Topic 4 of 5 · 4 min read
Checkable acceptance criteria for agent tasks
Goal: Write acceptance criteria for an agent task that the agent itself can verify with commands and tests.
Write acceptance criteria as things the agent can observe by running a command: a test that passes, an output that matches, a check that exits with code 0. If the agent has to judge "good enough", it will say yes.
Check yourself · 1 of 3
Which acceptance criterion can an agent verify itself?
Why it matters
An agent that cannot check its work will report success based on how the code reads. Anthropic's own guidance for Claude Code names verification as the single most useful thing you can give an agent: tests, screenshots or expected outputs it can compare against. Criteria like "should be fast and clean" give it nothing to compare. Criteria that run give it a loop: change, run, read the failure, fix.
What a checkable criterion looks like
Each one has three parts: a situation, an observable result and a way to run it.
- Weak: "Handle invalid input properly."
- Checkable: "POST /signup with an empty email returns 400 and body
{"error":"email_required"}. Test:pnpm test signup -t 'empty email'."
Cover these kinds:
- Behaviour. Inputs and expected outputs, including the failure cases.
- Regression guard. "All existing tests in
src/billingstill pass." - Boundaries. "No files outside
src/signup/change." The agent can check this withgit diff --stat. - Quality gates. Type check, linter and build commands from your project, run exactly as CI runs them.
- Not-done signals. "If a test cannot be made to pass without changing its expectation, stop and report."
Before and after
Before:
Add rate limiting to the login endpoint. Make sure it works well.
After:
Add rate limiting to POST /login.
Done when:
1. The 6th failed attempt from one IP within 60 seconds returns 429.
Test: new test in auth/login.rate.test.ts.
2. A successful login resets the counter. Test in the same file.
3. pnpm test auth and pnpm typecheck both pass.
4. git diff --stat shows changes only under src/auth/.
Do not edit existing tests. If one fails, stop and tell me.
The numbers in item 1 are your product decision, not a universal rule.
What goes wrong
- Subjective words. "Robust", "clean" and "efficient" cannot be run.
- A check the agent can edit away. If it may change the tests, a passing suite proves little. Say which tests are fixed.
- Only the happy path. Agents often test what they built. Ask for failure and edge cases by name.
- Criteria you never run. Run the key command yourself before approving. The agent's "all passing" is a claim.
Examples
Criteria for a bug fix
Bug: invoices over 999.99 show the wrong total.
Done when:
- A new failing test reproduces it first:
formatTotal(1234.5)returns"1,234.50". - After the fix, that test passes.
pnpm test invoicespasses with no existing test edited.- Only
src/invoices/format.tsand its test changed.
The unfixable criterion
A task says "page loads fast". The agent cannot measure that, so it adds caching, reports success, and the page is no faster. Rewritten as "the /reports route returns in under 300 ms in the local benchmark script, run with pnpm bench reports", it gives the agent a number to work against. The 300 is an example target.
Key points
- A checkable criterion has a situation, an observable result and a command that verifies it.
- Words such as "robust", "clean" and "works well" cannot be verified by an agent and invite premature success claims.
- Include regression guards, scope boundaries and the same quality gates CI runs.
- Say which tests the agent may not change, and tell it to stop and report if it cannot pass them.
- Run the key check yourself before approving, because the agent's report is a claim, not proof.
Common mistakes
- Using subjective goals such as "make it robust" that no command can check.
- Letting the agent edit the tests that define success.
- Listing only happy-path behaviour and leaving error and edge cases to the agent.
- Accepting "all tests pass" without running the command yourself.
Check yourself · 2 of 3
Why tell an agent which existing tests it may not edit?
Check yourself · 3 of 3
A task says "make the report page fast". What is the best rewrite?
Practice items, not counted towards your mastery.
Start here
- Small CLs (Google Engineering Practices) (opens in a new tab)ArticleFree
Why small, self-contained changes get better reviews, and how to split large ones.
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
A vendor's advice on verification, planning first and managing a filling context.
- Best practices for using GitHub Copilot to work on tasks (opens in a new tab)DocsFree
What makes a task a good fit for a coding agent: clear scope and acceptance criteria.
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 account of giving models precise instructions and testing what they return.