Blog /
How to Make Claude Code Validate Its Own Work
Learn how to make Claude Code validate its own work with commands, a Stop hook, reviewer checks and a live-app journey check after every deploy.

To make Claude Code validate its own work, give it a check it can run that comes back pass or fail (tests, a typecheck, a build's exit code, a browser screenshot), make that check mandatory with a Stop hook, have the diff reviewed by a fresh subagent with /code-review, and ask for evidence, not "all tests pass". For a live app, check the deployed build separately, outside the agent's session.
The reason is one line in Claude Code's best-practices guide: "Claude stops when the work looks done." If it has nothing to run that says whether the work actually is done, "looks done" is all it has to go on.
How do you make Claude Code validate its own work?
Give Claude Code something it can run that returns pass or fail, and decide how strictly that check is enforced: from a line in the prompt, through /goal, up to a Stop hook that Claude Code itself enforces. Add a reviewer that did not write the code, require the command output or screenshot as proof, and check the deployed app outside the session.
This is written for a founder or developer of a live web app on a team of one to ten, who writes code with Claude Code and has nobody whose job is testing.

Six steps turn every task into a repeatable loop:
Put the exact test, typecheck and lint commands in
CLAUDE.md. The best-practices guide calls "the exact test, typecheck, and lint commands" the first thing that belongs there.Say what done looks like, in the prompt or with
/goal, including the evidence you want back.Enforce the main check with a Stop hook in
.claude/settings.json, for examplepnpm tsc --noEmit 1>&2 || exit 2. 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.Review with
/code-review, which reviews the diff in a fresh subagent, or with a read-only reviewer subagent in.claude/agents/limited totools: Read, Grep, Glob.Run
/verifyor a browser check with Claude in Chrome for what tests and typechecks miss.After deploy, have the live app's key journeys checked outside the session, and send each failure back to the agent to fix.
Small teams merging AI-written pull requests should also add security checks next to these functional ones; DevArmor's article on securing AI-generated code in PRs covers that side.
Which Check Decides Pass or Fail, and What Each One Misses
Claude's completion message is not a check. The table compares seven ways to verify its output, from the loosest to the strictest inside a session, with the last row running outside the session against the live app.
| Method | Who decides pass/fail | Enforced by Claude Code? | What it misses |
|---|---|---|---|
| Prompt instruction | Claude, from its own reading | No | Claude decides for itself when it is satisfied |
/goal condition | A separate model checking the conversation after every turn | Partly: Claude keeps going until the condition is met | A model judges whether the condition holds |
| Stop hook running your tests | Your command, through its exit code | Yes: exit code 2 blocks the stop | Only what the command checks; weak tests still pass |
/code-review in a fresh subagent | A subagent that never saw your conversation | No, a model judges | Behavior it does not run |
Reviewer subagent against SPEC.md | A read-only reviewer with Read, Grep and Glob | No, a model judges | It cannot start the app or see the live site |
/verify or browser screenshot | Claude, looking at the result | No, Claude decides what to look at | Only what it chose to look at, usually on the local build |
| Separate check of the deployed app (CheckMyApp) | The journey walked on the live app, with evidence | No, runs outside the session | Only the journeys it walks; a pass is not a guarantee |
- Method
- Prompt instruction
- Who decides pass/fail
- Claude, from its own reading
- Enforced by Claude Code?
- No
- What it misses
- Claude decides for itself when it is satisfied
- Method
/goalcondition- Who decides pass/fail
- A separate model checking the conversation after every turn
- Enforced by Claude Code?
- Partly: Claude keeps going until the condition is met
- What it misses
- A model judges whether the condition holds
- Method
- Stop hook running your tests
- Who decides pass/fail
- Your command, through its exit code
- Enforced by Claude Code?
- Yes: exit code 2 blocks the stop
- What it misses
- Only what the command checks; weak tests still pass
- Method
/code-reviewin a fresh subagent- Who decides pass/fail
- A subagent that never saw your conversation
- Enforced by Claude Code?
- No, a model judges
- What it misses
- Behavior it does not run
- Method
- Reviewer subagent against
SPEC.md - Who decides pass/fail
- A read-only reviewer with Read, Grep and Glob
- Enforced by Claude Code?
- No, a model judges
- What it misses
- It cannot start the app or see the live site
- Method
/verifyor browser screenshot- Who decides pass/fail
- Claude, looking at the result
- Enforced by Claude Code?
- No, Claude decides what to look at
- What it misses
- Only what it chose to look at, usually on the local build
- Method
- Separate check of the deployed app (CheckMyApp)
- Who decides pass/fail
- The journey walked on the live app, with evidence
- Enforced by Claude Code?
- No, runs outside the session
- What it misses
- Only the journeys it walks; a pass is not a guarantee
Deterministic Commands Versus Model Judgment
The divide in that table is who holds the verdict. A Stop hook running your own tests is the strongest in-session option, because your shell command sets the exit code, not Claude. The docs are direct about the alternative: "A prompt or agent hook asks another model to decide, so it isn't deterministic either." For real enforcement they point to a command, http or mcp_tool hook.
A fresh reviewer helps for a different reason. As the guide puts it, handing the same task to a subagent "doesn't make the answer any better. A fresh reviewer does help, because it hasn't seen your reasoning." The reviewer in the docs is one file, .claude/agents/reviewer.md, with tools: Read, Grep, Glob, so it can read but not edit, and that limit "is enforced by Claude Code rather than requested in a prompt." You then ask Claude to have the reviewer compare the change against SPEC.md. Keep "skip style" in that prompt: the docs warn that "A reviewer that's asked to find problems will always find something."
Runtime checks cover what reading code cannot. The guide says /verify "has Claude build and run the app and look at the result. That catches the kind of problem that tests and typechecks miss." For balancing unit, integration and end-to-end tests around these checks, Technioz has a general overview of software testing strategy.
Where the In-Session Checks End
The first six rows all run inside or next to the agent's session, usually before or around deploy. None of them shows that the deployed build works once production configuration, real sign-in and third-party services are in play.
That gap is the subject of our guide on how to check your app still works after an AI coding agent changes it. Only the last row looks at the app your users actually get.
Set the Commands and Done Criteria Up Front
Start with CLAUDE.md at the repository root. The docs' example keeps it short:
# Commands - Install: pnpm install - Run one test file: pnpm vitest run path/to/file.test.ts - Typecheck: pnpm tsc --noEmit
Use your project's real scripts. The guide notes that a line like "Always typecheck before you finish" in this file "works most of the time, not every time"; if it has to happen every time, it belongs in a Stop hook.
Write Acceptance Criteria and Negative Cases
Before Claude edits anything, write down the flow that is changing, the expected end state, and at least one negative case. For a sign-in change, a useful negative case is that a wrong password keeps the user on the sign-in form with an error message.
Ask Claude to mark any criterion unknown when no command or screenshot backs it. That stops polite filler when a step could not run. A quick way to test a new test: break the logic on purpose, confirm the test fails, then revert. If the suite stays green with the logic broken, the assertion was not testing anything.
Then state the done condition in the prompt or with /goal. The docs' example is /goal all tests in tests/auth pass and lint is clean; a separate model checks it after every turn, and Claude keeps going until it is met.
Ask for evidence every time. The guide: "ask Claude for evidence: the command it ran and its output, or the screenshot. 'All tests pass' on its own tells you very little."
Block the Stop Until Checks Pass
A Stop hook runs your script whenever Claude tries to end its turn, and sends Claude back to work if the script exits with code 2. This is the example from the best-practices guide:
{
"hooks": {
"Stop": [
{
"hooks": [
{ "type": "command", "command": "pnpm tsc --noEmit 1>&2 || exit 2" }
]
}
]
}
}The compiler output is redirected to stderr (1>&2) because stderr is what goes back to Claude as the reason it can't finish. To see it work, the docs suggest asking Claude for a change that breaks a type: instead of finishing, it gets the compiler errors back and keeps going until tsc passes.

The same pattern works for fast unit tests or a build. Keep it quick: it runs every time Claude tries to stop.
For browser checks during development, Playwright MCP runs on your own machine inside the agent's session, and it is the better choice when you want the agent to drive a local build before you push. See Playwright MCP with Claude Code for setup.
Hooks, Skills and Safety
The features overview separates the two: a hook fires on a lifecycle event and fits deterministic work, while a skill suits a procedure that needs reasoning. Put the pass-or-fail command in the Stop hook and the instructions for diagnosing failures in a skill.
Mind permissions. The hooks reference warns: "Command hooks execute shell commands with your full user permissions." Review and test every hook command before adding it.
Use command hooks for gates. Prompt and agent hooks ask another model, so their verdict can differ from run to run.
Avoid conditions that can never resolve. The hooks reference says the
stop_hook_activefield istruewhen Claude Code is already continuing because of a stop hook; check it "to avoid blocking on a condition that will never resolve."
Check the Deployed App Before You Call It Done
Passing every local command shows the code compiles and meets its own assertions. It does not show that a real visitor can sign in or pay on the live URL. That verdict belongs outside the agent's session, after the deploy.
Keep two verdicts per release: code-level (the session's checks) and live-journey (sign-up, sign-in, the core action, payment if any, and any page the change touched, walked on the deployed build). A green suite without a passing live journey is partial. Our guide to software deployment testing covers where that check fits; for an example of automated browser runs catching end-to-end regressions in another stack, see Faberwork's Wallaby browser-testing case study.
This is where CheckMyApp fits. Your agent says "done"; CheckMyApp uses your live app as a real user and tells your agent what broke. It runs separately from the agent's session, walks the journeys that matter on the deployed build, and brings the evidence (the steps, screenshots and which build) back to the agent, which still does the fixing. It connects to Claude Code, Cursor and Codex through MCP. It reports what it saw on that run; a pass is not a guarantee.
A Real Failure the Session Could Not See
On our own app, JobLander, the sign-in request answered 200 and created a session, but the user stayed on /login; the expected redirect never happened. A check that reads status codes would call that a pass. Walking the journey as a user failed it (daily watch run #332, Oct 6, 2026), and the fix was merged in PR #349, 2 h 29 min after the check reported it. The case is written up on why a separate check, and connecting your agent takes one command on the install page.
Your agent says “done”. We check your app.
After each deploy and every day, we walk the journeys you choose on your live app and tell your agent what passed and what failed, with screenshots.
claude mcp add --scope user --transport http checkmyapp https://checkmyapp.dev/mcpFree account: $3 of checks, no card · Cursor, Codex and the full install guide
Common Questions About Claude Code Self-Checks
Can Claude Code mark its own task complete? It can say the task is done; it should not be the one who decides. Make a command decide in the session with a Stop hook, and have something that did not write the code look at the result.
Why does Claude say done when it is not? Because "Claude stops when the work looks done." Without a check that comes back pass or fail, its own reading of the work is all it has.
Does a Stop hook loop forever? No. Per the best-practices guide, if the hook blocks eight stops in a row with no tool call between them, Claude Code overrides the next block and ends the turn. Set
CLAUDE_CODE_STOP_HOOK_BLOCK_CAPto raise the cap.
Put together, exact commands in CLAUDE.md, a Stop hook, a fresh reviewer and a check of the deployed app give every session one loop: change, check, fix, check again.
This article was prepared with the help of AI. Found a mistake? Tell us.


