Use a context-isolated subagent to perform an 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 a check of security, performance, or code quality
Steps
Step 1: Collect the review scope
Determine the target the user wants reviewed:
- Specific file paths or directories
- Current git changes (uncommitted or most recent commit)
- PR number
If the user does not specify explicitly, review the current git changes by default:
git diff --name-only HEAD~1
Step 2: Launch the review subagent
Read the code-reviewer.md in this directory to get the full review prompt, then use the Agent tool to spawn a subagent:
description: "In-depth code review"prompt: Use the content ofcode-reviewer.mdas the system prompt, attaching the code content or change scope to be reviewedmodel: Readcode-reviewer.mdin the frontmatter'smodelfield to decide (if unspecified, default to sonnet)
Step 3: Output the review results
Output the review results returned by the subagent directly to the user, without summarizing or abbreviating.