Code Review with AI: Fresh Eyes Instead of Self-Grading
AI review works best with fresh context: the agent that wrote the code shouldn't be the one grading it โ and the review brief needs clear boundaries.
The core principle: fresh context
Anthropic's best practices are unambiguous here: a fresh context improves review because Claude isn't biased toward code it just wrote itself. The author tends to consider their own approach correct โ a reviewer that only sees the diff and the criteria evaluates the result independently. That's why the /code-review command in Claude Code runs in its own subagent with fresh context.
The tools
Locally, /code-review checks the current diff for bugs before you push. On GitHub, an automated review can analyze every pull request and post findings as inline comments with severity levels.
What AI review does well โ and what it doesn't
It's strong on correctness: logic errors, missed edge cases, violations of documented project rules. It's weak on judgments that need context beyond the code: architecture decisions, tradeoffs, whether an abstraction helps the team long-term. And: a reviewer told to find gaps will almost always find some โ even in solid work.
Narrowing the brief
So constrain the review prompt: name what is being checked, against what, and what counts as a finding. The docs put it like this: "Report gaps, not style preferences."
EXAMPLE
Review prompt with clear boundaries: 'Use a subagent to review the rate-limiter diff against PLAN.md. Check: every requirement implemented? Edge cases tested? Nothing outside the task's scope changed? Report gaps, not style preferences.'
๐ ๏ธ EXERCISE โ TRY IT YOURSELF
Have a fresh context review a diff, then evaluate the findings yourself.
- Make a small change in a project (or take an open branch) and run /code-review in Claude Code.
- Sort the findings into two groups: 'affects correctness' and 'style/taste'.
- Fix only the correctness findings and note which ones you deliberately discard โ with a one-sentence justification.
โ SELF-CHECK
- โ Were you able to assign every finding to one of the two groups?
- โ Did you discard at least one finding with a stated reason instead of chasing everything?
- โ Can you explain why the review ran in a subagent instead of your session?
QUICK QUIZ
According to Anthropic, why should code review run in a fresh context โ not in the session that wrote the code?
SOURCES
- Claude Code docs: Best practices (adversarial review) โ code.claude.com
- Claude Code docs: Code review โ code.claude.com
- Claude Code docs: Commands reference โ code.claude.com