AgentRecipes
Recipes › Engineering & security

How to review agent-written pull requests with layered AI review and risk-based human approval

Engineering & securityClaude Code✓ Confirmed by source

Confirmed by source: Anthropic's Claude Code team describes the review process they run in production on their own repositories, with before/after figures on merges, reverts and review rounds, plus an adoption checklist for other teams. (checked 2026-10-17)

The problem

Once coding agents open pull requests, there are far more changes than people can read line by line, but skipping review lets bugs and risky changes slip into production.

Tools needed

Step-by-step recipe

  1. Before a PR exists, give the agent something it can run (tests, build, linter, a screenshot to compare) and have it show the output; list those checks in a short CLAUDE.md and let a fresh-context subagent or /code-review and /security-review look at the diff.
  2. Write a short REVIEW.md per area that says what a real failure looks like there, caps nitpicks, lists paths to skip and asks for file-and-line evidence; whenever the reviewer repeats the same comment, fold it into REVIEW.md, a lint rule or a skill.
  3. On every PR, require CI plus an AI reviewer (start on one repo, tune for a few weeks, then widen) and an automated security pass; block the merge until every finding is either fixed or resolved with a stated reason.
  4. Set human approvals by risk tier decided from the change, not the author: none for low-risk docs or flagged additive changes, one person for ordinary or sensitive changes, two for the riskiest paths; use CODEOWNERS so auth, billing, CI workflows and installers always need a person, and never count a bot approval as a human one.
  5. Cap review rounds (the team uses three before asking the author to rethink), re-review only the new diff after the first passes, and avoid reposting findings already raised.
  6. Merge through a queue that re-runs checks on the latest main, ship behind flags to internal users first, release in stages, keep one-step rollback, and turn every incident or revert into an eval case the reviewer is rescored against.

Copyable prompt

Prompt template
REVIEW.md for [REPO OR DIRECTORY]
What a real failure looks like here: [e.g. wrong totals in billing / config that misroutes traffic]
Always flag: [SECURITY OR DATA-LOSS PATTERNS], changes that make CLAUDE.md out of date.
Skip: [GENERATED PATHS, VENDORED CODE, LOCKFILES]
Nits: at most [N] per review, tagged as Nit.
Every finding must cite a file and line as evidence and be tagged Important, Nit or Pre-existing.
Start the summary with the number of findings and say plainly when there is nothing to fix.
After round 3, stop listing new nits and ask the author whether the approach should change.

Original template written by our AI agent for AgentRecipes, not copied from the source. Replace the [BRACKETS] and {{variables}} with your own values and test before relying on it.

What the builder reported

The Claude Code team reports that from June to September merged pull requests more than doubled while the share that had to be reverted fell by more than 40 percent; after capping review rounds, PRs passing after one review round rose from 65% to 78% and mean reviews to pass fell from 2.08 to 1.32.

These are the source author's own claims. AgentRecipes has not run this recipe itself.

Watch out for

Source

Original write-up: claude.dev (Anthropic engineering blog) (2026-10-15) ↗

Found via Agent Use Cases: “Review AI-written code with a layered agent review process”. This recipe summarises the source in words written by our AI agent; read the original for the full details. Link last checked 2026-10-17.

More engineering & security recipes

Rewrite a critical production service with Claude Code behind a black-box test harnessA high-throughput background service is becoming a bottleneck and paging on-call, but rewriting it by hand is slow and risky, and…Claude Code✓ Confirmed by sourceShip vendor recipe prompts so coding agents integrate your API the way you wouldDevelopers ask coding agents to add a vendor feature from public docs alone; the agent often picks the wrong product surface, burns…Claude Code✓ Confirmed by sourceLet scheduled Claude Code routines maintain an old SaaS with one PR per change and reviewed, batched deploysA founder no longer has time for a 17-year-old Rails side project, so small bugs, missing tests, stale support docs and SEO fixes pile…Claude Code✓ Confirmed by source

New agent recipes in your inbox

A short email with the newest automation recipes, each linked to its real-world source. No spam. Every email has a one-click unsubscribe link.