A developer asks Claude Code to add a promo code field to the checkout form. A minute later: "Done. Added the field, the validation and the API call, and updated the order total." The diff reads well, so it gets pushed. CI fails: the order summary component still passes the old total shape, and a pricing test expects two decimal places. Nothing in the session ever ran the tests or the typechecker. Claude didn't lie. It stopped when the work looked done, and nothing told it otherwise.
The common misconception
"When Claude Code says the task is done, the change works, so there's no need for tests or another check." It's an easy belief to fall into:
The summary is specific and confident. It lists files, functions and edge cases, and reads like a report of verified work.
It's often right. Anthropic's docs say that in most cases a plain first prompt in a fresh session already does the right thing.
Claude Code's own loop has a "verify results" phase, so it's natural to assume verification always happens.
The diff looks right, and reading a diff feels like checking it.
The half-truth: Claude does verify when it has a way to. Its loop is gather context, take action, verify results. But verifying needs something that returns pass or fail. Without that, Claude's judgment that the work looks right is the whole verification step.
What actually happens
Claude stops when the work looks done
The docs put it plainly: "Claude stops when the work looks done." With nothing to run, "In practice that makes you the test suite, and every mistake sits there until you happen to notice it." They list this among the four usual reasons a session goes wrong: Claude said it was done and it wasn't quite, "usually because it had no way to check its own work."
A check closes the loop
Give Claude something that comes back pass or fail, and it closes the loop itself: it makes the change, runs the check, reads the output if something broke, fixes it and runs the check again. The check can be almost anything whose result Claude can read:
A test file, or a build's exit code
A typecheck or a linter
A script that diffs output against a fixture
A browser screenshot next to the mockup
Who decides it's done
The docs sort every instruction into two kinds. Non-deterministic ones are read by the model, which decides what to do with them: your prompt, a line, a skill. Deterministic ones are applied by Claude Code, the harness, every time: hooks, deny rules, managed settings. "Done" comes in both kinds, at four levels of strictness:
Option
Who decides it's done
Setup
"Run the tests and keep going until they pass" in the prompt
Claude itself
None
/goal with a condition
A separate small, fast model, after every turn
One command, this session only
A Stop hook
Your script's exit code, run by Claude Code
A few lines in .claude/settings.json
/code-review
A fresh subagent that never saw the conversation
None
/goal deserves a closer look. Its evaluator gets the condition and the conversation so far; it doesn't run commands or read files. So "all tests in test/auth pass" works because Claude runs the tests and the result shows up in the transcript. A condition such as "the checkout works" gives the evaluator nothing to check.
Ask for evidence, not a verdict
Whichever option you choose, ask Claude for the command it ran and its output, or the screenshot. The docs are direct: "All tests pass" on its own tells you very little, and reading the output is faster than rerunning the check yourself. For a session you weren't watching, it's the only evidence you have.
Same task, with and without a check
Bash · terminal
# No check: Claude stops when the diff looks rightclaude "Add a promo code field to the checkout form"
Bash · terminal
# A check, a finish line and a request for evidenceclaude "Add a promo code field to the checkout form. Then runpnpm vitest run src/checkout and pnpm tsc --noEmit, keep goinguntil both pass, and paste the final output."
The second prompt costs two extra sentences. It defines "done" as commands Claude can run, and it gives you output to read instead of a summary to trust.
Enforcing the check with a Stop hook
A line such as "Always typecheck before you finish", in a prompt or in CLAUDE.md, works most of the time, not every time. When the check must pass before every stop, make it a :
The hook runs whenever Claude tries to end its turn. Exit code 2 blocks the stop, and whatever the command prints to stderr goes back to Claude as the reason it can't finish yet; that's why the compiler output is redirected with 1>&2. To test it, ask for a change that breaks a type: instead of finishing, Claude gets the compiler errors and keeps going until tsc passes.
How to apply it in your project
Find the check you already haveTests, a typecheck, a linter, a build. If there's nothing yet, a small script that diffs output against a fixture counts.
Put the commands in CLAUDE.mdWrite the exact test, typecheck and lint commands, plus how to run a single test file. Only the commands: enforcing them is a hook's job.
Write "done" into the promptName the check, tell Claude to keep going until it passes, and ask for the final output rather than a summary.
Enforce the non-negotiable check with a Stop hookCommit it in .claude/settings.json so it applies to everyone who works in the repo. Keep it fast, because it runs every time Claude tries to stop.
Bound long runs with `/goal`For long or background work, state one measurable end state and how to prove it, and add a limit such as or stop after 20 turns.
Key takeaways
Claude stops when the work looks done; without a check, "looks done" is all it has to go on.
A check is anything that comes back pass or fail: tests, a typecheck, a linter, a build, a fixture diff.
Prompt and CLAUDE.md lines are followed most of the time; a Stop hook is enforced by Claude Code every time.
/goal's evaluator reads the conversation and runs nothing, so the proof must appear in the transcript.
Ask for the command and its output, not for "all tests pass".
التعليقات (0)