All courses

Reviewing the diff the agent made

Read the full diff of a change with `git diff` or an editor view. Check that every changed file belongs to the task, that nothing unrelated was deleted, and that the logic matches what was asked.

Builds on: git status and reading a diff, Reading the agent's summary skeptically

Read it card by card Start the whole course

The summary says done. Is it?

You asked the agent: "Round invoice totals to 2 decimal places." It replies with a one-line summary: ◂ Agent: Fixed rounding in `calc_total`. You already know to treat that as a claim, not a fact. But how do you actually check it? The change is now sitting in your files, and you are about to keep it.

The summary is a story, the diff is the record

`git status` and the diff are the record. Together they show every file and line the agent touched, whether or not the summary mentions it. Agents often do more than you asked. They tidy a nearby file, delete code they guess is unused, or change a value while "fixing" something else. Reading the diff answers three questions: - Are these the right files? - Was anything lost? - Does the new logic do what you asked?

Checklist before you keep a change

1. `git status`: list every changed file. Each one must belong to the task. New files show as *untracked* and do **not** appear in `git diff`, so open them directly. 2. `git diff --stat`: lines changed per file. A big number on a small task is a warning. 3. `git diff` or your editor's diff view: is each `-` line meant to go? Does each `+` line do what you asked? If `git status` shows changes as *staged*, plain `git diff` hides them. Add `HEAD` (your last commit) to compare against it: `git diff HEAD` and `git diff HEAD --stat`.

The invoice change, checked

`git status` lists `billing.py` and `utils.py`, but the summary only mentioned `calc_total`. The diff on the next card shows two problems: - In `utils.py`, a whole function, `format_date`, was deleted. Nothing in your request touched dates. - In `billing.py`, `round(total)` rounds to a whole number, so 19.99 becomes 20. You type: ▸ You: Restore `format_date` in utils.py. Only change `calc_total`, rounding to 2 decimals. Then you read the new diff again.

What `git diff` showed

Two files changed. One deletion is unrelated to the task. The rounding is wrong too: `round(total)` drops the cents, but you asked for 2 decimals, which would be `round(total, 2)`.
--- a/billing.py
+++ b/billing.py
@@ -12,2 +12,2 @@ def calc_total(items):
     total = sum(i.price for i in items)
-    return total
+    return round(total)
--- a/utils.py
+++ b/utils.py
@@ -40,3 +39,0 @@
-def format_date(d):
-    return d.strftime("%Y-%m-%d")
-

Keep the diff, not the summary

What ends up in your project is the diff, not the summary. Check three things: - Every file belongs to the task, including new files that only `git status` shows. - Every `-` line was meant to go. - Every `+` line does exactly what you asked. After each fix, read the diff again.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.