Skip to content

Give Claude a Verification Loop

Claude Code works better when “done” has a concrete signal.

For coding tasks, give Claude a check it can run and interpret: a test suite, a build, a typecheck, a linter, a screenshot comparison, or a script that compares output against a fixture.

Implement the change, run the relevant tests, and keep iterating until they pass.
Show me the command you ran and the final output.
Fix the build failure. Address the root cause, don't suppress the error.
Verify with npm run build before stopping.
Implement this UI change, take a screenshot, compare it to the reference,
then fix visible differences before stopping.
  • The exact command Claude ran.
  • The final pass/fail output.
  • Screenshots for UI work.
  • Any remaining risks or unverified assumptions.

If there is no check Claude can run, you are the verification loop, and every error waits for you to notice it. Claude Code offers escalating ways to hand that job back.

  1. Ask in the prompt. “Run the tests and show the output before stopping.” Cheapest, and enough for most tasks.
  2. /goal. Set a condition and Claude keeps working across turns until it is met: /goal all tests in packages/api pass. Clear it with /goal clear.
  3. Stop hook. A script that runs when Claude tries to end its turn and blocks it until the check passes. Deterministic, not advisory. Claude Code overrides the hook after 8 consecutive blocks, so it cannot loop forever. See hooks.
  4. Adversarial review agent. A fresh subagent reviewing the diff against the plan. Scope it: ask for gaps that affect correctness or stated requirements, and treat everything else as optional. An unscoped reviewer will keep finding things. See independent review.

Pick the lowest level that actually closes the loop for the task.

Without a check, Claude can only stop when the result looks plausible. With a check, Claude can close the loop itself: implement, run, read the result, fix, and repeat.

For unattended work, verification is the difference between “looks done” and “proved done.”