AI Code Review Playbook
How to decide how much AI-written code to read, what proof to demand from agents, and how to ship safely when you can't read everything.
Source: video transcript by John, senior staff software engineer at Meta, “Should you still read AI-generated code?” Restructured as a reference; the prompts and template are written from his points. New to a term? See Key terms.
Bottom line
- Trunk code (shared state, infra, entry points, ungated production behavior): read it closely.
- Leaf code (isolated or fully behind a feature gate): skim it and trust the proof.
- Make agents prove their work with tests, logs, screenshots and a confidence level. More proof means less reading.
- Review with a fresh agent that never saw the build conversation. The builder agent grades its own work too kindly.
- Lean on safety over reading: feature gates, canaries and rollback let you undo bad decisions you didn't catch.
Key terms
Every technical term used on this page and in the video, in plain words.
| Term | Simple meaning |
|---|---|
| Risk and code structure | |
| Blast radius | How much of the app could break if this change has a bug. |
| Trunk code | Core code that many parts of the app depend on. |
| Leaf code / leaf node | Separate code at the edge that almost nothing else depends on. |
| Entry point | The main file where the app starts, for example App.js. |
| Infrastructure (infra) code | Shared basic code like networking or image loading that the whole app uses. |
| Downstream dependencies | Other code that uses your code and could break if it changes. |
| Shared state / reducer | Data many screens read and change; a reducer is the code that updates it. |
| Side effects | Unexpected changes a piece of code causes in other places. |
| Isolated | Code that doesn't touch or change any existing code. |
| Production (prod) | The live app that real users are using. |
| Control experience | How the app works today, which must not change by accident. |
| One-way door | A decision that is hard or impossible to undo. |
| Feature gating and release | |
| Feature gating | Putting new code behind a check so it only runs when you turn it on. |
| Feature flag / feature toggle / gate | The on/off switch used for feature gating. |
| Ungated | Code with no on/off switch: it runs for everyone as soon as it ships. |
| LaunchDarkly | A paid tool for managing feature flags. |
| Integration layer / integration points | The places where new code connects to existing code. |
| Rollback | Undoing a change, often just by turning its flag off. |
| Broad strokes | The fast first version of a feature: built, gated off, merged. |
| Merge-ready vs launch-ready | Good enough to add to the code vs good enough to show to real users. |
| Audit | A full check of the whole feature before release: bugs, speed, security. |
| A/B test (experiment) | Showing the old version to some users and the new one to others, then comparing. |
| Statistical power | Having enough users that an A/B test result can be trusted. |
| Canary deployment | Releasing to a small group of users first to catch problems early. |
| Alerts | Automatic warnings when something breaks or errors go up. |
| AI agents | |
| Vibe coding | Letting AI write code and shipping it without really reading it. |
| AI slop | Low-quality code that AI writes and nobody checks. |
| Agent | An AI that does tasks on its own: writes code, runs tests, fixes errors. |
| Sub-agent | A second AI started by the main AI to do one task with a clean memory. |
| Builder agent | The AI that wrote the code. |
| Adversarial review agent | A separate AI whose job is to look hard for problems in the code. |
| Context / anchoring | What the AI remembers from the chat; anchoring means it sticks to that and goes easy on its own work. |
| Skill | A saved set of instructions that tells the AI how to do a task your way. |
| Agentic validation | The AI checks its own work by running tests and the app, then fixes problems. |
| Atomic change | A small change that does one thing only. |
| Spec | A written plan of what the feature should do. |
| Evaluations / validation criteria | Rules you decide early to check if the feature works. |
| Babysit a PR | Having an AI check a PR every hour and fix review comments for you. |
| Goals | A Codex feature that keeps working toward a task over time, like babysitting a PR. |
| Agentic safeguard / “agentic garden” | A safety system of tests, checks and AI reviewers around your code. |
Claude Code /code-review | The built-in command in Claude Code that reviews your code changes. |
| Codex reviewer | OpenAI's AI that can review PRs automatically on GitHub. |
| Review and testing | |
| Code review | Reading a code change before it goes live to find problems. |
| PR (pull request) / diff | A proposed code change, sent to others to review before it is merged. |
| Merge / land | Adding the approved change into the main code. |
| Skim | Read quickly, looking only for obvious problems. |
| Review depth | How carefully you read a change: from a skim to every line. |
| PR template | A fixed format so every PR description has the same sections. |
| Test plan | The part of a PR explaining how the change was tested. |
| Proof / evidence | Anything that shows the change works: tests, logs, screenshots. |
| Unit test | A small automatic test that checks one function works correctly. |
| Integration test | A test that checks several parts work together correctly. |
| Component test | A test that checks one piece of the UI, like a button, works. |
| Snapshot test | A test that saves how a UI piece looks and warns you if it changes. |
| Assert | The line in a test that checks the result is what you expect. |
| Runtime evidence / logs | Messages the app prints while it runs, showing what happened. |
| Visual evidence | A screenshot or video showing the feature working. |
| Confidence level | The AI saying how sure it is that each part of its code is right. |
| Static checking | Tools that find problems by reading the code without running it. |
| Linting | A tool that flags style issues and simple mistakes. |
| Type checking | A tool that checks you're using the right kind of data, like a number vs text. |
| Nits | Very small review comments about style or personal taste. |
| Refactor | Rewriting code to make it cleaner without changing what it does. |
AI across the whole lifecycle
Review is one stage of four. How much review a change needs is decided mostly by what you did in planning and what you'll do at launch.
Plan
- Agent drafts the spec
- Define validation criteria and evals up front
- Plan the feature gates
- Separate leaf work from integration work
Build
- Agents make small, atomic changes
- Agentic validation: the agent runs tests, reads logs, fixes itself
Review
- Depth set by blast radius
- Proof attached to the PR
- Independent reviewer agent
- Lint and type checks handle nits
Launch
- Launch-readiness audit
- Gate, canary, A/B test
- Watch crashes and alerts
- Roll back if needed
Think of the codebase as a tree
Different parts of the tree carry different risk. Before reviewing, place the change on the tree.
TRUNK Read deeply
- Main entry points (e.g.
App.jsand the helpers wired into it) - Infrastructure: networking, image processing and rendering pipelines
- Shared state, e.g. a reducer action that many screens depend on
- Any change to existing production behavior that isn't gated
- Anything with many downstream dependencies
LEAF Skim and check the proof
- One-off UI components, checked with component or snapshot tests
- New logic, a new endpoint or an integration, checked with unit or integration tests
- Anything fully behind a feature gate and not wired into production paths
- Skim for anything obviously wrong, then move on
Pick the review depth
These are the questions John asks himself before every review. Tick what applies to the change in front of you.
The three safety questions
| Question | What it tells you |
|---|---|
| What is the control experience that must not change? | The baseline behavior your review protects. If the change can alter it, read more. |
| If this goes wrong, how bad is it? | The size of the blast radius. |
| Can I roll it back? | The most important one. If a gate flip undoes it, you can review much less. |
Build behind feature gates from day one
Gating is what lets you read less code safely. It belongs in the plan, not added at the end.
| Practice | How |
|---|---|
| Start simple | A Boolean flag in config is enough to begin with. Move to a flag service (e.g. LaunchDarkly) when you need targeting and gradual rollout. |
| Gate in broad strokes | When planning the feature, gate every new path, not just the risky one. |
| Isolate the leaves | Build new parts so they don't touch existing code. These get light review. |
| Gate the integration layer | Where new code plugs into the trunk is the dangerous spot. Plan it and gate it separately. |
# Simplest possible gate: control path stays untouched
FEATURES = {"save_card": False} # flip per env / per user later
def on_card_swipe(card, user):
if FEATURES["save_card"]:
return save_card_flow(card, user) # new leaf code
return legacy_swipe(card, user) # control experienceRequire proof in every PR
Push agents to show evidence that the change works. With proof up front, you read less code and believe the output more.
| Proof type | What it looks like | How you review it |
|---|---|---|
| Unit tests | Focused tests for the logic changed | Read test names and asserts. Watch for useless tests that assert nothing real. |
| Component / snapshot tests | Render tests for UI leaves | Check the snapshot diff matches the intent. |
| Runtime evidence | Logs from an actual run of the feature | Scan for the expected events and no errors. |
| Visual evidence | Screenshot or short video of the UI working (e.g. the new Save button saving a card) | Look at it. Fastest trust signal for UI work. |
| Confidence level | Agent rates its confidence per area: logic, gating, integration | Read the low-confidence areas closely. |
Use agents as reviewers, the right way
AI is already a strong reviewer, probably better than most humans. Most people get poor results because of how they run it.
| Do this | Why |
|---|---|
| Use a fresh, independent reviewer | The agent that wrote the code anchors on its own conversation and goes easy on itself. Use a new sub-agent, or a different agent entirely, with no build context: an adversarial reviewer. |
| Start from a good review skill | Built-ins are solid: /code-review in Claude Code, the review agent in Codex. |
| Add a reviewer on GitHub | Codex can be added as a GitHub reviewer that runs on every new PR or when tagged. It uses a model tuned for review. It costs money. |
| Let static checks own the nits | Linting, type checking and formatters, plus the review agent, handle style. Personal style debates no longer belong in code review: code changes fast and refactors are cheap once validation exists. |
| Use a PR template | Without one the agent writes a long story. A template makes every PR look the same and keeps the important parts. |
| Automate the comment loop | Set up a recurring task that checks the PR every hour, fixes reviewer comments, reruns validations, updates notes and re-pushes. |
Copy-paste prompts and template
PR template
## What
One or two sentences. What changed and why.
## Where on the tree
- [ ] Leaf (isolated / fully gated)
- [ ] Trunk (entry point, infra, shared state, ungated prod behavior)
Files touching trunk: <list or "none">
## Gating & rollback
Flag: <name> Default: OFF
Control experience unchanged when OFF: yes / no (explain)
Rollback: flip flag / revert commit / needs migration (explain)
## Proof
- Tests: <names of key tests, what they assert>
- Runtime: <log excerpt or "n/a">
- Visual: <screenshot / video link or "n/a">
## Confidence (high / medium / low)
- Logic:
- Gating:
- Integration:
Low-confidence areas a human should read: <list>
## Validation run
lint ✔ typecheck ✔ unit ✔ integration ✔Adversarial reviewer (run in a fresh session or sub-agent)
You are an independent code reviewer. You did not write this code and have
no context from the conversation that produced it. Assume it has bugs.
Review the diff in <PR / branch>. Report only real problems, most severe first.
1. Classify each changed file as TRUNK (entry points, infra, shared state,
ungated production behavior) or LEAF (isolated or fully feature-gated).
2. For TRUNK files: check side effects on existing behavior, downstream
callers, concurrency, error handling and security.
3. Check the feature gate: with the flag OFF, is the control experience
exactly unchanged? Can the change be rolled back by flipping it?
4. Check the proof: do the tests assert real behavior, or are they filler?
Is anything claimed in the PR description not backed by evidence?
5. Ignore style nits that lint or the type checker would catch.
For each finding give: file:line, what breaks, a concrete failing scenario,
and a suggested fix. End with: SAFE TO MERGE / NEEDS CHANGES / NEEDS HUMAN
REVIEW (name the files a human must read).PR babysitter (recurring task)
Babysit PR <link>. Every hour until it is approved or I tell you to stop:
1. Read new review comments, including from the Codex/AI reviewer.
2. Fix each valid request. If you disagree, reply with your reasoning
instead of changing code.
3. Rerun local validation: lint, typecheck, unit and integration tests,
plus the agentic checks (run the feature, capture logs/screenshots).
4. Update the PR description so the Proof and Confidence sections match.
5. Push and re-request review. Stop and ping me if a fix touches trunk
code or the feature gate.Launch-readiness audit
Audit the full feature <name> (all merged PRs behind flag <flag>) before launch.
Look at it as a whole, not diff by diff. Report on:
- Does it work to spec? List any spec item that's missing or partial.
- Bugs and edge cases across the combined changes.
- Performance: hot paths, extra renders, N+1 calls, payload size.
- Security: input validation, auth checks, secrets, injection.
- Cleanup: dead code, duplicated helpers, leftovers from fast iteration.
Rank findings by launch risk.Merge-ready is not launch-ready
Working this way, everything gated and landed gets you about 80% of the way. The last 20% takes about as long as the first 80%, and it's where human taste matters most.
| Phase | What happens | Who leads |
|---|---|---|
| Broad strokes | Agents build fast, everything gated and landed, light review on leaves | agents |
| Launch-ready | Whole-feature audit by agents (spec, bugs, performance, security), refactoring and cleanup, details such as animations | you |
| Canary / A/B | Route a slice of traffic through the gate. Even without enough users for a statistically valid test, you see crashes and alerts early. | you + monitoring |
| Rollback ready | Bad result? Flip the gate. This is the safety net that justifies reading less. | the gate |
Anti-patterns
| Anti-pattern | Do this instead |
|---|---|
| Shipping AI code with no review at all | Place it on the tree and review trunk changes closely |
| Reading every line of every PR | Skim gated leaves and lean on proof |
| Builder agent reviews its own work | Fresh-context adversarial reviewer |
| Review threads full of style nits | Lint, type checks, formatter |
| Agent-written filler tests | A skill that defines what a useful test asserts |
| Essay-length PR descriptions | A short, fixed template |
| Ungated change to existing behavior | Gate the integration layer, keep the control path intact |
| Treating “merged” as “done” | Launch audit, canary, then full rollout |
Interview answer: “Do you still read AI-generated code?”
Short version (~30 s): “Yes, but the depth depends on blast radius. I treat the codebase like a tree. Trunk changes such as shared state, infra or ungated production behavior, I read line by line. Leaf changes that are isolated or behind a feature gate, I skim, as long as the PR carries proof: tests, runtime logs, a screenshot, and the agent's confidence per area.”
If they push: “Reviews run with a separate agent that has no context from the build session, because the builder anchors on its own reasoning. Lint and type checks handle style. And the real safety net is at launch: everything ships behind a gate, goes out as a canary, and rolls back with a flag flip. That's what lets me read less without taking on more risk.”
Summary in plain words
When AI writes your code, you don’t have to read every line, but you can’t skip reading either. How much you read depends on how much could break. Think of your code as a tree. The trunk is the important code that the whole app depends on, so a bug there can break everything, and you read it carefully. The leaves are small, separate pieces, so a bug there only breaks one small thing, and a quick look is enough. Before you trust the AI’s code, ask it for proof that it works: tests, logs, or a screenshot. Then have a different AI check the code, because the AI that wrote it is too easy on its own work.
The other big idea is to make every change easy to undo. Put new features behind an on/off switch (a “feature gate”). When you release, turn the feature on for a few users first. If something breaks, flip the switch off and the problem is gone. Merging the code is only about 80% of the job. The last 20% is your own final check and polish before real users see it. So the simple rule is: read more where mistakes are expensive, read less where they’re cheap, and always keep a way to undo.