Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Usage Best Practices  ›  Lesson

Review Every Diff

Usage Best Practices 12 minBefore committing agent-written changes, scan the diff for scope, weakened tests and leftovers, then read the change itself until you can explain it.

Review Every Diff

An agent writes code faster than you can read it, and that is exactly why reading matters. A diff is the smallest complete record of what changed. Reviewing it is the moment you stop being a spectator and become the owner.

The rule

Read the diff as if a stranger wrote it, before you commit.

Claude can misunderstand the task, reach into files it did not need, leave debugging output behind, hard-code a value, or, under pressure to make a test pass, weaken the test instead of fixing the code. None of this is malice. All of it shows up in the diff.

Why "as if a stranger wrote it"? Because Claude's summary of its work comes from the same reasoning that produced the change. If it misunderstood the task, the summary will describe the misunderstanding with complete confidence. The diff cannot hide anything; it only shows what actually changed.

You see diffs in three places: in each edit's permission prompt, in the editor extension's diff view, and in git diff at the end. The last is the most complete, because it shows all uncommitted changes to tracked files in one place, including changes made by shell commands; git status adds any brand-new files.

Here is part of a diff from the weekly-discount fix:

 def price_for(order):
-    if order.plan == "Weekly":
+    if order.plan.lower() == "weekly":
         return order.days * DAILY_PRICE * 90 // 100
 def test_weekly_plan():
-    assert price_for(weekly_order) == 630
+    assert price_for(weekly_order) > 0

The first change is the fix. The second makes the test useless, because any positive price now passes. Reject it and ask for the exact assertion back.

The shortcut

Make three scans, in order: scope, tests, leftovers. Scope: git diff --stat — is every changed file one the task needed? Tests: were any tests changed, and were they made weaker? Leftovers: debug prints, commented-out code, stray TODOs, secrets. Then read the real change line by line. If a line puzzles you, ask Claude to explain it, and check the explanation against a concrete case.

Reviewing the weekly-discount fixStep 1 of 5
  1. Scope

    git diff --stat lists pricing.py, tests/test_pricing.py and app.py. Why app.py?

Drills

Answer fast — trust the rule.

quick drill

Claude changed assert price_for(weekly_order) == 630 to > 0, and now the tests pass. What do you do?

quick drill

What is the first scan in "scope, tests, leftovers"?

quick drill

Why is git diff at the end more complete than the edit prompts along the way?

quick drill

Claude added a regular expression you do not understand. What is the best move?

Remember

  • Read the diff as if a stranger wrote it, before you commit.
  • Shortcut: scope, tests, leftovers, then the change itself.
  • Trap: tests that went green because a test was weakened.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainReview the weekly-discount fix

Describe how you would review Claude's diff for the weekly-discount fix before committing. Name what you look for in each scan, and one finding that would make you reject the change.