Sub topic 5
Triaging the change set before reading any code
This chapter assumes you know basic Git (branches, staging, diffs) and can run commands in a terminal. It also assumes you started the agent from a clean branch, as described in the previous chapter.
Why triage comes first
A multi-file change is hard to review one line at a time. Before you read any code, you need to know how big the change is, which files it touches, and whether any of those files are surprising. This step is called triage. It takes a couple of minutes and tells you where to spend your attention.
Triage answers four questions:
- Which files were added, modified, deleted, or renamed?
- How large is the change in each file?
- Does the file list match the task you gave the agent?
- Are any files in the list ones you did not expect to change?
Step 1: list every file that changed
Start with git status. git diff does not list untracked files, so a new file the agent created will not show up in it.
git status --short # includes new, untracked files
git diff --stat # size of change per file
git diff --name-status # added, modified, deleted, renamed
git diff --diff-filter=D --name-only # files the agent deletedIn the --short output, ?? marks an untracked file, M a modified file, and D a deleted file. The --stat output shows how many lines changed in each file. The --name-status output uses A, M, D, and R for added, modified, deleted, and renamed files. The last command lists only deletions, which are the changes most worth a second look.
Step 2: compare the list with the task
Hold the file list up against the task you wrote. Suppose the task was "rename the config loader function and update its callers." You would expect changes under src/config/ and in the files that call the function. Here is a result that should make you stop:
| File | Change | Reaction |
|---|---|---|
| `src/config/loader.py` | Modified, small | Expected |
| `src/app/main.py` | Modified, small | Expected, it is a caller |
| `tests/test_loader.py` | Modified, large | Check why a rename needs a large test change |
| `src/billing/invoice.py` | Modified | Outside the task |
| `requirements.txt` | Modified | Dependency change nobody asked for |
| `tests/test_legacy.py` | Deleted | Needs an explanation |
Unexpected files, deleted files, and large changes to small tasks are the three signals to look for. None of them proves a mistake. Each one tells you where to read first.
Step 3: mark each file's risk
Sort the files into three groups before you open any diff:
- Expected and small. Read these quickly later.
- Expected but large. Read these carefully, because size hides mistakes.
- Unexpected. Decide whether to keep or revert each one, before you spend time reviewing its details.
If an unexpected file is clearly wrong, you can stop here and send corrective feedback without reading the rest. Reviewing a change you are going to throw away wastes time.
Common mistakes
- Running only
git diffand missing new untracked files. - Reading the first file in the list instead of the riskiest one.
- Skipping the deleted-files check. A deleted test or config file can be easy to overlook in a long diff.
Exercise
You asked an agent to fix a typo in one error message. git diff --stat shows 14 files changed, and git status --short also shows two ?? entries. What do you do first, and why?
Show answer
Do not read the code yet. Compare the file list with the task. A one-message typo fix should touch one file, so the other 13 are suspect. Identify the two untracked files with git status --short (git diff will not show them), check git diff --diff-filter=D --name-only for deletions, and mark every file outside the task as a keep or revert decision. You will probably revert most of them or re-run with a narrower task.