Sub topic 3
Start with the requirement, not the code
This chapter assumes you can read a Git diff, write basic unit tests, and have used an AI coding assistant. It covers the intent check, the first step of a review. Do it before you read any line of the change.
Why intent comes first
AI-generated code usually looks tidy and runs. If you read it first, you tend to judge whether it is good code. You should be judging whether it is the right change. A clean function that solves the wrong problem is still a failed review.
Reading the code first also anchors you. The assistant's choices start to feel like the requirement. You then miss what it left out, such as an unhandled case or an ignored constraint.
Write down the requirement
Before you open the diff, state what the change must do in your own words. Use the original ticket, issue, or prompt as the source. Then list three things:
- Behavior: what should happen for normal input.
- Boundaries: what should happen for empty, missing, large, or invalid input.
- Non-goals: what the change must not touch.
Here is an example. The task was "add a function that returns the average of a list of scores." Your notes might read:
- Returns the mean of the numbers.
- An empty list needs a defined result. The ticket does not say which one, so you must ask or decide.
- No changes to existing scoring code.
The empty-list line matters most here. The requirement never addressed it, so the assistant had no guidance and made a silent choice. Writing the boundary down before reading the code lets you see that gap.
Compare the change to the requirement
Start with the file list, not the lines. This command gives you a summary of what changed:
git diff --statCheck the summary against your notes:
- Missing files: if the requirement implies a change to a config file or a test, and it is absent, the change is incomplete.
- Extra files: files you did not expect are scope creep. The assistant may have refactored code, renamed things, or edited unrelated modules.
- Size mismatch: a "small fix" that touches twelve files needs an explanation.
Then read the diff with your notes beside it. For each requirement, find the code that satisfies it. For each hunk of code, find the requirement that justifies it. A hunk with no matching requirement is either unneeded or hiding a decision you should make yourself.
Common intent mismatches
| Mismatch | What it looks like |
|---|---|
| Solves an easier problem | Handles the happy path and ignores the stated constraint |
| Solves a different problem | Adds a general utility when you asked for a specific fix |
| Silent assumption | Picks a behavior for an unspecified case without saying so |
| Scope creep | Renames, reformats, or "improves" unrelated code |
A mismatch is not always the assistant's fault. A vague prompt produces a vague change. If you find several mismatches, consider rewriting the requirement more precisely and asking again, instead of patching the output.
Ask the assistant to state its assumptions
You can ask the assistant to list the assumptions it made and the cases it did not handle. Treat the answer as a lead to check, not as proof. It shows you where to look first. It cannot tell you what it failed to notice.
Exercise
A ticket says "make the export endpoint return results sorted by date." The AI's diff sorts the results and also renames three helper functions in an unrelated module. Which intent-check problem is this, and what do you do?
Show answer
It is scope creep. The sorting change matches the requirement, but the renames have no matching requirement. Ask for them to be removed from this change, or move them to a separate change that you review on its own.
Exercise
Why do you write the requirement notes before opening the diff instead of after?
Show answer
Reading the code first anchors your judgment on the assistant's choices. Notes written beforehand give you an independent standard, so you can see omissions such as an unhandled empty input.