{"slug": "acceptance-criteria-your-ai-coding-agent-can-actually-test", "title": "Acceptance criteria your AI coding agent can actually test", "summary": "A developer outlined a method for writing acceptance criteria that AI coding agents can actually verify, arguing that vague criteria like \"the dashboard should load quickly\" give an agent nothing to fail against. The approach requires each criterion to name specific data, routes, numbers, ordering and timing, pair every success case with a failure case, and state observable outcomes rather than implementation details such as database indexes. The developer also recommends splitting multi-part criteria into separate testable clauses so edge cases like empty states and double submissions become numbered tests the agent must pass before declaring a feature done.", "body_md": "Most acceptance criteria I see in PRDs are wishes, not tests. \"The dashboard should load quickly.\" \"Users should be able to reset their password easily.\" \"The search should work well.\"\n\nHand those to an AI coding agent and it will nod, build something, and call the feature done — because there is nothing in the sentence it can fail against. A criterion the agent cannot test is a criterion the agent cannot satisfy. It is decoration.\n\nGood acceptance criteria are written so that a machine — or a tired reviewer at 11pm — can check them and say yes or no without guessing. Here is how I write them.\n\nThe format is not the point. The values are.\n\nWeak:\n\n```\nGIVEN a logged-in user\nWHEN they open the dashboard\nTHEN they see their tasks\n```\n\nStrong:\n\n```\nGIVEN a user with 3 active sprints and 12 open tasks\nWHEN they open /dashboard\nTHEN the page renders within 1.5s and lists exactly the 12 open tasks,\nordered by due date ascending, with the sprint name on each row\n```\n\nThe strong version names the data, the route, the number, the order, and the time. An agent can build a test for every clause. The weak version has no clause at all — \"see their tasks\" could mean anything, and the agent will pick the easiest interpretation.\n\nRule: if a criterion has no number, no named state, and no named outcome, it is not finished yet.\n\nA feature is only defined when you also say what happens when it goes wrong. For every success case, write the failure case next to it:\n\n```\n- Success: GIVEN a valid email and password\n  WHEN the user submits the login form\n  THEN a session is created and the user lands on /dashboard\n\n- Failure: GIVEN a wrong password\n  WHEN the user submits the login form\n  THEN no session is created, the form shows \"Incorrect email or\n  password\", and the password field is cleared\n```\n\nAgents are optimistic builders. Left alone, they build the happy path and leave the error state as a browser alert or a silent nothing. The failure twin is what forces the error UI, the validation, and the \"what happens next\" into the build — before a real user discovers the gap.\n\nThe bugs that cost you a weekend are never in the main flow. They are in the edges: empty lists, duplicate submissions, expired sessions, zero results, amounts of exactly zero.\n\n```\n- GIVEN a workspace with no sprints\n  WHEN the lead opens /sprints\n  THEN show an empty state with a \"Create your first sprint\" button,\n  not a blank page and not a loading spinner that never stops\n\n- GIVEN a user double-clicks \"Record payment\"\n  WHEN the second click lands before the first request finishes\n  THEN only one payment is recorded; the button is disabled while\n  the request is in flight\n```\n\nWrite the edge case as a criterion with the same GIVEN / WHEN / THEN shape. If it lives in a footnote (\"handle empty states\"), the agent will not build it. If it is a numbered criterion, it becomes a test the agent runs before calling the feature done.\n\n\"The API should use a database index\" is not an acceptance criterion. It is an implementation detail wearing a criterion's clothes, and it cannot be observed from the outside.\n\nObservable instead:\n\n```\nGIVEN 10,000 indexed records\nWHEN the user searches for \"invoice\"\nTHEN results appear in under 500ms\n```\n\nThe agent is free to add the index, cache the query, or paginate — whatever satisfies the observable number. Criteria that prescribe the implementation tie the agent's hands and still fail to say what the user experiences. Criteria that state the observable outcome let the agent choose the means and let you verify the end.\n\nA criterion that says three things is a criterion that passes when two of them work:\n\n```\nBad: \"The user can sign up, verify their email, and see the\nonboarding checklist.\"\n```\n\nSplit it:\n\n```\n- GIVEN a new email address WHEN the user signs up THEN an account\n  is created and a verification email is sent within 30 seconds\n- GIVEN an unverified account WHEN the user clicks the link in the\n  email THEN the account becomes verified and the user lands on\n  /onboarding\n- GIVEN a verified account WHEN the user lands on /onboarding THEN\n  the checklist shows 3 items, all unchecked\n```\n\nThree checks, each pass or fail on its own. When the agent runs them, a failure points at exactly one broken thing instead of a vague \"signup doesn't work\".\n\nIn the four files I generate, acceptance criteria sit in `PRODUCT_REQUIREMENTS.md` — one GIVEN / WHEN / THEN block per feature, success and failure side by side, edge cases as numbered criteria. `AI_AGENT_IMPLEMENTATION.md` then tells the agent to treat each criterion as a check: build the feature, run the checks, do not call it done until every one passes. `TECHNICAL_ARCHITECTURE.md` turns the numbers into indexes, validation schemas, and idempotency keys, and `UI_UX_SPECIFICATION.md` carries the empty states and error states the failure cases demand.\n\nThe point is not the format. The point is that the agent has something to test against — and that you have something to hold it to when it says \"done\".\n\nRead any criterion in your PRD and ask: could I write a test for this without asking the author a question? If the answer is no — no number, no named state, no observable outcome — rewrite it before the build starts. It takes five minutes per feature, and it is the difference between an agent that finishes your feature and an agent that finishes something that looks like your feature.\n\nIf you want the same starting point, the generator writes GIVEN / WHEN / THEN criteria into every feature it produces — you can try it free with 50 credits at [webdevmehedi.com/ai-prd-generator](https://webdevmehedi.com/ai-prd-generator) — and the free template behind the format is in the [ai-prd-template repo](https://github.com/web-dev-mehedi/ai-prd-template).\n\nA PRD without testable criteria is a wish list. Write the test into the wish, and the agent will build what you actually asked for.\n\n*Web Dev Mehedi turns an app idea into a build-ready PRD, UI/UX spec, database schema, API contracts, and Cursor/Claude Code rules in under 60 seconds. Free signup includes 50 credits; paid plans start at ৳99/month.*", "url": "https://wpnews.pro/news/acceptance-criteria-your-ai-coding-agent-can-actually-test", "canonical_source": "https://dev.to/web-dev-mehedi/acceptance-criteria-your-ai-coding-agent-can-actually-test-3l1e", "published_at": "2026-11-26 04:39:43+00:00", "updated_at": "2026-11-26 04:43:20.163517+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": [], "also_reported_by": [], "takeaway": "Write acceptance criteria with named data, routes, numbers, ordering and timing, pair each success case with a failure twin, and split multi-part criteria so an AI coding agent can turn every clause into a test.", "recommendation": {"advice": "Rewrite vague acceptance criteria as numbered GIVEN/WHEN/THEN clauses with concrete numbers and named states, add a failure twin for each success case, and split multi-part criteria so the agent can test each one.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/acceptance-criteria-your-ai-coding-agent-can-actually-test", "markdown": "https://wpnews.pro/news/acceptance-criteria-your-ai-coding-agent-can-actually-test.md", "text": "https://wpnews.pro/news/acceptance-criteria-your-ai-coding-agent-can-actually-test.txt", "jsonld": "https://wpnews.pro/news/acceptance-criteria-your-ai-coding-agent-can-actually-test.jsonld"}}