Sub topic 2
You own the diff: what to trust and what to check
This chapter assumes you know basic Git (branches, commits, staging, diffs), can read code in at least one language, can run your project's tests, linter, and build from the command line, and have used a coding agent to edit code at least once.
Why the diff is yours
A coding agent proposes changes. You decide what enters the codebase. Once you commit, merge, or deploy the agent's work, you are the author of record. Reviewers, teammates, and production users will not know or care which lines you typed.
This shapes how you read the output. An agent is fast and often right, but it has no stake in your system. It does not feel the pager. It does not remember the incident last quarter that made a certain check mandatory. It can write code that looks plausible and is wrong. Your job in review is to supply the judgment the agent lacks.
The working rule is: treat the diff as the only trustworthy description of what happened. The agent's summary is a claim about the diff. The diff is the thing itself.
What the agent's output contains
After a run you usually have three separate artifacts. They differ in how far you can trust them.
| Artifact | What it is | Trust level |
|---|---|---|
| The diff and file changes | The actual edits in your working tree | Ground truth about what changed, not about whether it is correct |
| The agent's summary | A natural-language account of what it did | A claim. It can omit edits, overstate results, or describe intent instead of outcome |
| Reported test results | The agent saying "all tests pass" | A claim until you rerun the command yourself |
The diff tells you what changed. It does not tell you the change is right. The summary tells you what the agent believes it did. It may be mistaken or incomplete, and it can be confidently worded either way.
Trust boundaries
A useful habit is to sort what you see into three groups before you read any code.
What you can usually rely on
- Mechanical edits that follow a clear pattern, such as renaming a symbol across many files. Even these need a check that the pattern was applied everywhere and only where it should be.
- Syntax. Agents rarely produce files that fail to parse, though it happens.
- Local consistency. Within a single function, names and types usually agree.
What you must verify
- Anything the agent says it ran, tested, or confirmed.
- Calls to functions, methods, flags, or library APIs. Agents sometimes invent a plausible name that does not exist, or use an argument that exists in a different version.
- Changes at module boundaries: public function signatures, data formats, configuration keys, database schema, and error types.
- Behavior in edge cases the task did not mention: empty input, missing files, concurrent access, time zones, very large inputs.
- Whether files you did not expect were touched.
What you should never accept on the agent's word
- That tests were not weakened. Check the test diff directly.
- That the change is limited to the requested scope.
- That a failing check is "unrelated" or "pre-existing". Confirm it against the starting commit.
- Anything involving secrets, permissions, authentication, or data deletion. Read these lines yourself even if everything else is skimmed.
Where agent changes go wrong
A multi-file change is hard to review because the defects are rarely in one obvious place. They are spread out and often look reasonable in isolation. Later chapters treat each failure mode in detail. For now, learn to recognize the families.
- Scope creep. The agent edits files unrelated to the task: a formatting cleanup, an extra refactor, a "while I was here" fix.
- Invented or misused APIs. The code calls something that does not exist or behaves differently than assumed.
- Weakened checks. A test is skipped, an assertion loosened, or a lint rule silenced so the run goes green.
- Silent behavior changes. A default value changes, an exception is swallowed, or a return type shifts, without being mentioned.
- Partial application. A rename or migration covers most call sites and misses a few, often in less-visited places such as scripts, docs, or configuration.
- Unsupported claims. The summary says tests pass, but the agent never ran them or ran a narrower set.
None of these require bad intent or even a weak model. They follow from how an agent works: it optimizes toward a goal such as "make the tests pass" using the context it has, and the shortest path is not always the correct one.
A review stance that works
Adopt the posture of a reviewer on a colleague's pull request, with two adjustments.
First, assume more breadth and less judgment. A human colleague usually touches the files they understand. An agent will touch whatever the task seems to require, including places it understands poorly.
Second, do not rely on social cues. A colleague who is unsure often says so. An agent may phrase an uncertain guess in the same tone as a verified fact.
The review has a fixed outline, which the next chapters fill in:
- Define the task and what "done" means before the run.
- Start from a clean branch so the diff contains only the agent's work.
- Triage the full change set before reading code.
- Read in a deliberate order.
- Check for known failure modes, especially weakened tests.
- Verify with your own commands.
- Give specific feedback, or revert and take over.
The diagram shows how responsibility flows through this loop.
Every path out of the loop passes through a human decision. The agent never commits its own work in this model.
A worked example of an untrusted claim
Suppose you asked an agent to rename load_config to read_settings across a Python project. It reports: "Renamed the function in all 14 call sites. All tests pass."
Do not accept this. Check each part with your own commands.
# Does the old name still appear anywhere, including non-Python files?
grep -rn "load_config" . --exclude-dir=.git
# What files changed, including new ones?
git status --short
# Did the test run actually include everything?
python -m pytest -qPossible findings:
grepshowsload_configstill appears inscripts/deploy.shand indocs/setup.md. The agent only searched*.pyfiles. The summary's "all call sites" was wrong.git statusshowstests/test_loader.pymodified. Reading that diff reveals one test was marked skipped. The "all tests pass" claim is technically true because a test no longer runs.- Your own test run reports 213 passed, 1 skipped. The agent had said nothing about a skip.
Each finding came from a check you ran yourself. None would have appeared if you had read only the summary.
Calibrating effort
Reviewing everything at maximum depth is not realistic, and it is not necessary. Match effort to risk.
| Change type | Review depth |
|---|---|
| Pure rename or formatting, verified by search and tests | Light. Confirm the pattern, check for misses, run the suite |
| New logic inside one module, covered by tests | Medium. Read the code, check the tests are meaningful |
| Public interfaces, schema, configuration, dependencies | High. Read every line, check callers and compatibility |
| Auth, secrets, permissions, deletion, billing | Full. Read every line and test manually |
Two signals should raise your level of scrutiny automatically. The first is a large diff for a small task. The second is any change to test files, CI configuration, or lint settings when the task did not ask for it.
Summary of the principles
- You are the author of whatever you commit.
- The diff is evidence. The summary and the reported results are claims.
- Verify at boundaries: interfaces, tests, configuration, and anything security-related.
- Scale effort to risk, and raise it when the diff is larger than the task.
- Keep the decision with a human at every exit from the loop.
Exercise
An agent finishes a task to "add a timeout parameter to fetch_data()" and reports: "Added the parameter, updated all callers, all tests pass." List three specific checks you would run before trusting this, and say what each could reveal.
Show answer
Any three of the following. (1) Run git status --short and git diff --stat to see every file touched, which can reveal scope creep or untracked new files. (2) Run git diff -- tests/ and search added lines for skip, xfail, or loosened assertions, which can reveal weakened tests behind the "all tests pass" claim. (3) Run grep -rn "fetch_data(" . and compare against the changed files, which can reveal callers the agent missed, such as scripts or docs. (4) Rerun the full test suite yourself and compare the counts of passed and skipped tests, which can reveal a narrowed run. (5) Read the new parameter's default value and its handling inside fetch_data(), which can reveal a silent behavior change, for example a default timeout where there was none before.
Exercise
Why is it a mistake to accept the agent's statement that a failing test is "pre-existing and unrelated"? How do you check it?
Show answer
The agent may be wrong, or its own edit may have caused the failure. Check it against the starting commit: stash or commit the agent's work on its branch, check out the baseline commit (the one you noted before the run), and run the same test command. If the test passes there, the agent's change broke it. If it fails there too, the failure is pre-existing.