Review generated code with a fresh instance
Judge a review design for its blind spots, and defend one that uses an independent reviewer, per-file plus cross-file passes, and a confidence on each finding to route it.
Scenario
Scenario: Claude Code for Continuous Integration. A CI job asks Claude Code to add cursor pagination to the orders export API. The change touches 14 files: a new partially_refunded order status in the model, a page-size parameter, and the export mapper.
At the end of the job, the same session is asked: "Review your changes for mistakes." It replies that the change is complete and correct. The pull request merges.
A week later two bugs surface. Every page returns one order fewer than requested, and exports crash on any order with the new status, because the mapper in another file has no case for it.
Before reading on: what about this review made both bugs easy to miss?
Explanation
Why self-review fails. A model reviewing in the session that wrote the code keeps the reasoning that produced it, so it is less likely to question its own decisions. Claude Code's docs say it directly: a fresh context improves code review because Claude won't be biased toward code it just wrote. A reviewer in a fresh context sees only the diff and the criteria you give it, so it judges the result on its own terms. Asking the writer to "verify your work", or letting it think longer, doesn't give you that independence.
What the independent reviewer gets: the diff, the criteria (what to report, how severe), and the surrounding code it needs. Not the writer's reasoning or its summary of what it meant to do.
Large changes: two kinds of pass.
- Per-file passes look at one file at a time for local issues. Each pass stays focused, instead of one long pass where attention thins out as the context fills.
- A cross-file integration pass looks at what flows between files: a new enum value, a renamed field, a changed function signature, and every place that uses it.
Confidence per finding, for routing. Have a verification pass re-check each finding and report its confidence. Use it to decide where findings go (high confidence to an inline comment, low confidence to a human queue), not to silently drop them, and compare it against which findings developers dismiss. Anthropic's own managed Code Review follows a similar shape: several agents find candidate issues, a verification step checks them against the code, and the rest are ranked by severity.