Key takeaways
- ✓A plan can only show some bugs. A decision is something a plan would state (what's stored, which cases are handled, a limit, a retry); a slip is a detail of how the code is written (< instead of <=, a forgotten line). Of 173 planted bugs, 81 are decisions, by a model's labels checked by another AI pass, not by a person.
- ✓Here the plans were mostly right. An AI agent that read the task and the code, without seeing any version of the PR, stated 69 of the 81 decisions correctly. The bug showed up in the code, which a plan review can't see.
- ✓Review a plan next to its task. Reading the wrong plan alone, the standard AI reviewer caught 60%; with the task, 77%. A cap of 50 runs looks fine on its own and wrong next to a request that never asked for a cap.
- ✓A plan reviewer sends good plans back. Even with the task, standard flagged 49 of 77 right plans (64%), with real questions: a duplicate check that could race, a missing test case. A plan is one page with gaps.
- ✓For an AI reviewer on these PRs, the diff caught as many: 84% in the diff against 77% in the plan, a likely range of 16 points worse to 1 point better. And a plan review cost about the same, 0.48¢ against 0.50¢, because the cost is in the thinking, not the reading.
- ✓An approved plan is a spec only for code built from it. Given the plan with the diff, the reviewer found the same 80% of bugs, and flagged 52 of 77 clean PRs instead of 37, mostly for not matching a plan they were never written from.
- ✓Every reviewer here is an AI, on PRs with a median of about 74 changed lines. Whether people catch more in a plan than in a 1,000-line diff is still open.
There's a popular rule for AI coding: review the plan, not the diff. A design bug hidden in a thousand-line diff should be obvious in a fifteen-line plan, so check the agent's plan before it writes any code. This chapter tests that rule on the planted bugs from Chapter 1. Which bugs can a plan even show? Did the agent's plans have them? And, on the same bugs, does the AI reviewer catch more in the plan or in the finished pull request's diff?
The source is Lab 07 of the code-review labs, "Review the Plan, Not the Diff", recorded in October 2026: scripts 01_plans.py (the plans, and which bugs are decisions), 02_plan_review.py (reviewing right and wrong plans), 03_plan_vs_code.py (the same bugs at both stages) and 04_plan_as_spec.py (code review with the approved plan). The video re-runs only 03_plan_vs_code.py, which reads recorded results and calls no model. Everything here is AI: the plans (gpt-5.4-mini), the wrong plans, the labels of which bugs are decisions, and every review, by the AI stand-in reviewer from Chapter 3. No person reviewed a plan or a PR. The PRs are the testbed from Chapter 1: Harbor, a made-up data-sync app, with 173 PRs that carry one planted bug each and 77 clean twins.
How the PRs are named. Each pull request has an id like c03-d1. The first part is the change: c03 is one feature, returning a sync's run history newest first. (c changes come from the app's own history, n changes were written for the test set.) The second part is the version: c03-clean is the correct PR, and c03-d1 is a copy of it with one planted bug. Other changes have several such copies: -d1, -d2, -d3.
A plan, before the code
For each of the 77 changes, an AI agent played the author before writing anything. It got the task (the change's title and description), read-only tools on the code as it was before the change, and no view of any version of the PR. It read the code it would change and wrote a plan: a goal, 3 to 8 approach steps, the files it would touch, risks, and tests. 77 plans cost $0.95, about 1.2¢ each, with a median of 13 tool calls.
The plan for c03, "Return run history newest first", starts like this:
- Update the run-history repository query in
api/src/repo/runs.tsto sort bystarted_at DESC, rowid DESCand keep the limit in that same query, so the database returns the newest runs first before mapping them to GraphQL objects.
Decisions and slips
A plan can only catch some bugs.
- A decision is something a plan would state: what gets stored or sent and when, which cases are handled, where filtering happens, how many queries run, what a limit or a default is, whether a failure is retried.
- A slip is a detail of how the code is written: a
<that should be<=, a sort's tie-break, which parse function, a forgotten line. No plan says that.
So which of the 173 bugs are decisions? A model, asked first, said 129. Almost anything can be put into words, so "could a plan say this?" is nearly always yes. The real question is whether an author would think to write it in a plan. A stricter check, then a pass over every pick by the AI that built the lab, kept 81 (47%). No person checked those labels, so treat 81 as a careful estimate. Every number below is on those 81.
| Type of bug | Bugs | Decisions | …the agent's own plan had right |
|---|---|---|---|
| performance | 21 | 16 | 10 |
| contract | 18 | 10 | 8 |
| reliability | 23 | 12 | 12 |
| ai-shaped | 21 | 10 | 8 |
| logic | 31 | 14 | 14 |
| security | 16 | 7 | 5 |
| ui | 17 | 6 | 6 |
| tests | 11 | 3 | 3 |
| convention | 15 | 3 | 3 |
| all | 173 | 81 | 69 |
Most performance bugs are decisions: a query per row, or a whole table read and sliced in memory. Most convention and tests bugs aren't: a plain Error instead of Harbor's own error class, a loosened assertion. Logic splits in half: a cap of 50 nobody asked for is a decision; a wrong tie-break is a slip.
The agent's own plans were mostly right
Now the last column. Of the 81 decisions, the agent's own plan, written from the task without seeing the PR, stated 69 correctly, as judged by the model that planted the bugs. So in this test set the plan usually had it right. The bug only shows up in the code, and a plan review can't see code.
To test plan review anyway, a model wrote a wrong plan for each of the 81 decisions: the plan an author who chose the buggy design would have written, believing it was right. It's the plan-level twin of a planted bug. In c03-d1, the planted bug quietly caps every request at 50 runs, so asking for 60 returns 50. Its wrong plan changes one step:
- … and keep the limit in that same query, capping the requested limit at 50 so the database returns the newest runs first …
The right plan and the wrong plan differ by a phrase or a step, the way a clean PR and its buggy copy differ by a line or two. Read a few and decide whether you'd send them back:
Each wrong plan is the agent's plan with a step or two rewritten the way an author who chose the buggy design would write it. Read the task first, then the steps. Would you send the plan back?
The task (the PR description)
The run history page shows the oldest runs, so once a sync has more than 20 runs, the latest ones never appear. syncRuns should return runs newest first, as the schema says, and limit should keep the newest ones.
Step 1
The agent's plan
Update the run-history repository query in api/src/repo/runs.ts to sort by started_at DESC, rowid DESC and keep the limit in that same query, so the database returns the newest runs first before mapping them to GraphQL objects.
The wrong plan
Update the run-history repository query in api/src/repo/runs.ts to sort by started_at DESC, rowid DESC and keep the limit in that same query, capping the requested limit at 50 so the database returns the newest runs first before mapping them to GraphQL objects.
Shaded: the words that differ. The wrong plan's risks and tests lists can differ too (not shown). Every reviewer is an AI stand-in from Chapter 3; a judge model decides whether a comment names the planted bug.
Review the plan
The reviewer is Chapter 3's stand-in at two of its budgets (which model, and how hard it thinks): quick (gpt-5.4-nano) and standard (gpt-5.4-mini, low effort). A judge model checks each comment on a wrong plan: does it object to the planted decision? A wrong plan is caught if any comment does. A right plan, the agent's own, has no planted bug, so any comment marked as a bug sends it back.
The code reviewer in Chapter 3 always had the PR's description. So the plan reviewer ran twice: on the plan alone, and on the task and the plan together.
| Plan reviewer reads | Wrong plans caught (of 81) | Right plans sent back (of 77) | Cost per plan |
|---|---|---|---|
| plan alone, quick | 46 (57%) | 71 (92%) | 0.09¢ |
| plan alone, standard | 49 (60%, 50–71%) | 56 (73%) | 0.50¢ |
| task + plan, quick | 56 (69%) | 63 (82%) | 0.09¢ |
| task + plan, standard | 62 (77%, 67–85%) | 49 (64%, 52–73%) | 0.48¢ |
The ranges are 95% intervals from a bootstrap over changes: resampling the changes many times to see how much the number moves.
The task is what makes a plan reviewable. Look at the cap of 50. On its own, the plan looks fine. Next to a task that asks for newest-first runs and never mentions a cap, it's obviously wrong. Standard missed it on the plan alone and caught it with the task. Recall on logic decisions rose the most, from 21% to 79% (14 bugs).
Most right plans get sent back. Even the best row returns 49 of 77 good plans. The comments aren't nonsense. On the right plan for api-release, a release that bundles API query fixes, validation and a faster sync list:
Rejecting duplicate destination names with an API-layer precheck (or any preflight SELECT alone) is race-prone: two concurrent creates can both pass the check and insert duplicates.
And on the right plan for c01, a fix for syncs(enabled: false) returning every sync: "The task explicitly requires that omitting enabled or passing null still returns all syncs, but the proposed test matrix only covers no argument, true, and false." A plan is one page with gaps, and a reviewer told to find problems asks about them. Whether that helps depends on what sending a plan back costs: a short exchange is cheap; an author blocked for a day isn't.
It's also noisy. Quick's two runs on the plan alone disagreed on 21 of the 81 wrong plans.
Plan or diff?
Now the main question. The same 81 bugs were reviewed twice: once as a wrong plan, once in the finished PR's diff (Chapter 3's recorded code reviews). Because it's the same bugs, the comparison is paired:
| Budget | Plan reviewer reads | In the diff | In the plan | Plan − diff, points (likely range) |
|---|---|---|---|---|
| quick | plan alone | 65% | 57% | −9 (−22 to +4) |
| quick | task + plan | 65% | 69% | +4 (−9 to +15) |
| standard | plan alone | 84% | 60% | −23 (−35 to −12) |
| standard | task + plan | 84% | 77% | −7 (−16 to +1) |
In this run, the diff caught more: 84% in the code against 77% in the plan. But the likely range runs from 16 points worse to 1 point better. So the plan is no better, and the gap could be close to zero; that's within the noise. Quick did a little better on the plan with the task, by 4 points, also within the noise. With the plan alone, standard caught 23 points fewer than in the diff, and that range excludes zero: a plan is only reviewable next to what it's for. For reference, careful, the expensive budget, caught 91% in the diff.
Standard, with the task: 58 bugs caught at both stages, 4 only in the plan, 10 only in the diff, 9 at neither. Explore them:
Each square is one planted bug that is a decision. The same bug was reviewed twice: once as a wrong plan, once in the finished PR's diff. Pick the reviewer's budget and what the plan reviewer reads. Click a square.
Likely range of plan − diff: −16 to +1 points. It includes zero: no clear difference. Cost per review: 0.48¢ a plan, 0.50¢ a PR.
The bug: listRuns quietly caps every request at 50 runs, a limit nobody asked for, so syncRuns(limit: 60) returns 50.
In the plan (the task + the plan): caughtIn the diff: caughtCareful, in the diff: caught
The agent's own plan had this decision right.
Quick and standard are the AI stand-in's budgets from Chapter 3 (gpt-5.4-nano, and gpt-5.4-mini at low effort); one run each. The likely range is the lab's bootstrap over changes, which is why it isn't exactly the difference of the two percentages.
A plan review isn't cheaper for a model. A plan is about 900 input tokens against a mean of 3,345 for a PR. But input is cheap; the cost is in the output, and output is mostly thinking. Standard wrote about 900 output tokens on a plan and 626 on a PR. A plan review cost 0.48¢, a code review 0.50¢. The saving from short plans is a person's saving, not a model's.
The plan as the spec
One more idea: approve the plan, then give it to the code reviewer as the spec, the description of what the code should do. The reviewer gets the approved (right) plan above the diff, with a note that the plan was reviewed and approved and the PR should carry it out. Surely that helps?
The code reviewer reads the PR's diff and description. Now put the approved (right) plan above the diff, with a note: this plan was reviewed and approved, and the PR should carry it out.
Planted bugs found
Switch the plan on. Will the reviewer find more of the bugs that contradict the plan?
Changes in points with the plan (bootstrap over changes): decisions the agent's plan got right −3 (−10 to +4); decisions the agent's plan missed 0 (−33 to +33); slips and the rest +3 (−4 to +11); all planted bugs +1 (−5 to +6).
It found the same share of bugs: 80% with or without the plan. Even the bugs that contradict the plan weren't found more often (90% without, 87% with): the PR description already told the reviewer the right behaviour.
But clean PRs flagged as buggy rose from 37 to 52 of 77 (48% → 68%). 22 were newly flagged, 7 no longer were, and 15 of the 22 new flags cite the plan. Most are drift: "this pull request doesn't do what the approved plan said." On c04-clean, the correct PR for "Reject zero and negative schedules": "this PR no longer implements the worker-side safeguard from the approved plan." These PRs weren't written from these plans; the PRs came first. So most differ from their plan somewhere, and the reviewer flags each difference. A plan works as a spec only for code built from it.
Also in the lab
From the lab's README and checklist answers (its own run, October 2026), beyond the video:
- A plan is about a page at every size. Median plan lines against median PR changed lines: 23 vs 25 for extra-small PRs, 27 vs 58 small, 31.5 vs 107.5 medium, 36 vs 209.5 large. The reading a plan saves grows with the PR.
- Plans predict files loosely. A plan names a median 50% of the files its PR changes, and the PR changes 46% of the files the plan names. Of the 205 changed files no plan named, 132 are test files.
- Pipelines. A plan review lifts the decisions and leaves the rest alone. Plan (standard) + code (quick) found 76% of all 173 bugs, below standard's code review alone (80%), at 0.62¢ against 0.50¢ a PR, with 49 good plans sent back. Plan (standard) + code (standard): 82% at 1.00¢. Careful on the code alone: 88% at 3.36¢, the best of the model pipelines. For a person, a plan adds about 30 lines of reading per PR (97 → 127).
- What went wrong while building it. The first classifier called nearly everything a slip, because the plan already said the right thing; that became the "69 of 81" finding. The second called nearly everything a decision. The first plan review gave the reviewer the plan alone, which made the plan look 23 points worse; with the task it's 7. Cost: $7.56 in model calls.
- An optional sitting (
review_session.py): a person reviews 13 plans in about 30–40 minutes. No person has done it yet, so the results are the stand-in's only.
What to do
- Find out where your design bugs come from. If your agent's plans are mostly right and the bugs appear in the code, a plan review won't catch them.
- Review a plan next to its task, the ticket it's for. A plan on its own can only be checked for internal consistency.
- Expect good plans to come back with questions. Decide which questions are worth a round trip, or tell the reviewer to send a plan back only when a decision contradicts the task.
- Keep the code review. Plan review does nothing for slips, which are about half the bugs.
- Use the plan as a spec only for code written from it. Otherwise every honest difference reads as drift.
- Measure the advice on your own PRs before adopting it: same bugs, both stages, paired.
Caveats
- Every reviewer is an AI. The rule is about human attention: a design bug hidden in a thousand-line diff. A model reads 100 lines as easily as 15. Whether people catch more in a plan needs people to measure.
- The PRs are small: a median of 73.5 changed lines over all 250 (the README's "58" is the median of its small-PR bucket). The rule may still hold for people on big changes.
- The decision labels are by AI. The first model pass, a stricter check and the final labels by the AI that built the lab; "the agent's plan had it right" is the planting model's judgement. No person checked them.
- The wrong plans are planted. A model wrote each one to contain the bug. Real wrong plans may be harder or easier to spot.
- The PRs weren't written from the plans. So "drift" here measures two independent designs, not code drifting from the plan it followed.
- One run per reviewer, and quick's two runs disagreed on 21 of 81 wrong plans.
The checklist
- Sort a sample of your past bugs into decisions and slips, with a written rule, and have a person check the labels.
- For the decisions, check your agent's plans: did the plan have it right, and the code drift, or was the plan wrong?
- Give the plan reviewer the task, not the plan alone.
- Count both sides: wrong plans caught, and right plans sent back.
- Pair the stages on the same bugs: caught in the plan, in the diff, both, neither, with a likely range.
- Compare costs per review, including output tokens for a model and minutes for a person.
- Before giving a reviewer the approved plan, make sure the code was built from it, and watch clean-PR false alarms.
Practice: the scoring in code
Write the four pieces the comparison rests on: score one plan review, pair the plan stage with the diff stage on the same bugs, turn the counts into a difference in points, and count how the approved plan moved the false alarms. The tests use the lab's recorded results: 58, 4, 10 and 9 for standard with the task, −7 and −23 points, and 37 → 52 clean PRs flagged.
Quiz
1.Which of these planted bugs is a decision, something a plan would state?
2.The first model pass called 129 of the 173 bugs decisions. Why did that need checking?
3.The standard AI reviewer caught 60% of the wrong plans reading the plan alone, and 77% with the task as well. Why does the task matter so much?
4.On the same 81 bugs, standard caught 84% in the diff and 77% in the plan with the task. The likely range of plan minus diff is −16 to +1 points. What can you say?
5.A plan is about a quarter as long as a PR. Why did a plan review cost the AI reviewer about the same (0.48¢ against 0.50¢)?
6.The code reviewer got the approved plan above the diff. It found the same 80% of bugs and flagged 52 clean PRs instead of 37. Why?
Check your understanding
Try each question before opening its answer.
What makes a bug a decision rather than a slip, and why did the first model's answer need checking?
A decision is something an author would write in a plan on purpose: what's stored, which cases are handled, a limit, a retry. A slip is a detail of writing the code, like an operator or a forgotten line. Any bug can be described in words, so a model asked loosely said 129 of 173. A stricter check and another AI pass kept 81, which no person has checked.
The agent's own plan had 69 of 81 decisions right. What does that say about plan review here?
That in this test set, design bugs were mostly code that went wrong under a sound plan, not a wrong plan. A plan review can only catch the second kind. The first needs a code review.
Why did the plan reviewer need the task, and what changed when it got it?
Many wrong decisions only look wrong next to the request, like a cap of 50 runs that nobody asked for. With the task, standard's recall on wrong plans rose from 60% to 77%, and on logic decisions from 21% to 79%. The code reviewer always had the PR description, so only task + plan is a fair comparison.
The reviewer sent back 64% of right plans. Are those comments useless?
Not necessarily. Many are real open questions: a duplicate check that could race without a unique index, a test list that skips the null case. A plan is a page with gaps. Whether sending it back helps depends on what the round trip costs the author.
Standard caught 84% in the diff and 77% in the plan. Does that refute "review the plan, not the diff"?
No. The gap's likely range is −16 to +1 points, so the plan is no better here, but the difference could be close to zero. And the rule is about people on big diffs; these reviewers are AI models on PRs of about 74 changed lines. It shows that for a model on small PRs, a plan review is no shortcut.
Why did a plan review cost a model about as much as a code review?
For these models the cost is mostly output, and output is mostly thinking. A plan is about 900 input tokens against 3,345 for a PR, but standard wrote about 900 output tokens on a plan and 626 on a PR: 0.48¢ against 0.50¢.
Giving the code reviewer the approved plan found no more bugs and flagged more clean PRs. Why?
The PRs weren't written from those plans, so most clean PRs differ from their plan somewhere, and the reviewer flags each difference as drift: 52 of 77 clean PRs instead of 37. It found no more bugs because the PR description already told it the right behaviour. A plan is a spec only for code built from it.
Next up: Chapter 9: not every pull request needs a human. Route each PR by risk.