Sub topic 4
Keep changes small enough to review
This chapter assumes you can read a Git diff, stage changes with Git, and have used an AI coding assistant on a real task. Review quality depends on the size of the change. A reviewer who checks a 30-line diff carefully will skim a 900-line one, and an AI assistant can produce 900 lines in under a minute.
Why size limits your review
Reading attention is finite. Studies of human code review consistently find that defect detection drops as a change grows. AI tools make this worse because they:
- touch files you did not ask about
- rewrite working code while "tidying up"
- add helpers, options, and error handling nobody requested
Each extra line is something you must understand before accepting it. If you cannot explain a hunk (a contiguous block of changed lines in a diff), you cannot vouch for it.
The rule of thumb is to accept only as much code as you can review fully in one sitting. For most people that is one behavior change, a few files, and well under a few hundred changed lines.
Constrain the request
You control size before the code exists. Ask for one step at a time and name the boundaries:
- State one outcome: "Add input validation to
parse_order", not "Improve the order module". - Name the files that may change.
- Say what must not change: public function signatures, formatting, unrelated modules.
- Ask for the tests in a separate step so you can review code and tests on their own terms.
If the assistant returns more than you asked for, do not accept the extras. Discard them or ask for them as a separate change.
Measure the change before reading it
Start with the shape of the change, then the detail. The commands below show which files changed, show the full diff, and let you stage changes hunk by hunk.
git diff --stat
git diff
git add -pgit diff --stat lists each changed file with a count of added and removed lines. Check it against your request. A file you never mentioned is a warning sign, and so is a large number of deletions in code you wanted left alone.
git add -p walks through each hunk and asks whether to stage it. Answer y to stage, n to skip, and s to split a large hunk into smaller ones. Only staged hunks go into your commit, so the prompt works as a review gate.
Split what is too large
When a change is too big, you have three options:
- Discard and re-ask. Run
git restore .only if you have no changes of your own in the working tree. Then give a narrower prompt. - Stage in slices. Use
git add -pto commit the part you have reviewed. Leave the rest unstaged and review it next. - Separate refactors from behavior. A rename mixed with a logic fix hides the fix. Commit each on its own.
Common mistakes
- Reviewing only the last file the assistant mentioned in its summary.
- Staging everything with
git add .after reading part of the diff. - Letting formatting changes inflate the diff until real changes are hard to see.
- Committing reviewed and unreviewed hunks together, so later you cannot tell which is which.
Exercise
An assistant was asked to fix a bug in one function. git diff --stat shows 14 files changed and 600 lines added. What do you do, and which command lets you keep only the reviewed fix?
Show answer
Do not review all 600 lines in one pass. Compare the file list to the request, discard or park the unrelated changes, and re-ask with narrower scope if needed. Use git add -p to stage only the hunks that belong to the bug fix, review those carefully, run the tests, and commit them separately.