Topic 4 of 5 · 4 min read
Making the agent prove it is done
Goal: Add runnable done criteria to an instruction and detect when an agent reports success without running them.
Give the agent the exact commands that prove the work is done, and ask it to show their output; "done" should mean "these commands pass", not "I think it works".
Check yourself · 1 of 3
Which done criterion can an agent not fake easily?
Why it matters
An agent writes code and then describes it. The description can be wrong. It may say "all tests pass" without having run them, run a different command, or make a test pass by editing the test. Anthropic's own guidance for Claude Code calls giving the agent a way to verify its work the single most useful thing you can do. A runnable check turns the agent's claim into evidence.
How to do it
- Name the commands exactly. Not "run the tests" but
pnpm test src/services/orders,pnpm lint,pnpm tsc --noEmit. Copy them from your own terminal so they work. - State what passing means. "Exit code 0, no new lint warnings, no skipped tests."
- Ask for the output. "Paste the last lines of each command's output in your final reply." Output is harder to invent than a summary.
- Add a test for the new behaviour first. "Write a failing test for the bug, show it failing, then fix it, then show it passing."
- Protect the checks. "Do not edit existing tests or the lint config to make them pass. If a test seems wrong, tell me."
Heavy commands such as a full build or full suite are fine to ask for at the end, but on a shared machine run them with the project's agreed limits.
Before and after
Weak:
Fix the date parsing bug and make sure everything works.
Better:
Fix the date parsing bug in src/utils/date.ts (inputs like "2026-02-30" must return null, not March 2).
Done means all of these pass:
1. pnpm test src/utils/date.test.ts (add a failing test for the bug first and show it failing)
2. pnpm lint
3. pnpm tsc --noEmit
Paste the final output of each. Do not edit existing tests or skip any.
What goes wrong
- Claimed, not run. The reply says "tests pass" with no output. Ask for it, and run the command yourself when the stakes are high.
- Moving the goalposts. The agent deletes or loosens a failing test. Look for edits to test files in the diff.
- Wrong command. It runs one file's tests and reports the whole suite as green. Name the scope.
- Green but wrong. Passing tests prove only what they test. A weak test gives a weak guarantee, so check that the new test would fail without the fix.
Examples
Catching a claim without evidence
Agent: Fixed the bug. All tests pass.
You: Paste the output of pnpm test.
Agent: I did not run it in this session. Running now... 2 failures in cart.test.ts.
The summary was a guess. Asking for output exposed it.
Red then green
Instruction: First write a test that reproduces the bug and show it failing. Then fix the code and show the same test passing.
A test that never failed may not test the bug at all. Seeing it fail first proves it does.
Key points
- Write done as exact commands that you have run yourself, not as run the tests.
- Define passing: exit code, no new warnings and no skipped tests.
- Ask the agent to paste the command output, because a summary can be invented and output is harder to fake.
- Have the agent write a failing test first, then show it passing after the fix.
- Forbid editing existing tests or lint config to get green, and look for such edits in the diff.
Common mistakes
- Saying make sure it works, with no command, so the agent decides alone what works means.
- Accepting a summary such as all tests pass without the command output.
- Letting the agent edit or skip a failing test, then reading the green result as success.
- Naming a command that covers only part of the code and treating it as full verification.
Check yourself · 2 of 3
An agent reports all tests pass, but the diff edits two existing test files. What should you do?
Check yourself · 3 of 3
Why ask an agent to write a failing test before the fix?
Practice items, not counted towards your mastery.
Start here
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
A vendor's own advice: give the agent a way to verify its work, name files and explore before coding.
- Best practices for using GitHub Copilot (opens in a new tab)DocsFree
Guidance on writing clear prompts, breaking tasks down and giving context to a coding assistant.
- AGENTS.md (opens in a new tab)DocsFree
The open convention for a standing instruction file that coding agents read before each task.
More for this topic
- Here's how I use LLMs to help me write code (Simon Willison) (opens in a new tab)ArticleFree
A practitioner's notes on context, clear instructions and always testing what the model produces.