Lesson 20 / 25
Verification Loops
Give the agent a way to check its own work with tests, linters and type checks.
Let it see the result
Agents do much better when they can run something that tells them if the work is right: tests, a linter, a type checker, a screenshot. Tell the agent the verification command in CLAUDE.md, and ask it to run it before saying it is done.
Build, measure, improve
You cannot improve what you cannot measure. Evals, checks and budgets turn a demo into a dependable system.
A verification script
One command that fails loudly gives the agent a clear signal. set -e stops at the first failing step.
#!/usr/bin/env bash
set -e
npm run lint
npm run typecheck
npm testDo not trust "done"
An agent can report success without checking. Read the test output yourself for important changes, and be suspicious of tests that were weakened to make them pass.
Quick check: What most improves an agent's reliability on a coding task?
- A longer prompt with more adjectives
- A command it can run to verify its work
- Hiding the test results
- Fewer files in the repo
Answer
A command it can run to verify its work — Feedback from real checks lets the agent find and fix its own mistakes.