How Claude Code worksPart 9
Verify against the spec
On this page
In short: A building inspector does not ask the builder whether the house is finished. They walk it with the drawings in hand, room by room. Give Claude the same habit: one verify command, tests named after each acceptance criterion, an alarm that runs verify before Claude can say done, reviewers that check against the spec, and an evidence table at the end.
Part 8 kept the data honest. This part proves the result does what the spec promised. The project in the examples, the Acme storefront, is made up.
“Done” needs a definition
Think of it like this: “The kitchen is finished” can mean the cupboards are in, or that the tap runs hot water. The drawings say which.
Claude is eager to finish. Without a definition, “done” means “the code looks complete”. With a spec from Part 7, done has a precise meaning: every acceptance criterion has evidence.
Five pieces of verification
Each piece uses something from earlier parts. Together they turn “trust me” into “here is the proof”.
- 1 · One command that checks everything
Lint, types, tests and build behind one name. Claude, CI and you all run the same thing.
// package.json "scripts": { "verify": "npm run lint && tsc --noEmit && npm test && npm run build" } - 2 · Tests named after the criteria
Each test says which promise it checks, so a failure points at the spec.
test('AC-2 unknown code shows an error and changes nothing', ...) test('AC-3 a second gift card is refused', ...) - 3 · An alarm before Claude says done
A Stop hook (Part 3) runs verify. If it fails, exit 2 keeps Claude working.
"Stop": [{ "hooks": [{ "type": "command", "command": "npm run verify --silent || (echo verify failed >&2; exit 2)" }] }] - 4 · Reviewers in parallel
Two specialists (Part 3), each with its own desk, read the change against the spec and against safety rules.
> Use the spec-reviewer and security-reviewer subagents in parallel on this branch. Report findings only.
- 5 · An evidence table
Claude ends with one row per criterion. A gap is visible at a glance.
AC-1 met test AC-1 passes; screenshot of total AC-2 met test AC-2 passes AC-3 met test AC-3 passes AC-4 NOT MET receipt shows no balance; no test AC-5 met types are integer; test AC-5 passes
- 6 · You decide
The table makes review fast. You check the rows, not the whole diff from scratch.
Under the hood: Stop hooks without loops
- A Stop hook runs when Claude is about to finish its reply. Exit code 2 blocks the stop, and the error text goes back to Claude.
- The hook’s input includes
stop_hook_active, which is true when Claude is already continuing because of a Stop hook. Check it in a script if you want to avoid sending Claude round the same failure forever. - Keep verify fast. If the full suite takes ten minutes, run the fast checks in the hook and leave the slow ones for CI.
- CI should run the same
npm run verify. Then a pass on your laptop and a pass in CI mean the same thing.
A reviewer with one job
Think of it like this: The person who built the wall is the worst person to inspect it. They see what they meant to build.
A subagent (Part 3) has its own desk and only the tools you give it. Make it read-only, give it the spec, and ask for a report.
--- name: spec-reviewer description: Checks a change against its spec. Use after a feature is built, before it is called done. tools: Read, Grep, Glob, Bash model: sonnet --- You review one change against specs/<feature>/spec.md. 1. List every acceptance criterion by ID. 2. For each one, find the code and the test that cover it. 3. Run the tests for that criterion. 4. Report a table: ID, met / not met / not tested, evidence. 5. List anything built that no criterion asked for. Do not fix anything. Report only.
Run a second one for security, with its own checklist: secrets, input validation, permissions. Both run in parallel and return short reports, so your desk stays clear (Part 6).
What counts as evidence
- A named test for that AC, passing.
- Command output: the verify run, a query result.
- A screenshot of the page for a visible criterion.
- A link to the line of code that does it.
- "I have implemented AC-3."
- "Should work now."
- A test that passes but checks something else.
- Green CI when the AC has no test at all.
Rule: if a criterion cannot be proved by a test, a command output or a screenshot, the criterion is too vague. Fix it in the spec.
Where this fits in the bigger picture
Think of it like this: A colleague you can hand work to is one whose “done” you can trust. Not because they are never wrong, but because they show you the proof.
The spec says what to build, the contract keeps the data honest, and verification proves the result. That loop is what makes a setup like this safe to hand real work to. Part 10 makes sure the proof, and the decisions behind it, are still there tomorrow.
Which one fits?
- I want one way to know it works: A verify scriptOne command for lint, types, tests and build. Claude, CI and you run the same one.
- Claude says done too early: A Stop hookRun verify when Claude tries to finish. Exit 2 sends it back to work with the errors.
- I want a second opinion: A reviewer subagentIts own desk, read-only tools, and one job: check the change against the spec.
- A criterion is hard to test: Make it testable or split itRewrite it in the spec until a test or a screenshot could prove it.
- I do not have time to read the whole diff: The evidence tableRead the rows. Open the code only where a row is weak or missing.
Your setup so far
- Part 1 · where it worksYou know which machine does what, and which folders Claude can reach.
- Part 2 · what it remembersOne task per notebook; photocopies in their own folder; helpers for noisy side jobs.
- Part 3 · how it behavesFridge rules for what is always true, recipe cards for procedures, alarms for musts, specialists for checks.
- Part 4 · what it can reachPhone lines to your tracker and tools, checked before trusted; your setup packed as one toolbox.
- Part 5 · what it may doKeys for routine work, a knock for anything that publishes, locked doors for secrets.
- Part 6 · how it stays sharpA clear desk: fresh sessions, focused summaries, helpers for big reads, rules only where they apply.
- Part 7 · what it builds fromA written spec with acceptance criteria, rules with IDs, and a plan agreed before code.
- Part 8 · how it avoids guessingContract first: generated types are the only truth, and a hook makes Claude state the facts.
- Part 9 · how it proves the workOne verify command, reviewers in parallel, and evidence before anything is called done.
- NextPart 10 · handoffs and memory
Three rules of thumb
The same command on your laptop, in Claude's loop and in CI. No "works for me".
Every AC gets a row with something you can check. Words are not evidence.
Keep the reviewer read-only. Separate roles catch more than one colleague doing both.
QuizCI is green and Claude says the gift card feature is done. The evidence table shows AC-4 as “not tested”. What is the status?
Show the answer
Answer: Not done: AC-4 has no evidence
Green CI only proves the tests that exist. AC-4 has none, so nothing shows it works. Add a test for it, or show other evidence, before calling it done.
Words in this post:
- Verify script: one command that runs every check: lint, types, tests, build.
- Stop hook: a script that runs when Claude is about to finish, and can send it back to work.
- Reviewer subagent: a read-only helper that checks a change against the spec.
- Evidence table: one row per acceptance criterion, each with proof.
- CI: checks that run automatically on every pull request.
Hook and subagent details were checked against the Claude Code documentation on hooks and subagents in November 2026. These features change often, so the docs are the final word for your version.
Next, Part 10: Handoffs and memory makes tomorrow’s session start where today’s left off.
Setting up Claude Code or AI agents for your team?
I help teams build this: agents, RAG search and Claude Code setups that hold up in production.
Series
How Claude Code works
- How Claude Code worksWhere Claude runs
- How Claude Code worksSessions and forks
- How Claude Code worksSkills, hooks and subagents
- How Claude Code worksMCP servers and plugins
- How Claude Code worksPermissions and safety
- How Claude Code worksContext and cost
- How Claude Code worksSpecs as the source of truth
- How Claude Code worksContract first
- How Claude Code worksVerify against the specyou are here
- How Claude Code worksHandoffs and memory
- How Claude Code worksYour setup as a kit
- How Claude Code worksRolling it out