Skip to content
mentoor

Topic 3 of 5 · 5 min read

Reviewing the diff after each step

Goal: Review one step's diff against its plan step and write specific feedback that corrects drift before the next step.

After every step, read the diff against the plan step it was meant to implement, and send specific corrections before the next step starts. Drift is small at step 2 and large at step 6.

Check yourself · 1 of 3

What is the first thing to check in a step's diff, before reading line by line?

Choose one answer

Why it matters

An agent can follow the plan and still wander. It may add a helper nobody asked for, rename things on the way, or catch an error and hide it. Each of these is minor once. Built upon by later steps, they become a design you never chose. Reviewing right after each step keeps the correction cheap, and the diff stays small enough to read well.

How to do it

  1. Put the plan step next to the diff. Ask: what did this step promise, and what changed?
  2. List the files first. Any file that the step did not need is a flag. Run git diff --stat before reading lines.
  3. Read tests first. Were tests added for the new behaviour? Were any existing tests changed or removed?
  4. Read the logic at the edges. Empty input, errors, and the call sites of anything renamed or changed.
  5. Check that it ran. The step's check passes on your machine.
  6. Write feedback the agent can act on. Name the file and line, say what is wrong, and say what to do. Ask for a fix inside the same step, and review the fix.

Before and after

Weak feedback: "This looks off, can you clean it up?"

The agent changes things at random, maybe more files than before.

Better feedback:

In src/totals.ts line 41 you catch the error from loadCoupon and return 0.
That hides a failed lookup as "no discount". Let it throw CouponLookupError
(src/errors.ts) and add a test for the failure path.
Do not change any other file.

The fix is one function and one test, and you can verify it in a minute.

What goes wrong

  • Reviewing at the end only. By then the early drift is built into everything.
  • Vague feedback. "Improve it" gives the agent license to change what you did not point at.
  • Reviewing the summary. The agent's description of its work is not the work.
  • Fixing it yourself silently. If you patch the code by hand, the agent's context no longer matches the files. Tell it what you changed.

Examples

Drift caught at step 2

Step 2 was "apply the coupon in calculateTotal". git diff --stat shows six files, including formatPrice.ts. The agent reformatted prices "while it was there". You ask it to revert that file. The next steps now build on a clean change.

Feedback with a limit

"Line 18: the new retry loop has no maximum, so a down server causes an endless loop. Cap it at 3 tries and add a test. Touch only client.ts and client.test.ts." The limit stops the fix from spreading.

Key points

  • Review right after each step, against the plan step it was meant to implement.
  • Start with the list of changed files; a file the step did not need is a flag for drift.
  • Read test changes before code, and look for tests that were weakened or removed.
  • Write feedback with a file, a line, the problem and the wanted fix, and limit the scope of the fix.
  • Tell the agent about any manual edits you make, so its picture of the files stays correct.

Common mistakes

  • Waiting to review until all steps are done.
  • Giving feedback such as "make it better" with no file or line.
  • Reading the agent's summary instead of the diff.
  • Editing files by hand without telling the agent.

Check yourself · 2 of 3

The agent caught an exception and returned 0, hiding a failed lookup. Which feedback is best?

Choose one answer

Check yourself · 3 of 3

An agent finished step 3 of 6. At what point is a review of that step's diff most useful?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic