Sub topic 13
Checking the agent's work with tests and review
This chapter assumes you can run your project's tests and linter from the shell, read a git diff, and have used an interactive agent session. An agent's summary says what it intended to do. Verification checks what it actually did.
Why agent output needs checking
An agent can report "all tests pass" without having run them, or after running only a subset. It can also change a test so that it passes, or fix the symptom and leave the cause. Treat the summary as a claim and the diff and test results as evidence.
Run the checks yourself
Run the project's own commands in your shell, not through the agent. This gives you a result that doesn't depend on the agent's account of what happened.
npm test
npm run lint
npx tsc --noEmitIf the agent claims a bug is fixed, reproduce the bug first. Check that a test fails without the fix and passes with it. A test that passes both ways proves nothing.
Review the diff
Read the whole diff before accepting anything. Look at the files the agent touched and compare them with the files you expected.
git status
git diff --stat
git diffCheck these things in order:
- Files outside the task, such as lockfiles, config, or generated output.
- Edited or deleted tests. A weakened assertion is a common shortcut.
- New dependencies in
package.json. - Hard-coded values, disabled checks, and
// TODOorskipmarkers. - Error handling and edge cases the task implied but did not state.
Ask the agent to review too
A second pass by the agent can find problems, but it is not independent. The same model may repeat the same blind spot. Use it as an extra check, with a specific prompt.
Review the uncommitted changes. List any behavior change not covered by a test, any edited test assertions, and any file unrelated to the date-parsing fix.For stronger separation, start a fresh session for the review so it doesn't carry the implementation's assumptions in its context.
Verification loop
When you send a failure back, paste the exact error output. Keep the request narrow, for example "fix the failing test in date.test.ts without changing its assertions."
Common errors
| Problem | Sign | Response |
|---|---|---|
| Tests not actually run | Summary says "should pass" | Run them yourself |
| Test edited to pass | Assertion changed in diff | Revert the test, fix the code |
| Scope creep | Unrelated files in `git diff --stat` | Unstage them with `git restore` |
| Passing but untested | No test covers the new branch | Ask for a test, then confirm it fails without the fix |
Exercise
An agent says it fixed a parsing bug and that all tests pass. The diff shows a changed assertion in an existing test. What do you do before accepting the change?
Show answer
Find out why the assertion changed. If the old assertion was correct, revert the test change and have the agent fix the code instead. Then run the full test suite yourself. If the old assertion was wrong, confirm that against the requirements, and check that a test fails without the fix and passes with it.
Exercise
Why start a fresh session for an agent-led review of its own changes?
Show answer
A fresh session doesn't carry the implementation session's context and assumptions, so the review is less likely to repeat the same blind spots. It is still not fully independent, so it doesn't replace running the tests and reading the diff yourself.