code-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Review

代码审查

Context

上下文

Staged diff:
!
git diff --cached
Recent commits (for context):
!
git log --oneline -10
暂存差异:
!
git diff --cached
最近提交(用于上下文参考):
!
git log --oneline -10

Arguments

参数

Raw arguments: $ARGUMENTS
Parse the arguments as follows:
  • Agent (optional, first argument): The CLI command or agent name to delegate the review to. Recognized values:
    • claude
      or
      self
      or empty — perform the review directly in this context (default)
    • Any other value — treated as a CLI command name (e.g.
      codex
      ,
      aider
      ,
      goose
      ). The review will be delegated by invoking that command via Bash (see Delegation section).
  • Feature (optional, remaining arguments after agent): A description of what part of the codebase to review (e.g. "voting functionality", "authentication", "API endpoints"). When provided, find and review all files related to this feature. When empty/omitted, review staged changes instead.
If only one argument is given and it does NOT match a known agent name (
claude
,
self
), treat it as the feature instead, with agent defaulting to
claude
.
原始参数:$ARGUMENTS
参数解析规则如下:
  • Agent(可选,第一个参数):用于委托审查的CLI命令或Agent名称。认可的值包括:
    • claude
      self
      或留空——直接在此上下文中执行审查(默认行为)
    • 其他任意值——视为CLI命令名称(例如
      codex
      aider
      goose
      )。审查将通过Bash调用该命令进行委托(详见委托部分)。
  • 功能模块(可选,Agent之后的剩余参数):描述需要审查的代码库部分(例如“投票功能”、“身份验证”、“API端点”)。提供该参数时,查找并审查所有与该功能相关的文件。留空时,审查暂存的变更。
如果仅提供一个参数且该参数不匹配已知的Agent名称(
claude
self
),则将其视为功能模块,Agent默认使用
claude

Instructions

操作说明

Determine what to review

确定审查范围

  1. If a feature is specified — use Glob and Grep to find all files related to the described feature. Read those files and review them as existing code.
  2. If no feature is specified and there are staged changes — review the staged diff shown above.
  3. If no feature is specified and there are NO staged changes — tell the user: "Nothing to review. Either stage changes with
    git add
    or specify a feature to review, e.g.
    /code-review voting functionality
    ." Then stop.
  1. 指定了功能模块时——使用Glob和Grep查找所有与描述的功能相关的文件。读取这些文件并作为现有代码进行审查。
  2. 未指定功能模块但存在暂存变更时——审查上方显示的暂存差异。
  3. 未指定功能模块且无暂存变更时——告知用户:“没有可审查的内容。请使用
    git add
    暂存变更,或指定要审查的功能模块,例如
    /code-review voting functionality
    。” 然后停止操作。

Perform the review

执行审查

Read surrounding source files as needed to understand context. Organize findings by file, then by severity.
根据需要读取周边源文件以理解上下文。按文件分类,再按严重程度整理审查结果。

Severity levels

严重程度等级

  1. 🔴 Critical — Bugs, security vulnerabilities, data loss risks, or crashes. Must be fixed.
  2. 🟠 Error — Logic errors, missing error handling, broken edge cases. Very likely to cause problems.
  3. 🟡 Warning — Code smells, performance concerns, potential edge cases, maintainability issues.
  4. 🔵 Suggestion — Better approaches, readability improvements, idiomatic alternatives.
  5. ⚪ Nitpick — Style, naming, formatting, minor preferences. Totally optional.
  1. 🔴 关键——漏洞、安全隐患、数据丢失风险或崩溃问题。必须修复。
  2. 🟠 错误——逻辑错误、缺少错误处理、边缘场景失效。极有可能引发问题。
  3. 🟡 警告——代码异味、性能问题、潜在边缘场景、可维护性问题。
  4. 🔵 建议——更优实现方式、可读性提升、符合语言习惯的替代方案。
  5. ⚪ 细节优化——风格、命名、格式、次要偏好。完全可选。

Output format

输出格式

Group findings by severity. Each severity level that has findings should be its own heading (e.g.
## 🔴 Critical
,
## 🟠 Error
, etc.). Within each severity heading, list the findings. For each finding, include:
  • The file and line reference
  • A concise description of the issue
  • A suggested fix or alternative (when applicable)
Omit severity headings that have no findings.
End with a
## Summary
section: overall assessment, whether changes look good to merge (or code looks healthy), and a count of findings per severity level.
按严重程度分组展示结果。每个有结果的严重程度等级应作为独立标题(例如
## 🔴 关键
## 🟠 错误
等)。每个严重程度标题下,列出审查发现。每个发现需包含:
  • 文件和行号引用
  • 问题的简洁描述
  • 建议的修复方案或替代方案(如有)
省略没有发现的严重程度标题。
最后添加
## 总结
部分:整体评估、变更是否适合合并(或代码是否健康),以及各严重等级的发现数量统计。

Delegation

委托审查

If the agent is not
claude
/
self
/empty, it is treated as a CLI command name. Delegate the review by invoking that command via Bash:
  • Build a prompt that includes the review instructions, severity levels, output format, and either the staged diff or the feature description
  • Run:
    <agent> -q "<prompt>"
    where
    <agent>
    is the CLI command the user specified (e.g.
    codex
    ,
    aider
    ,
    goose
    )
  • When the command returns, relay its findings to the user verbatim
如果Agent不是
claude
/
self
/留空,则将其视为CLI命令名称。通过Bash调用该命令进行委托审查:
  • 构建包含审查说明、严重程度等级、输出格式以及暂存差异或功能模块描述的提示词
  • 执行:
    <agent> -q "<prompt>"
    ,其中
    <agent>
    是用户指定的CLI命令(例如
    codex
    aider
    goose
  • 命令返回结果后,将其内容原封不动地转发给用户