Sub topic 14
Putting It Together as a Repeatable Review Loop
This chapter assumes you know basic Git (branches, staging, diffs), can run your project's tests, linter, and type checker, and have used a coding agent at least once. It joins the earlier techniques into one loop you can run on every agent task.
The loop at a glance
Each run follows the same stages. Reviewing and steering are repeated until you accept, revert, or take over.
Before the run
- Write the task and the definition of done. Name the files or directories in scope and the command that proves success.
- Create a branch and confirm the tree is clean, so every change afterwards belongs to the agent.
git switch -c agent/rename-config-loader
git status --short
git log --oneline -1After the run
Triage
Look at the size and shape of the change before reading code. Run git status as well as git diff, because git diff does not list untracked files.
git status --short
git diff --stat
git diff --name-status
git diff --diff-filter=D --name-onlyAsk three questions. Are there files outside the scope? Were any files deleted? Is the size what you expected for this task?
Review in order
Read the file list first, then interfaces (signatures, public types, config), then the implementation, then the tests. Use git diff --color-moved=zebra and git diff -w to remove noise from moved or reformatted code.
Check tests and run your own checks
Inspect the test changes by themselves and search for markers that silence checks.
git diff -- tests/
git diff -U0 | grep -nE '^\+.*(@pytest\.mark\.(skip|xfail)|# noqa|# type: ignore)'Then run the project's tests, type checker, and linter yourself. The agent's summary is a claim, not evidence. If the change affects behavior users see, run the code once by hand.
Deciding what happens next
| Situation | Action |
|---|---|
| Everything is correct and in scope | Commit |
| Some hunks are good, some are not | Stage good hunks with `git add -p`, discard the rest with `git restore -p .` |
| Problems are clear and small | Send bounded feedback and re-run |
| The agent went the wrong way or the task was too large | Revert, narrow the task, and start again |
| The same fix fails after two corrections | Take over and edit by hand |
Good feedback confirms what is correct, names each problem with its file, limits the next edit, and asks for a verifiable report:
The change to src/config/loader.py is correct. Two problems remain:
1. You edited src/billing/invoice.py, which is outside this task. Revert that file.
2. tests/test_loader.py now skips test_missing_file. Restore the test and fix the code so it passes.
Do not change any other files. When finished, run the project's test suite and report the exact command and its result.Closing the loop
After each review, ask whether the same correction has come up before. If it has, add it to your project instructions, for example "do not edit files outside the named directories" or "never skip tests to make them pass". The agent then follows the rule on later runs without being told again.
Exercise
An agent run finishes. git diff --stat shows four modified files, but git status --short also lists a new file, scripts/migrate.py, that the task never mentioned. Why did git diff not show it, and what should you do?
Show answer
git diff only compares tracked files, so untracked files do not appear in it. Read the new file, decide whether it is within the task's scope, and delete it if it is not. If the agent keeps creating such files, add an instruction to the project guidance and bound the next task more tightly.
Exercise
The agent fixed a failing test by adding @pytest.mark.skip to it, and its summary says "all tests pass". Which step of the loop catches this, and what is the corrective message?
Show answer
The test-integrity check catches it: searching the added lines for @pytest.mark.skip finds the marker. Send feedback that names the file and test, tells the agent to remove the skip and fix the code so the test passes, bounds the edit to the relevant files, and asks it to report the exact test command and its result. Then run that command yourself.