Sub topic 9
Reviewing the spec and the agent's output
This chapter assumes you can read a Git diff, run a test suite, and have already seen the requirements, design, and tasks documents from earlier chapters. It covers where a human should stop and check the work, and what to look for at each stop.
Why review happens in gates
An agent follows whatever it is given. If a requirement is wrong, the agent builds the wrong thing, and it does so confidently. The cost of fixing a mistake rises at each phase. A bad sentence in the requirements takes a minute to fix. The same mistake found after ten tasks means rewriting code, tests, and design.
A review gate is a point where the agent stops and a person approves the work before the next phase starts. Gates are cheapest early, so most of your attention belongs on the spec.
Reviewing the spec
Review each document for a different kind of fault.
- Requirements: Is each acceptance criterion observable and testable? Look for vague words such as "fast", "secure", or "user-friendly". Check for missing cases, such as the unregistered email or the reused link in the password reset example.
- Design: Does it satisfy every requirement? Does it name the files, data structures, and interfaces it will change? Check that it does not add components that no requirement needs.
- Tasks: Is each task small enough to review in one sitting? Does each task cite the requirement it covers? Is every requirement covered by at least one task? A requirement that no task cites will not get built.
A quick traceability check helps. List the criteria on one side and the tasks on the other, and look for gaps.
| Criterion | Covered by task | Test exists |
|---|---|---|
| 1.1 Link expires after 30 minutes | 1, 2 | Yes |
| 1.2 Same response for unknown email | 3 | No |
| 1.3 Used link is rejected | 1, 2 | Yes |
The empty "Test exists" cell for 1.2 is a finding. Raise it at the gate, before the agent writes any code.
Reviewing the agent's output
After each task, review three things in this order.
- Tests. Run the suite yourself. Do not rely on the agent's statement that tests pass.
- Scope. Check which files changed. Changes outside the task's stated scope are the most common sign of drift.
- Diff against the criteria. Read the code with the acceptance criteria next to it, and ask whether each criterion is visibly satisfied.
git diff --stat main
pytest -q
git diff main -- src/ tests/The first command shows the size and spread of the change. If a task meant to touch one module changed eight files, read those files before anything else.
Also look at the tests the agent wrote. An agent can make a failing test pass by weakening the assertion, deleting the test, or mocking away the behavior being checked. Compare test changes against the criteria, not just against a green result.
Common errors
- Rubber-stamping. Approving a long spec without reading it. Keep documents short enough that you will read them.
- Reviewing only the code. If the spec was wrong, correct code still delivers the wrong behavior.
- Batching tasks. Letting the agent run five tasks before you look. Review after each task so a wrong turn costs one task.
- Fixing the code but not the spec. If review shows the spec was wrong, change the spec first, then the code. The next chapter covers keeping them in sync.
Exercise
An agent finishes task 2 and reports that all tests pass. The diff touches the token module, the tests, and an unrelated login handler. What do you check first, and why?
Show answer
Check the unrelated login handler change first. It is outside the task's scope, so it may be spec drift or an unrequested change. Then run the tests yourself, and confirm the test changes still assert the acceptance criteria and were not weakened to pass.