Review uncommitted or committed changes in the current branch and generate a code review report.
Input: Optionally specify:
- Review scope:
unstaged, staged, unpushed, all
- Review focus:
security, performance, style, architecture, all
IMPORTANT: This skill MUST read openspec/project.md before performing the review to understand project-specific conventions and constraints.
重要: 审查报告必须使用中文输出。
Steps
Load project conventions
CRITICAL: First read openspec/project.md to get:
- Technology stack constraints
- Layered architecture rules
- Naming conventions
- Code style requirements
- Design patterns
- Important constraints
Use these conventions as the baseline for the review.
Determine review scope
Run git status to see all changes.
Run git branch --show-current to get the current branch name.
Use AskUserQuestion tool to ask what to review:
Review scope options:
unstaged - Only unstaged changes (default if no staged changes)
staged - Only staged changes (default if staged changes exist)
unpushed - All commits not yet pushed to remote
all - All uncommitted changes + unpushed commits
If unpushed or all:
git log origin/<current-branch>..HEAD --oneline
to list unpushed commits.
Get diff content
For unstaged changes:
git diff
For staged changes:
git diff --cached
For unpushed commits:
git diff origin/<current-branch>..HEAD
For all changes:
git diff HEAD
git log origin/<current-branch>..HEAD --oneline
Run git diff --stat to get a summary of changes.
Secret scanning
Use git diff output to scan for potential secrets:
- API keys (patterns like
api_key, apikey, API_KEY)
- Passwords (
password, passwd, pwd)
- Tokens (
token, access_token, refresh_token)
- Private keys (
-----BEGIN.*PRIVATE KEY-----)
- Database URLs with credentials
- AWS/Azure/GCP credentials
If secrets detected:
- Add to Critical issues section
- Suggest using environment variables or secret management
- Warn about git history (may need
git filter-branch or BFG)
Perform code review based on openspec/project.md
Analyze the changes against the project conventions loaded from openspec/project.md:
5.1 Technology Stack Compliance:
- Java 8 compatibility (no Java 9+ features:
var, record, sealed, pattern matching, text blocks)
- Spring Boot annotations usage
- MyBatis/MyBatis-Plus usage (
@TableName)
- MapStruct for object conversion
- Lombok annotations (
@Data, @Builder, @Slf4j, @AllArgsConstructor, @NoArgsConstructor)
- PageHelper for pagination
- Swagger 2 (
@Api, @ApiOperation, @ApiModelProperty) or OpenAPI 3 (@Schema)
5.2 Layered Architecture Compliance:
Check that code follows the strict layering: Web → Biz → Core → Common
- No reverse dependencies (lower layers depending on upper layers)
- No cross-layer dependencies (each layer only depends on direct lower layer)
5.3 Naming Conventions:
| Type |
Pattern |
Example |
| Controller |
*Controller |
PurWebContractPaymentBaseController |
| BizService |
*BizService / *BizServiceImpl |
ContractPaymentBaseBizService |
| DomainService |
*DomainService / *DomainServiceImpl |
ContractPaymentBaseDomainService |
| Mapper |
@Repository |
ContractPaymentBaseMapper |
| ManualMapper |
*ManualMapper |
ContractPaymentBaseManualMapper |
| DO |
*DO |
ContractPaymentBaseDO |
| Model |
*Model |
ContractPaymentBaseModel |
| VO |
*VO |
WebContractPaymentConfirmedVO |
| Request |
*Request |
ContractPaymentBaseAddRequest |
| Converter |
*Convert / *Converter |
ContractPaymentBaseConvert |
| FacadeClient |
*FacadeClient / *FacadeClientImpl |
IdGeneratorFacadeClient |
| Utils |
*Utils |
AssertUtils |
| ConditionDalRequest |
*ConditionDalRequest |
ContractPaymentBaseConditionDalRequest |
5.4 Annotation Usage:
Controller Layer:
@RestController, @RequestMapping
@Api + @ApiOperation (Swagger 2) or @Schema (OpenAPI 3)
@Slf4j
@Authority(permissionCode = ...) or @NonLoginAuthority
@Validated with JSR-303 annotations
- Return type:
YzwResult<T>
BizService Layer:
- Interface:
*BizService
- Implementation:
@Service, @Slf4j, *BizServiceImpl
- Injection:
@Resource (preferred) or @Autowired
DomainService Layer:
- Interface:
*DomainService
- Implementation:
@Service, @Slf4j, *DomainServiceImpl
- Write operations:
@Transactional(rollbackFor = Throwable.class)
- Injection:
@Autowired or @Resource
DO Objects:
- Extend
AbstractBaseDO
@TableName (MyBatis-Plus)
@Data, @ToString(callSuper = true), @EqualsAndHashCode(callSuper = true)
- JavaDoc for fields
Model Objects:
- Extend
AbstractBaseBO
@Data
- JavaDoc for fields
Request Objects:
- AddRequest extends
CreateInfo
- UpdateRequest extends
UpdateInfo
@Data, @Builder, @AllArgsConstructor, @NoArgsConstructor
5.5 Code Style:
- Import order: Java stdlib → Third-party → Project internal
- No full package name imports (e.g., use
List not java.util.List)
- Empty lines between class members and methods
- Use
log.debug(), log.info(), log.error() - NO System.out.println()
5.6 Error Handling:
- Use
AssertUtils for validation
- Throw
BusinessException with BizErrorCode
- Private validation methods:
validateAddXxx(), validateUpdateXxx()
5.7 Pagination:
- Use
PageHelper.startPage(pageNum, pageSize)
- Convert to
Page<DO> type
- Use
PageConvertUtils.pageResultConvert(PageInfo, List)
- Empty result:
PageConvertUtils.getResult(PageInfo)
5.8 Object Conversion:
- MUST use MapStruct (
@Mapper with INSTANCE constant)
- Call pattern:
XxxConvert.INSTANCE.method(...)
- NO manual field-by-field conversion
5.9 Collection Handling:
- Use
CollectionUtils.isEmpty() / CollectionUtils.isNotEmpty()
- Use
StringUtils (Apache Commons Lang3) for strings
5.10 Transaction Management:
- Write operations MUST have
@Transactional(rollbackFor = Throwable.class)
- Read operations: no transaction needed
5.11 Security:
- SQL injection prevention (parameterized queries)
- XSS prevention
- Input validation
- Authentication/Authorization with
@Authority
5.12 Performance:
- N+1 query detection
- Batch query optimization
- Efficient algorithms
Check historical reviews
If review reports exist in openspec/review/:
- List previous review reports
- Compare with last review (if same branch)
- Highlight recurring issues
- Show improvement trend
Save review report to file (使用中文)
CRITICAL: 不需要询问用户,直接保存。
a. 用 Shell 创建目录(如不存在):mkdir -p openspec/review
b. 使用 Write 工具将报告写入 openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md
c. 如果同名文件已存在,使用 -N 后缀:YYYY-MM-DD-HH-mm-<branch-name>-review-N.md
Report structure (中文模板):
# 代码审查报告
**日期:** YYYY-MM-DD HH:mm
**分支:** <branch-name>
**审查人:** Claude Opus 4.6
**审查范围:** 未暂存 / 已暂存 / 未推送 / 全部
**规范基准:** openspec/project.md
## 概要
- 变更文件数: X
- 新增行数: X
- 删除行数: X
- 审查提交数: X (如果是未推送)
- 发现问题数: X (严重: X, 重要: X, 一般: X, 建议: X)
## 严重问题 🚨
<!-- 必须立即修复的严重问题 -->
1. **[安全] SQL注入风险** - `path/to/file.java:123`
```java
// 问题代码片段
修复建议: 使用参数化查询
重要问题 ⚠️
一般问题 📝
改进建议 💡
规范违规 (openspec/project.md)
| 规范类型 |
文件 |
问题描述 |
| 命名规范: Controller |
path/to/file.java |
类名应以 'Controller' 结尾 |
| 架构规范: 分层 |
path/to/file.java |
Core层不应依赖Biz层 |
已审查文件
| 文件 |
变更行数 |
问题数 |
严重程度 |
| path/to/file.java |
+50/-10 |
2 |
重要 |
敏感信息扫描结果
与上次审查对比
- 上次审查日期: YYYY-MM-DD HH:mm
- 已解决问题: X
- 新发现问题: X
- 重复问题: X
修复建议
- 优先修复项
- 后续步骤
亮点肯定 ✨
Output full report to conversation, then prompt for fix proposal (输出报告+询问提案,合并为一条消息)
在同一条消息中完成以下全部内容:
a. 输出完整报告内容到对话(与 Step 7 保存到文件的内容相同)
b. 在报告末尾注明:> 报告已保存到 openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md
c. 如果发现严重或重要问题,在报告输出之后使用 AskUserQuestion tool 询问:
"审查发现 X 个严重问题和 Y 个重要问题。是否需要生成 OpenSpec 修复提案?"
选项:
生成修复提案 - 使用 /opsx:propose 生成修复提案
暂不生成 - 稍后手动处理
d. 如果仅有一般问题和建议,不发起 AskQuestion,消息到此结束。
If user chose to generate fix proposal, create proposal and append summary to report (提案生成+摘要回写)
当用户选择"生成修复提案"后:
a. 根据问题类型生成提案名称(kebab-case):
- 安全问题:
fix-security-<issue-type>
- 规范违规:
fix-convention-<issue-type>
- 性能问题:
fix-performance-<issue-type>
- 混合问题:
fix-<主要问题描述>
b. 构建提案描述:
- Why: 说明发现的问题及其影响
- What Changes: 列出需要修复的文件和修改内容
- 引用审查报告路径
c. 调用 /opsx:propose 生成修复提案
d. 提案生成完成后,必须将提案摘要追加写入已保存的报告文件末尾(Read 报告文件获取当前内容,在末尾追加后重新 Write),追加内容:
## 修复提案
**提案名称:** <change-name>
**提案路径:** `openspec/changes/<change-name>/`
**生成时间:** YYYY-MM-DD HH:mm
### 提案包含制品
- `proposal.md` - 提案文档
- `design.md` - 设计文档
- `specs/` - 规格文档
- `tasks.md` - 实施任务
### 后续操作
运行 `/opsx:apply` 开始实施修复。
e. 在对话中告知用户:提案已生成,摘要已追加到报告文件中,运行 /opsx:apply 开始实施修复。
如果只有一般问题或建议:
- 不自动提示生成提案
- 用户可手动运行
/opsx:propose 生成提案
Output On Success (中文输出)
## 代码审查完成
**分支:** <branch-name>
**审查范围:** <scope>
**规范基准:** openspec/project.md
**报告路径:** openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md
### 问题统计
| 严重程度 | 数量 |
|----------|------|
| 严重 | X |
| 重要 | X |
| 一般 | X |
| 建议 | X |
### 规范违规统计
| 类型 | 数量 |
|------|------|
| 命名规范 | X |
| 架构规范 | X |
| 代码风格 | X |
### 敏感信息扫描
✅ 未检测到敏感信息
<!-- 或者 -->
⚠️ 在 X 个文件中检测到潜在敏感信息 - 详情见报告
### 严重问题(必须在提交前修复)
1. **[安全] SQL注入** - `path/to/file.java:123`
2. ...
### 后续步骤
1. 修复严重问题
2. 修复规范违规
3. 审查重要问题
4. 重新运行代码审查: `/git-code-review`
Output With Fix Proposal (用户同意生成提案后的最终输出)
## 修复提案已生成
**提案名称:** fix-<issue-name>
**提案路径:** openspec/changes/fix-<issue-name>/
**提案摘要已追加到报告文件中:** openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md
### 提案包含制品
- `proposal.md` - 提案文档
- `design.md` - 设计文档
- `specs/` - 规格文档
- `tasks.md` - 实施任务
运行 `/opsx:apply` 开始实施修复。
严重程度说明
| 严重程度 |
图标 |
判定标准 |
处理建议 |
| 严重 |
🚨 |
安全漏洞、Bug、破坏性变更、敏感信息泄露 |
必须在提交前修复 |
| 重要 |
⚠️ |
规范违规、性能问题、SOLID原则违反 |
应在合并前修复 |
| 一般 |
📝 |
代码风格、命名、注释 |
建议修复 |
| 建议 |
💡 |
最佳实践、优化建议 |
可选修复 |
Review Focus Areas
When user specifies focus areas, prioritize:
security - Focus on security vulnerabilities + secret scanning
performance - Focus on performance issues + N+1 queries
style - Focus on code style and conventions
architecture - Focus on layered architecture and design patterns
all - Full review (default)
Guardrails
- ALWAYS read
openspec/project.md before reviewing
- Always ask for review scope first (Step 2 is the ONLY place to use AskQuestion before the report)
- Always run secret scanning
- ALWAYS save review report to
openspec/review/ — do NOT ask, just save and also output to conversation
- 审查报告必须使用中文输出
- Use severity levels consistently
- Check against project-specific conventions from openspec/project.md
- Provide actionable recommendations with file paths and line numbers
- Include code snippets in issue descriptions
- Include positive highlights to encourage good practices
- Never auto-fix issues without user confirmation
- Compare with previous reviews for trend analysis
- AskQuestion 使用约束:整个流程最多使用两次 AskQuestion —— Step 2(选择审查范围)和 Step 8c(仅当存在严重或重要问题时询问是否生成提案)。不要在其他步骤额外询问。
- Step 7 仅保存文件,Step 8 才输出到对话:严格分离"保存"和"展示"两个动作,避免重复或遗漏。
- 生成修复提案时:
- 仅在发现严重或重要问题时提示生成提案
- 提案名称使用 kebab-case 格式
- 提案描述必须包含审查报告路径
- 生成的提案应包含具体的修复步骤
- 提案生成后必须将摘要追加到已保存的报告文件末尾
Error Handling
- If
openspec/project.md not found: Warn user and use default conventions
- If no changes to review: Inform user and exit
- If diff is too large (>5000 lines): Review file by file and summarize
- If review directory creation fails: Show error and suggest manual creation
- If secret scanning fails: Continue review and note the failure
Convention Checklist (from openspec/project.md)
| Category |
Check |
| Java Version |
Java 8 compatible |
| Layering |
Web → Biz → Core → Common, no reverse deps |
| Naming |
Controller/BizService/DomainService/DO/Model/VO/Request |
| Annotations |
@RestController/@Service/@Transactional/@Data/@Builder |
| Transaction |
@Transactional(rollbackFor = Throwable.class) on writes |
| Pagination |
PageHelper.startPage() + PageConvertUtils |
| Conversion |
MapStruct with INSTANCE, no manual conversion |
| Error |
AssertUtils + BusinessException + BizErrorCode |
| Logging |
log.debug/info/error, no System.out |
| Imports |
Java stdlib → Third-party → Project internal |
| Collections |
CollectionUtils.isEmpty/isNotEmpty |
| Strings |
StringUtils (Apache Commons) |
1---2name: git-code-review3description: Review uncommitted or committed changes in the current branch and generate a code review report. Use when the user wants to review their changes before or after committing.4license: MIT5---67Review uncommitted or committed changes in the current branch and generate a code review report.89**Input**: Optionally specify:10- Review scope: `unstaged`, `staged`, `unpushed`, `all`11- Review focus: `security`, `performance`, `style`, `architecture`, `all`1213**IMPORTANT**: This skill MUST read `openspec/project.md` before performing the review to understand project-specific conventions and constraints.1415**重要**: 审查报告必须使用中文输出。1617**Steps**18191. **Load project conventions**2021 **CRITICAL**: First read `openspec/project.md` to get:22 - Technology stack constraints23 - Layered architecture rules24 - Naming conventions25 - Code style requirements26 - Design patterns27 - Important constraints2829 Use these conventions as the baseline for the review.30312. **Determine review scope**3233 Run `git status` to see all changes.3435 Run `git branch --show-current` to get the current branch name.3637 Use **AskUserQuestion tool** to ask what to review:3839 **Review scope options:**40 - `unstaged` - Only unstaged changes (default if no staged changes)41 - `staged` - Only staged changes (default if staged changes exist)42 - `unpushed` - All commits not yet pushed to remote43 - `all` - All uncommitted changes + unpushed commits4445 **If `unpushed` or `all`:**46 ```bash47 git log origin/<current-branch>..HEAD --oneline48 ```49 to list unpushed commits.50513. **Get diff content**5253 For **unstaged changes:**54 ```bash55 git diff56 ```5758 For **staged changes:**59 ```bash60 git diff --cached61 ```6263 For **unpushed commits:**64 ```bash65 git diff origin/<current-branch>..HEAD66 ```6768 For **all changes:**69 ```bash70 git diff HEAD71 git log origin/<current-branch>..HEAD --oneline72 ```7374 Run `git diff --stat` to get a summary of changes.75764. **Secret scanning**7778 Use `git diff` output to scan for potential secrets:79 - API keys (patterns like `api_key`, `apikey`, `API_KEY`)80 - Passwords (`password`, `passwd`, `pwd`)81 - Tokens (`token`, `access_token`, `refresh_token`)82 - Private keys (`-----BEGIN.*PRIVATE KEY-----`)83 - Database URLs with credentials84 - AWS/Azure/GCP credentials8586 **If secrets detected:**87 - Add to Critical issues section88 - Suggest using environment variables or secret management89 - Warn about git history (may need `git filter-branch` or BFG)90915. **Perform code review based on openspec/project.md**9293 Analyze the changes against the project conventions loaded from `openspec/project.md`:9495 **5.1 Technology Stack Compliance:**96 - Java 8 compatibility (no Java 9+ features: `var`, `record`, `sealed`, pattern matching, text blocks)97 - Spring Boot annotations usage98 - MyBatis/MyBatis-Plus usage (`@TableName`)99 - MapStruct for object conversion100 - Lombok annotations (`@Data`, `@Builder`, `@Slf4j`, `@AllArgsConstructor`, `@NoArgsConstructor`)101 - PageHelper for pagination102 - Swagger 2 (`@Api`, `@ApiOperation`, `@ApiModelProperty`) or OpenAPI 3 (`@Schema`)103104 **5.2 Layered Architecture Compliance:**105 Check that code follows the strict layering: Web → Biz → Core → Common106 - No reverse dependencies (lower layers depending on upper layers)107 - No cross-layer dependencies (each layer only depends on direct lower layer)108109 **5.3 Naming Conventions:**110111 | Type | Pattern | Example |112 |------|---------|---------|113 | Controller | `*Controller` | `PurWebContractPaymentBaseController` |114 | BizService | `*BizService` / `*BizServiceImpl` | `ContractPaymentBaseBizService` |115 | DomainService | `*DomainService` / `*DomainServiceImpl` | `ContractPaymentBaseDomainService` |116 | Mapper | `@Repository` | `ContractPaymentBaseMapper` |117 | ManualMapper | `*ManualMapper` | `ContractPaymentBaseManualMapper` |118 | DO | `*DO` | `ContractPaymentBaseDO` |119 | Model | `*Model` | `ContractPaymentBaseModel` |120 | VO | `*VO` | `WebContractPaymentConfirmedVO` |121 | Request | `*Request` | `ContractPaymentBaseAddRequest` |122 | Converter | `*Convert` / `*Converter` | `ContractPaymentBaseConvert` |123 | FacadeClient | `*FacadeClient` / `*FacadeClientImpl` | `IdGeneratorFacadeClient` |124 | Utils | `*Utils` | `AssertUtils` |125 | ConditionDalRequest | `*ConditionDalRequest` | `ContractPaymentBaseConditionDalRequest` |126127 **5.4 Annotation Usage:**128129 **Controller Layer:**130 - `@RestController`, `@RequestMapping`131 - `@Api` + `@ApiOperation` (Swagger 2) or `@Schema` (OpenAPI 3)132 - `@Slf4j`133 - `@Authority(permissionCode = ...)` or `@NonLoginAuthority`134 - `@Validated` with JSR-303 annotations135 - Return type: `YzwResult<T>`136137 **BizService Layer:**138 - Interface: `*BizService`139 - Implementation: `@Service`, `@Slf4j`, `*BizServiceImpl`140 - Injection: `@Resource` (preferred) or `@Autowired`141142 **DomainService Layer:**143 - Interface: `*DomainService`144 - Implementation: `@Service`, `@Slf4j`, `*DomainServiceImpl`145 - Write operations: `@Transactional(rollbackFor = Throwable.class)`146 - Injection: `@Autowired` or `@Resource`147148 **DO Objects:**149 - Extend `AbstractBaseDO`150 - `@TableName` (MyBatis-Plus)151 - `@Data`, `@ToString(callSuper = true)`, `@EqualsAndHashCode(callSuper = true)`152 - JavaDoc for fields153154 **Model Objects:**155 - Extend `AbstractBaseBO`156 - `@Data`157 - JavaDoc for fields158159 **Request Objects:**160 - AddRequest extends `CreateInfo`161 - UpdateRequest extends `UpdateInfo`162 - `@Data`, `@Builder`, `@AllArgsConstructor`, `@NoArgsConstructor`163164 **5.5 Code Style:**165 - Import order: Java stdlib → Third-party → Project internal166 - No full package name imports (e.g., use `List` not `java.util.List`)167 - Empty lines between class members and methods168 - Use `log.debug()`, `log.info()`, `log.error()` - NO `System.out.println()`169170 **5.6 Error Handling:**171 - Use `AssertUtils` for validation172 - Throw `BusinessException` with `BizErrorCode`173 - Private validation methods: `validateAddXxx()`, `validateUpdateXxx()`174175 **5.7 Pagination:**176 - Use `PageHelper.startPage(pageNum, pageSize)`177 - Convert to `Page<DO>` type178 - Use `PageConvertUtils.pageResultConvert(PageInfo, List)`179 - Empty result: `PageConvertUtils.getResult(PageInfo)`180181 **5.8 Object Conversion:**182 - MUST use MapStruct (`@Mapper` with `INSTANCE` constant)183 - Call pattern: `XxxConvert.INSTANCE.method(...)`184 - NO manual field-by-field conversion185186 **5.9 Collection Handling:**187 - Use `CollectionUtils.isEmpty()` / `CollectionUtils.isNotEmpty()`188 - Use `StringUtils` (Apache Commons Lang3) for strings189190 **5.10 Transaction Management:**191 - Write operations MUST have `@Transactional(rollbackFor = Throwable.class)`192 - Read operations: no transaction needed193194 **5.11 Security:**195 - SQL injection prevention (parameterized queries)196 - XSS prevention197 - Input validation198 - Authentication/Authorization with `@Authority`199200 **5.12 Performance:**201 - N+1 query detection202 - Batch query optimization203 - Efficient algorithms2042056. **Check historical reviews**206207 If review reports exist in `openspec/review/`:208 - List previous review reports209 - Compare with last review (if same branch)210 - Highlight recurring issues211 - Show improvement trend2122137. **Save review report to file (使用中文)**214215 **CRITICAL: 不需要询问用户,直接保存。**216217 a. 用 Shell 创建目录(如不存在):`mkdir -p openspec/review`218 b. 使用 Write 工具将报告写入 `openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md`219 c. 如果同名文件已存在,使用 `-N` 后缀:`YYYY-MM-DD-HH-mm-<branch-name>-review-N.md`220221 **Report structure (中文模板):**222 ```markdown223 # 代码审查报告224225 **日期:** YYYY-MM-DD HH:mm226 **分支:** <branch-name>227 **审查人:** Claude Opus 4.6228 **审查范围:** 未暂存 / 已暂存 / 未推送 / 全部229 **规范基准:** openspec/project.md230231 ## 概要232233 - 变更文件数: X234 - 新增行数: X235 - 删除行数: X236 - 审查提交数: X (如果是未推送)237 - 发现问题数: X (严重: X, 重要: X, 一般: X, 建议: X)238239 ## 严重问题 🚨240241 <!-- 必须立即修复的严重问题 -->242243 1. **[安全] SQL注入风险** - `path/to/file.java:123`244 ```java245 // 问题代码片段246 ```247 **修复建议:** 使用参数化查询248249 ## 重要问题 ⚠️250251 <!-- 应该修复的重要问题 -->252253 ## 一般问题 📝254255 <!-- 轻微问题或代码风格改进 -->256257 ## 改进建议 💡258259 <!-- 可选的改进建议 -->260261 ## 规范违规 (openspec/project.md)262263 <!-- 违反项目规范的问题 -->264265 | 规范类型 | 文件 | 问题描述 |266 |----------|------|----------|267 | 命名规范: Controller | path/to/file.java | 类名应以 'Controller' 结尾 |268 | 架构规范: 分层 | path/to/file.java | Core层不应依赖Biz层 |269270 ## 已审查文件271272 | 文件 | 变更行数 | 问题数 | 严重程度 |273 |------|----------|--------|----------|274 | path/to/file.java | +50/-10 | 2 | 重要 |275276 ## 敏感信息扫描结果277278 - 未检测到敏感信息 ✅279 <!-- 或者 -->280 - ⚠️ 在 X 个文件中检测到潜在敏感信息281282 ## 与上次审查对比283284 <!-- 如果存在之前的审查记录 -->285 - 上次审查日期: YYYY-MM-DD HH:mm286 - 已解决问题: X287 - 新发现问题: X288 - 重复问题: X289290 ## 修复建议291292 1. 优先修复项293 2. 后续步骤294295 ## 亮点肯定 ✨296297 <!-- 代码中发现的良好实践 -->298 ```2993008. **Output full report to conversation, then prompt for fix proposal (输出报告+询问提案,合并为一条消息)**301302 **在同一条消息中完成以下全部内容:**303304 a. **输出完整报告内容**到对话(与 Step 7 保存到文件的内容相同)305 b. **在报告末尾注明**:`> 报告已保存到 openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md`306 c. **如果发现严重或重要问题**,在报告输出之后使用 **AskUserQuestion tool** 询问:307 > "审查发现 X 个严重问题和 Y 个重要问题。是否需要生成 OpenSpec 修复提案?"308309 **选项:**310 - `生成修复提案` - 使用 `/opsx:propose` 生成修复提案311 - `暂不生成` - 稍后手动处理312 d. **如果仅有一般问题和建议**,不发起 AskQuestion,消息到此结束。3133149. **If user chose to generate fix proposal, create proposal and append summary to report (提案生成+摘要回写)**315316 **当用户选择"生成修复提案"后:**317318 a. 根据问题类型生成提案名称(kebab-case):319 - 安全问题:`fix-security-<issue-type>`320 - 规范违规:`fix-convention-<issue-type>`321 - 性能问题:`fix-performance-<issue-type>`322 - 混合问题:`fix-<主要问题描述>`323324 b. 构建提案描述:325 - **Why**: 说明发现的问题及其影响326 - **What Changes**: 列出需要修复的文件和修改内容327 - 引用审查报告路径328329 c. 调用 `/opsx:propose` 生成修复提案330331 d. 提案生成完成后,**必须将提案摘要追加写入已保存的报告文件末尾**(Read 报告文件获取当前内容,在末尾追加后重新 Write),追加内容:332333 ```markdown334 ## 修复提案335336 **提案名称:** <change-name>337 **提案路径:** `openspec/changes/<change-name>/`338 **生成时间:** YYYY-MM-DD HH:mm339340 ### 提案包含制品341 - `proposal.md` - 提案文档342 - `design.md` - 设计文档343 - `specs/` - 规格文档344 - `tasks.md` - 实施任务345346 ### 后续操作347 运行 `/opsx:apply` 开始实施修复。348 ```349350 e. 在对话中告知用户:提案已生成,摘要已追加到报告文件中,运行 `/opsx:apply` 开始实施修复。351352 **如果只有一般问题或建议:**353 - 不自动提示生成提案354 - 用户可手动运行 `/opsx:propose` 生成提案355356**Output On Success (中文输出)**357358```359## 代码审查完成360361**分支:** <branch-name>362**审查范围:** <scope>363**规范基准:** openspec/project.md364**报告路径:** openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md365366### 问题统计367368| 严重程度 | 数量 |369|----------|------|370| 严重 | X |371| 重要 | X |372| 一般 | X |373| 建议 | X |374375### 规范违规统计376377| 类型 | 数量 |378|------|------|379| 命名规范 | X |380| 架构规范 | X |381| 代码风格 | X |382383### 敏感信息扫描384✅ 未检测到敏感信息385<!-- 或者 -->386⚠️ 在 X 个文件中检测到潜在敏感信息 - 详情见报告387388### 严重问题(必须在提交前修复)3891. **[安全] SQL注入** - `path/to/file.java:123`3902. ...391392### 后续步骤3931. 修复严重问题3942. 修复规范违规3953. 审查重要问题3964. 重新运行代码审查: `/git-code-review`397```398399**Output With Fix Proposal (用户同意生成提案后的最终输出)**400401```402## 修复提案已生成403404**提案名称:** fix-<issue-name>405**提案路径:** openspec/changes/fix-<issue-name>/406**提案摘要已追加到报告文件中:** openspec/review/YYYY-MM-DD-HH-mm-<branch-name>-review.md407408### 提案包含制品409- `proposal.md` - 提案文档410- `design.md` - 设计文档411- `specs/` - 规格文档412- `tasks.md` - 实施任务413414运行 `/opsx:apply` 开始实施修复。415```416417**严重程度说明**418419| 严重程度 | 图标 | 判定标准 | 处理建议 |420|----------|------|----------|----------|421| 严重 | 🚨 | 安全漏洞、Bug、破坏性变更、敏感信息泄露 | 必须在提交前修复 |422| 重要 | ⚠️ | 规范违规、性能问题、SOLID原则违反 | 应在合并前修复 |423| 一般 | 📝 | 代码风格、命名、注释 | 建议修复 |424| 建议 | 💡 | 最佳实践、优化建议 | 可选修复 |425426**Review Focus Areas**427428When user specifies focus areas, prioritize:429- `security` - Focus on security vulnerabilities + secret scanning430- `performance` - Focus on performance issues + N+1 queries431- `style` - Focus on code style and conventions432- `architecture` - Focus on layered architecture and design patterns433- `all` - Full review (default)434435**Guardrails**436437- ALWAYS read `openspec/project.md` before reviewing438- Always ask for review scope first (Step 2 is the ONLY place to use AskQuestion before the report)439- Always run secret scanning440- **ALWAYS save review report to `openspec/review/` — do NOT ask, just save and also output to conversation**441- **审查报告必须使用中文输出**442- Use severity levels consistently443- Check against project-specific conventions from openspec/project.md444- Provide actionable recommendations with file paths and line numbers445- Include code snippets in issue descriptions446- Include positive highlights to encourage good practices447- Never auto-fix issues without user confirmation448- Compare with previous reviews for trend analysis449- **AskQuestion 使用约束**:整个流程最多使用两次 AskQuestion —— Step 2(选择审查范围)和 Step 8c(仅当存在严重或重要问题时询问是否生成提案)。不要在其他步骤额外询问。450- **Step 7 仅保存文件,Step 8 才输出到对话**:严格分离"保存"和"展示"两个动作,避免重复或遗漏。451- **生成修复提案时:**452 - 仅在发现严重或重要问题时提示生成提案453 - 提案名称使用 kebab-case 格式454 - 提案描述必须包含审查报告路径455 - 生成的提案应包含具体的修复步骤456 - **提案生成后必须将摘要追加到已保存的报告文件末尾**457458**Error Handling**459460- If `openspec/project.md` not found: Warn user and use default conventions461- If no changes to review: Inform user and exit462- If diff is too large (>5000 lines): Review file by file and summarize463- If review directory creation fails: Show error and suggest manual creation464- If secret scanning fails: Continue review and note the failure465466**Convention Checklist (from openspec/project.md)**467468| Category | Check |469|----------|-------|470| Java Version | Java 8 compatible |471| Layering | Web → Biz → Core → Common, no reverse deps |472| Naming | Controller/BizService/DomainService/DO/Model/VO/Request |473| Annotations | @RestController/@Service/@Transactional/@Data/@Builder |474| Transaction | @Transactional(rollbackFor = Throwable.class) on writes |475| Pagination | PageHelper.startPage() + PageConvertUtils |476| Conversion | MapStruct with INSTANCE, no manual conversion |477| Error | AssertUtils + BusinessException + BizErrorCode |478| Logging | log.debug/info/error, no System.out |479| Imports | Java stdlib → Third-party → Project internal |480| Collections | CollectionUtils.isEmpty/isNotEmpty |481| Strings | StringUtils (Apache Commons) |