Claude Code or your AI agent said done, but the tests fail
What it looks likeAgent: Done! The feature is implemented and all tests pass.
$ npm test
Tests: 2 failed, 41 passed, 43 total
Agents often say "done" without running every check, or after quietly changing a test. Run the full test, build, typecheck and lint yourself, read the diff for weakened tests, and make the agent show real output before it finishes.
Why it happens
An agent's "done" is a summary, not a result. Common gaps: it ran only the tests near its change, it never ran the production build or the typechecker, it made a failing test pass by loosening it (an added .skip or .only, a deleted assertion, an updated snapshot), it left a stub, or it edited files outside the task.
Fix it by hand
- Run everything yourself. The full test suite, the production build, the typechecker and the linter, for example
npm test,npm run build,npx tsc --noEmitandnpm run lint. - Read the diff for quiet failures.
git diff --statshows which files changed. Check test files for.only,.skip, removed assertions or rewritten snapshots, and look foranycasts,@ts-ignoreand TODO stubs. - Give the agent the real output. Paste the failing lines back and ask it to fix the code without changing the tests.
- Write the rule down. In
CLAUDE.mdorAGENTS.md: "Before saying done, run npm test and npm run build, and paste the last lines of each output." - Enforce it in Claude Code with a Stop hook. A Stop hook runs when Claude finishes responding. If it exits with code 2, Claude gets your stderr message and keeps working. In
.claude/settings.json:{ "hooks": { "Stop": [ { "hooks": [ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/require-tests.sh" } ] } ] } }
Claude Code passes#!/bin/sh # .claude/hooks/require-tests.sh if ! npm test --silent >/tmp/stop-hook-tests.log 2>&1; then echo "Tests are failing. Fix them before you finish:" >&2 tail -n 30 /tmp/stop-hook-tests.log >&2 exit 2 fi exit 0stop_hook_activeto the hook and stops after 8 blocks in a row, so a test that can never pass won't loop forever.
Stop it happening again
- Keep the Stop hook (or your agent's equivalent) in the project so every session uses it.
- Ask for the real output, not a summary, whenever an agent says something works.
- Turn each mistake you correct into a written rule the agent checks next time.
Prove It Works Free
Prove It Works runs your project's real test, build, typecheck and lint commands, shows the output with exit codes, inspects the diff for weakened tests, scope creep and broken project rules, and makes the agent say "NOT DONE" until they pass. Its Never Twice mode turns a correction into a rule checked every time after.
- Runs your tests, build, typecheck and lint, and shows the real output with exit codes.
- Flags weakened tests, files changed outside the task and broken project rules before the agent can say "done".
- Verdict first. Every finding shows the file and line, what it breaks, and the fix as a diff that is applied only with your OK.
Prove It Works: how it works, with examples · Install guide
Works with Claude Code, Claude.ai, Cursor, Codex and other agents that read SKILL.md files. No installs, no accounts, works offline.