Use a context-isolated subagent to perform in-depth code review.
Trigger conditions
- The user requests a code review
- The user mentions keywords such as "code review", "code review", "review code", etc.
- The user requests checking security, performance, or code quality
Steps
Step 1: Organize the user's requirements
Organize the user's review requirements into concise instructions, including:
- Review target (such as "current git staged changes", "src/auth/ directory", "PR #42")
- Focus areas (security/performance/quality; if the user does not specify, do not limit)
- Other requirements added by the user
If the user does not specify a review target, organize it as "review the current project's git staged changes (git diff --cached)".
Step 2: Launch the review subagent
Read the code-reviewer.mdin this directory, and use itsfull contentconcatenated with the requirements organized in Step 1 as the prompt passed to the Agent tool to spawn the subagent.
description: "In-depth code review"prompt:code-reviewer.mdfull content + "\n\n## Review Task\n" + user requirement instructionsmodel: readcode-reviewer.mdin the frontmattermodelfield to decide (if unspecified, default to sonnet)
Key principles:
- Do not gather code content in the main agent, only pass the description of the review target
- The subagent has its own Bash, Read, and other tools, and will read the code and diff itself
- Must pass all of the
code-reviewer.mdcontent to the subagent, without truncation or summarizing
Step 3: Output the review results
Output the review results returned by the subagent directly to the user, without summarizing or abbreviating.