Use when the user asks to "review code", "review my changes", "code review", "review this PR", "review pull request", "check code quality", "review this file", "review this diff", or wants feedback on code changes, code quality, or best practices.
Follow this sequence for every review:
Identify what to review based on the user's request:
git diff (unstaged), git diff --cached (staged), or git diff main...HEAD (branch changes) to identify modified files.gh pr diff <number> to get the changes.git diff main...<branch> to get the diff.git diff and git diff --cached to review all uncommitted changes.Always read the full file content for each changed file to understand context around the diff, not just the changed lines.
Read the full file for each changed file, not just the diff. Check for existing tests and follow established codebase conventions.
The model's training data has a knowledge cutoff. When reviewing code that uses libraries or frameworks, actively verify that APIs, patterns, and configurations are current:
pom.xml, build.gradle.kts, package.json, or other dependency files to determine the exact versions of libraries and frameworks in use.mcp__claude_ai_Context7__resolve-library-id then mcp__claude_ai_Context7__query-docs) to retrieve up-to-date documentation for any library or framework where:
WebSearch and WebFetch to check for:
gh CLI to check release notes, changelogs, or issues for dependencies when needed (e.g., gh api repos/{owner}/{repo}/releases/latest)Do not assume that an API or pattern is correct based solely on model knowledge. When in doubt, look it up.
Enforce these testing requirements:
latest.If SonarQube MCP tools are available, use them to augment the review:
mcp__sonarqube__* toolsIf SonarQube MCP tools are not available, skip this step silently — do not mention SonarQube is unavailable.
Output a structured review using this format:
## Code Review: [brief description of what was reviewed]
### Summary
[1-3 sentence overview of the changes and overall quality assessment]
### Critical Issues
[Issues that must be fixed — bugs, security vulnerabilities, data loss risks]
Each issue:
- **File:line** — Description of the issue
- Suggested fix or approach
### Warnings
[Issues that should likely be fixed — performance problems, design concerns, potential bugs]
Each issue:
- **File:line** — Description of the issue
- Suggested fix or approach
### Suggestions
[Optional improvements — readability, minor refactors, testing gaps]
Each issue:
- **File:line** — Description of the issue
- Suggested fix or approach
### What Looks Good
[2-3 positive observations about the code — good patterns, thorough testing, clean design]