Before You Trust AI Output: Verification and Review
Judge an AI agent's "done" by checks that return pass or fail and by evidence. Move rules that can't bend into hooks and deny rules, and decide where review stops. Checked 2026-11-15.
- Claude Code instructions come in two kinds: ones the model reads and decides on (prompts, CLAUDE.md, skills) and ones the harness always executes (hooks, deny rules, managed settings). Rules that can't have exceptions belong in the second kind.
- Decide whether work is done with a check that returns pass or fail, such as tests, a build's exit code or a linter. "All tests pass" on its own tells you little, so ask for the command that ran and its output.
- When a review checks work against a spec, keep "skip style" in the prompt. A reviewer asked to find problems always finds something, and fixing every finding adds needless abstraction and tests for cases that can't happen.
Judge an agent’s output by checks that come back pass or fail and by evidence (the command that ran and its output), not by its report that it is done. Move rules that can’t have exceptions out of instructions to the model and into hooks and deny rules that the harness always runs. Treat review as something you scope and stop on purpose: decide what it should report against your spec, and when to stop.
This page is a map for checking the quality of an agent’s work. It lists what the official best practices say and the order in which to read our guides. Official facts were checked against the docs on 2026-11-15, when the latest Claude Code on npm (@anthropic-ai/claude-code) was 2.1.325. We did not run any command on this page for this hub. Where the docs did not state something, we left it out or marked it “unverified”, and we label our own views as ours.
What the model decides and what the harness enforces
The official best practices split every Claude Code instruction into two kinds:
- Non-deterministic: you write it and the model reads it. Your prompt,
CLAUDE.mdand skills are this kind. The model usually follows them, but nothing guarantees it. - Deterministic: you configure it and Claude Code (the harness) has to execute it. Hooks, deny rules and managed settings are this kind, applied every time whatever the model decided.
| Claude decides | Claude Code enforces | |
|---|---|---|
| What to do | Your prompt, CLAUDE.md, skills Claude picks up itself | Hooks, and skills only you can start |
| What it can touch | Auto mode’s classifier | Deny rules, the sandbox in strict mode, managed settings |
| When it’s done | A request for evidence, /goal, /code-review | Tests, typecheck, a Stop hook, CI |
| How much it spends | Effort level, Claude’s own pace | --max-turns or --max-budget-usd with -p, a spend limit you’ve set |
| Who has the last word | Claude’s summary of what it did | Branch protection, a person who approves the merge |
Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
Most of the time the docs want Claude to decide, because with the code in front of it Claude is usually better placed than a rule written in advance. The deterministic kind is for things that must always (or never) happen, whatever the model decides. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
If you keep adding emphasis to a CLAUDE.md line and Claude still misses it, that line belongs in a hook. The reverse holds too: delete hooks for things that are only preferences. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
- A rule like “never read
.env” belongs in a deny rule, which holds in every permission mode, including auto andbypassPermissions. Rules match tool calls, not intent: a script that opens the file isn’t caught, so add the sandbox for an OS-level limit. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15) - A
promptoragenthook asks another model to decide, so it isn’t deterministic either. For real enforcement, use acommandorhttphook. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15) - Keep the enforced set small. Every hook and deny rule occasionally fires when it shouldn’t, and each needs maintaining. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
Hook events and exit codes are in Claude Code Hooks: Events, Exit Codes and Examples. How a written ban failed to stop a repeat, and how hooks and git numbers did, is in Don’t Trust an Agent’s “Done”.
Deciding whether work is done
Without a way to check, Claude stops when the work looks done, which makes you the test suite. Give it something that comes back pass or fail and it closes the loop itself: change, run the check, read the output, fix, run again. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
Checks the docs list:
- A test file
- A build’s exit code
- A linter
- A script that diffs output against a fixture
- A browser screenshot next to the mockup
If your repo already has one, the most useful line in CLAUDE.md is the command that runs it. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
You choose how strict the check is.
| Level | How | Who decides |
|---|---|---|
| Prompt | “Run the auth tests after, and keep going until they pass” | Claude, when it is satisfied. No setup |
/goal | A condition that a separate model checks against the conversation after every turn; Claude keeps going until it’s met | A separate model. Matters for long background runs that end a turn with a progress summary while items are open |
Stop hook | Your script runs whenever Claude tries to end its turn; exit code 2 sends it back to work | The harness. The turn doesn’t end until the check passes or the block limit is reached |
| Someone who didn’t write it | /code-review reviews the diff in a fresh subagent that never saw your conversation | A reviewer not swayed by the reasoning that produced the code |
Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
The Stop hook example is a few lines in .claude/settings.json, such as pnpm tsc --noEmit 1>&2 || exit 2. The compiler output goes to stderr because stderr is what Claude gets back as the reason it can’t finish. 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; raise the cap with CLAUDE_CODE_STOP_HOOK_BLOCK_CAP. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
Whatever the level, ask for evidence: the command and its output, or the screenshot. “All tests pass” on its own tells you very little, and for a session you weren’t watching it is the only evidence you have. After Claude says it’s done, /verify has Claude build and run the app and look at the result, which catches problems tests and typechecks miss. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
Whether the check itself is real is a separate question. How green tests failed to guard anything, and how to break the code on purpose to find out, is in Green Tests Prove Nothing.
Using review, and where to stop
To check work against your plan rather than hunt for bugs in general, write the review prompt yourself. The docs’ example has a subagent review the diff against SPEC.md, check that every requirement is implemented and the listed edge cases have tests, report gaps that affect correctness, and skip style. Don’t drop skip style. A reviewer asked to find problems always finds something; fix every finding and you get extra abstraction layers and tests for cases that can’t happen. Source: https://code.claude.com/docs/en/best-practices (checked 2026-11-15)
There is more than one way in:
/code-reviewin your session works on any plan. Source: https://code.claude.com/docs/en/code-review (checked 2026-11-15)- Code Review is for Team and Enterprise. Several agents read each GitHub pull request, a verification step drops false positives, and findings arrive as inline comments ranked by severity. A review never approves or blocks the pull request; the merge decision stays with your team. Source: https://code.claude.com/docs/en/code-review (checked 2026-11-15)
- The docs warn that a review with no findings doesn’t mean the code is error-free or secure. Source: https://code.claude.com/docs/en/code-review (checked 2026-11-15)
Where to stop is our own view. Tell apart work that won’t pass in one round from a loop that never ends. Fix commits produce new findings too, so review just the fixing diff once more. When a reviewer without the conversation history reopens a settled point, reject it by citing the agreed document. Cases and rough round counts are in When to Stop AI Code Review. For design, a different model’s strongest rebuttal is cheaper before any code exists; the steps are in Have Another AI Rebut Your Design.
Doubting root causes and fixes
This section only points to our guides, and these are our views.
- When an agent states a root cause, take a control first, then doubt the environment, artifact freshness and the measurement setup, in that order. See Doubting the AI’s Root Cause.
- When fixes of the same kind keep missing, stop before the next try. Check by eye that the fix reached the real thing, and split “not applied” from “overridden”. If written rules don’t stop the repeat, hand it to a mechanism. See Don’t Make It Fix the Same Thing Thrice.
- When deleting old code, map the dependency direction and remove callers first, one step per commit so tests pass at every commit. See Deleting Thousands of Lines in a Refactor.
Narrowing what the LLM does
The earliest way to make work checkable is not to hand an LLM work you can’t check. This is also our view.
- Free-form prose can’t be checked by machine, so limit the model to picking from options and extracting from source text.
- Structured output guarantees the shape only. Check by machine that an extracted quote really appears in the source, right before you use it.
- Decide whatever can be decided with a function, not with the model.
Details are in Let LLMs Only Pick and Extract.
Reading order
Starting points, not a ranking. Read top to bottom for the full picture.
- Green Tests Prove Nothing: it isn’t a test until breaking the target makes it fail.
- Don’t Trust an Agent’s “Done”: check completion reports against hooks and git numbers.
- Doubting the AI’s Root Cause: controls, environment, artifact freshness, then measurement.
- Don’t Make It Fix the Same Thing Thrice: stop after repeated misses and write down when to retreat and resume.
- When to Stop AI Code Review: an endless loop versus one you must not cut short.
- Have Another AI Rebut Your Design: the strongest rebuttal before code, checked against settled decisions.
- Deleting Thousands of Lines in a Refactor: map dependencies and delete callers first, one step per commit.
- Let LLMs Only Pick and Extract: no prose; pick, extract and verify against the source by machine.
- Claude Code Code Review: /code-review vs Managed PR Reviews: managed Code Review for Team and Enterprise versus local
/code-review. - Claude Code Ultrareview: Cost, Limits and How to Run It:
/code-review ultra, where several cloud agents reproduce each finding.
Related hubs
- Claude Code Hooks: Events, Exit Codes and Examples: enforcing with
StopandPreToolUsehooks. - Claude Code Subagents and Parallel Agents: subagents as reviewers that never saw the conversation.
- Claude Code in CI, Headless and Production: running checks in CI and leaving the last word to branch protection.
- Claude Code Setup and Daily Operations: where
CLAUDE.mdand settings live.
Summary
- Instructions are either decided by the model (prompts,
CLAUDE.md, skills) or enforced by the harness (hooks, deny rules, managed settings). - Move rules with zero exceptions into hooks or deny rules. A line you keep emphasizing is a sign; a hook for a preference should go.
- Decide “done” with a pass/fail check. Strictness rises from prompt to
/goalto aStophook to a review by someone who didn’t write the code. - Ask for the command and its output, not “all tests pass”.
- In a spec review, keep
skip style. Fixing every finding adds abstraction and tests you don’t need. - Checked against the official docs on 2026-11-15; we ran nothing.
FAQ
- Does Claude always follow the rules in CLAUDE.md?
- There is no guarantee. Prompts, CLAUDE.md and skills are instructions the model reads and decides on; it follows them nearly every time, but whether it does on a given turn is still its call. Anything that must happen every time belongs in a hook, a deny rule or a managed setting.
- How do I check an agent's claim that it is done?
- Give it a check that returns pass or fail: a test file, a build's exit code, a linter, a script that diffs output against a fixture, or a browser screenshot next to the mockup. Then ask for evidence: the command it ran and its output.
- How do I stop Claude from finishing with a Stop hook?
- Add a command to the Stop hooks in .claude/settings.json and exit with code 2 when the check fails. Whatever the command prints to stderr goes back to Claude as the reason it can't finish. After eight blocked stops in a row with no tool call between them, Claude Code overrides the next block; raise the cap with CLAUDE_CODE_STOP_HOOK_BLOCK_CAP.
- Should I fix every review finding?
- The official best practices warn that a reviewer asked to find problems will always find something, and fixing every finding leads to extra abstraction layers and tests for cases that can't happen. In a spec review, ask only for gaps that affect correctness and keep skip style in the prompt.