code-reviewer-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese代码审查
Code Review
使用上下文隔离的 subagent 执行深度代码审查。
Perform in-depth code reviews using context-isolated subagents.
触发时机
Trigger Conditions
- 用户要求进行代码审查
- 用户提到"code review"、"代码审查"、"审查代码"等关键词
- 用户要求检查安全性、性能或代码质量
- User requests a code review
- User mentions keywords such as "code review", "代码审查", "审查代码"
- User requests checks for security, performance, or code quality
步骤
Steps
第一步:整理用户需求
Step 1: Organize User Requirements
将用户的审查需求整理为简洁的指令,包括:
- 审查目标(如"当前 git 暂存变更"、"src/auth/ 目录"、"PR #42")
- 重点关注方向(安全/性能/质量,如用户未指定则不限定)
- 其他用户补充的要求
如果用户未指定审查目标,整理为"审查当前项目的 git 暂存变更(git diff --cached)"。
Organize the user's review requirements into concise instructions, including:
- Review target (e.g., "current git staged changes", "src/auth/ directory", "PR #42")
- Focus areas (security/performance/quality; no restriction if not specified by the user)
- Additional requirements provided by the user
If the user does not specify a review target, default to "Review the git staged changes of the current project (git diff --cached)".
第二步:启动审查 subagent
Step 2: Launch Review Subagent
读取本目录下的 ,将其完整内容与第一步整理的需求拼接,作为 prompt 传给 Agent 工具 spawn subagent。
code-reviewer.md- : "深度代码审查"
description - :
prompt完整内容 + "\n\n## 审查任务\n" + 用户需求指令code-reviewer.md - : 读取
modelfrontmatter 中的code-reviewer.md字段决定(如未指定则默认 sonnet)model
关键原则:
- 不要在主 agent 中搜集代码内容,只传递审查目标的描述
- subagent 自己拥有 Bash、Read 等工具,会自行读取代码和 diff
- 必须将 的全部内容传递给 subagent,不可截断或摘要
code-reviewer.md
Read the file in the current directory, concatenate its full content with the requirements organized in Step 1, and pass it as a prompt to the Agent tool to spawn a subagent.
code-reviewer.md- : "In-depth Code Review"
description - : Full content of
prompt+ "\n\n## Review Task\n" + User requirement instructionscode-reviewer.md - : Determined by the
modelfield in the frontmatter ofmodel(default to sonnet if not specified)code-reviewer.md
Key Principles:
- Do not collect code content in the main agent, only pass the description of the review target
- The subagent has its own tools like Bash and Read, and will read code and diffs on its own
- Must pass the entire content of to the subagent; do not truncate or summarize
code-reviewer.md
第三步:输出审查结果
Step 3: Output Review Results
将 subagent 返回的审查结果直接输出给用户,不做摘要或缩写。
Directly output the review results returned by the subagent to the user without summarization or abbreviation.