Home › All prompts › Spec and Tests First: Tell the Agent When It's Done
Mini pack
Free
Spec and Tests First: Tell the Agent When It's Done
Agents often say they're done before the work actually is. These 9 free prompts help you write down what done means as checks, turn those checks into failing tests before any code exists, have the agent build until the tests pass without touching them, and ask for proof instead of "All done!"
Write down what "done" means, turn it into tests before any code exists, build until they pass without touching them, ask for proof instead of "Done!", and split big features into small specs.
9 prompts in 4 sections. Replace everything in [BRACKETS IN CAPS], then copy and paste into your AI tool.
Claude Code and Cursor's Agent: all 9 prompts are pasted into either tool, opened in the reader's project. Prompts 1.1, 1.2 and 4.1 only write planning files (SPEC.md, SPECS.md) and no code; 2.1, 3.1 and 4.2 add tests or code and tell the agent when to stop and ask; 2.2, 3.2 and 3.3 only check and report. The core rule in every build prompt: change the code, never the tests, unless the reader says so.
Claude Code: interview-then-SPEC.md and a fresh session to build from it, asking for evidence (the command and its output) instead of "all tests pass", /goal (a separate model checks the condition after every turn), /verify, /code-review in the terminal (fresh subagent), the "skip style" warning for spec reviews, and /clear were checked against Anthropic's Claude Code best-practices and /goal pages. The Stop hook is only pointed to (Claude Code Guardrails 3.4).
Cursor: Plan Mode (Shift+Tab, clarifying questions, an editable plan, Save to workspace into .cursor/plans/, revert and refine the plan instead of patching), the TDD order (write tests, confirm they fail, commit, then code that passes without changing them), the agent taking browser screenshots, and Agent Review in the Source Control tab were checked against Cursor's Plan Mode docs and its agent best-practices guide.
Not repeated here: getting an idea into a brief points to Say What You Mean; a quick proof check after a fix to Ship It Safe 7.2; enforcing tests with a Stop hook to Claude Code Guardrails 3.4; a test for one bug to Fix My Bugs 2.3.
No stats or X claims: no numbers, no X posts quoted, and no affiliate or sponsor copy.
Written for use with Claude Code and Cursor's Agent. Not yet tested against them.
Use this when you know what feature you want and are about to ask the agent to build it. It's for a short SPEC.md with numbered checks the agent can test, so "done" is written down before any code exists.
Fill in: [THE FEATURE] (e.g. "people can add tasks to a to-do list, tick them off, and delete them"), [WHO USES IT] (e.g. "me and two friends, mostly on phones"), [WHAT MATTERS MOST] (e.g. "tasks must still be there after a refresh").
Don't write any code yet. Help me write a one-page spec for a new feature and save it as SPEC.md in the project.
The feature: [THE FEATURE]
Who uses it: [WHO USES IT]
What matters most: [WHAT MATTERS MOST]
First, read the project so the spec fits what's already there. Then write SPEC.md with these parts:
1. Goal: one sentence on what the feature does and who it's for.
2. Acceptance criteria: a numbered list. Each line is one thing a person does and what they should see, written so it's clearly yes or no. For example: "I type a task and press Add, and it appears at the top of the list."
3. Edge cases: 3 to 5 tricky situations, such as an empty input, a very long input, a double-click or a page refresh, each with what should happen.
4. Out of scope: things this feature will not do yet.
5. Open questions: anything you'd otherwise have to guess. List them. Don't answer them for me.
Keep it to one page and use plain words. Show me SPEC.md, then stop and wait for me to answer the open questions.
Tips to customize: Answer every open question before you go on. Each guess the agent makes there is a place it can build the wrong thing. Anthropic's Claude Code best-practices guide suggests a similar habit: once SPEC.md exists, start a fresh session to build from it. In Claude Code, /clear starts fresh. In Cursor, you can also press Shift+Tab in the agent input to switch to Plan Mode, which asks clarifying questions and writes a plan you can edit before anything gets built. Not sure what you want yet? Start with Say What You Mean, Prompt 1.1, then come back here.
1.2 Make Every Line Checkable
Untested: not yet run against a model.
Use this when you have a spec, plan or feature request, but some lines are vague, like "make it user-friendly" or "it should be fast." It's for rewriting each line into a yes-or-no check, and flagging the ones nobody can test.
Fill in: [MY SPEC FILE] (e.g. "SPEC.md", or paste the text).
Don't write any code. Read [MY SPEC FILE] and make every line checkable.
For each line in the spec:
1. Say whether someone could check it with a clear yes or no. Mark it "checkable" or "vague."
2. For each vague line, rewrite it as one or more checks. Use real numbers and real actions. For example, turn "loads fast" into "the task list shows within 2 seconds on my phone," and "easy to use" into "a new user can add their first task without help."
3. For each check, say how it would be tested: an automatic test, a browser test that clicks through it, or a check I do by hand. Prefer automatic tests where you can.
4. Point out anything missing, such as what happens when something fails, when the user isn't logged in, or when a list is empty.
5. If a line can't be turned into a check, ask me what I really mean. Don't invent an answer.
Show me the changes as a before-and-after list. Update the file only after I say OK.
Tips to customize: Words to watch for: nice, clean, fast, simple, modern, intuitive, robust, and "should handle errors." Each one hides a decision you haven't made yet. Any number you pick for "fast" is a choice, not a fact, so pick one you'd actually be happy with. Checks you'll do by hand are fine, but keep a short list so you remember to do them.
Section 2: Tests Before Code
2.1 Turn the Spec Into Failing Tests
Untested: not yet run against a model.
Use this when your spec is ready and you want tests written before any feature code. It's for one test per acceptance criterion, run once so you can see them all fail, then saved as a commit.
Fill in: [MY SPEC FILE] (e.g. "SPEC.md"), [MY TEST COMMAND] (e.g. "npm test", or "please find it").
We're doing test-driven development. Write the tests first. Do not write any feature code in this step.
Spec: [MY SPEC FILE]
Test command: [MY TEST COMMAND]
Please:
1. Find how this project runs tests. If it has no test setup, suggest the simplest one for this project, explain it in two lines, and wait for my OK before you install anything.
2. Write at least one test for every numbered acceptance criterion and every edge case. Name each test after its criterion number, like "AC3: a task stays after refresh."
3. For anything a person does on screen, like clicking a button, write a browser test that really clicks it and checks what appears.
4. Test real behavior. Don't build fake versions of the feature to test against, and don't test parts that don't exist yet with mocks.
5. Run the tests and show me the output. They should fail, because the feature isn't built. If any test passes, tell me why, because it may not be testing anything.
6. Give me a table: criterion number, test name, what it checks.
Then stop. Don't write feature code until I say so.
Tips to customize: Cursor's agent best-practices guide lays out this same order: write the tests, run them and confirm they fail, commit them, then ask for code that passes them without changing them. Once the table looks right, commit the tests (ask the agent: "commit the tests with a short message"). That commit makes it easy to spot any later change to a test. Before you commit, run Prompt 2.2 so you know the tests are worth keeping.
2.2 Check That the Tests Test Real Behavior
Untested: not yet run against a model.
Use this when your tests pass (or are about to) but you don't trust them, or the app is broken even though everything is green. It's for finding tests that would pass even if the feature didn't work.
Fill in: [MY SPEC FILE] (e.g. "SPEC.md"), [THE TEST FILES] (e.g. "tests/tasks.test.ts", or "all of them").
Don't change any code or tests yet. Review the tests in [THE TEST FILES] against [MY SPEC FILE], and tell me which ones I can trust.
For each test, answer:
1. Which acceptance criterion or edge case does it check? Name the number, or say "none."
2. If the feature were broken in the most obvious way (the button does nothing, nothing is saved, the wrong user sees the data), would this test fail? Say yes or no, and why.
3. Does it check what the user sees or what gets saved, or only that some code ran?
4. Does it use mocks or fake data in a way that hides a real problem?
Then list:
- criteria with no test at all
- tests that would pass even if the feature were broken
- tests that check something the spec doesn't ask for
Suggest one fix for each problem. Wait for my OK before you change anything.
Tips to customize: A quick way to see if a test is real: ask the agent to break the feature on purpose ("comment out the save, run the tests, show me which ones fail, then undo it"). A test that still passes isn't checking that part. Common culprits: tests that only check a button exists, not that clicking it does something, and tests where both the real code and the expected answer come from the same fake.
Section 3: Build Until It's Really Done
3.1 Build Until Every Test Passes, Without Touching the Tests
Untested: not yet run against a model.
Use this when the failing tests are committed and you're ready for the agent to build the feature. It's for building in small steps until every test passes, with a hard rule against editing the tests to get there.
Fill in: [MY SPEC FILE] (e.g. "SPEC.md"), [MY TEST COMMAND] (e.g. "npm test"), [OTHER CHECKS] (e.g. "npm run build and npm run lint", or "none").
Now build the feature in [MY SPEC FILE] so that every test passes.
Test command: [MY TEST COMMAND]
Other checks that must also pass: [OTHER CHECKS]
Rules:
1. Don't change, skip, delete or loosen any test. If you think a test is wrong, stop and tell me which one and why, and wait for my answer.
2. Don't build anything the spec lists as out of scope.
3. Work in small steps. After each step, run the tests and tell me how many pass and which still fail.
4. Don't hard-code answers just to make a test pass. The code has to work for real users, not only for the test data.
5. You're done only when every test and every other check passes. Then show me the full output of the last run.
At the end, list every file you changed, with one plain sentence about each.
Tips to customize: Before you accept the work, check that the tests haven't changed since you committed them. Ask: "show me any changes to test files since the tests commit." It should be empty. In Claude Code, the /goal command sets a condition (like "all tests pass and the build is clean") that a separate model checks after every turn, and Claude keeps working until it's met. That's mostly useful for long runs you aren't watching. To make Claude Code refuse to finish while tests fail, see Claude Code Guardrails, Prompt 3.4.
3.2 Show Me Proof, Not "Done"
Untested: not yet run against a model.
Use this when the agent says the feature is finished. It's for getting real evidence for every acceptance criterion, such as test output, the steps it clicked through and screenshots, instead of a cheerful summary.
Fill in: [MY SPEC FILE] (e.g. "SPEC.md").
Before I accept this, prove every line of [MY SPEC FILE] works. Don't change any code in this step.
For each numbered acceptance criterion and each edge case:
1. Show the evidence: the test that covers it and its result from a fresh run, or the exact steps you clicked through in the running app and what appeared. Add a screenshot if you can take one.
2. Mark it "proven," "not proven" or "couldn't check," and say why.
3. If you didn't run something, say so plainly. Don't describe what "should" happen.
Then give me a short list of checks to do by hand myself, including one that should fail (like submitting an empty form) to show the error handling works.
End with: anything still not done, and anything you're unsure about.
Tips to customize: Anthropic's Claude Code best-practices guide says to ask for evidence, meaning the command Claude ran and its output, because "All tests pass" on its own tells you very little. It also mentions a /verify command that has Claude build and run the app and look at the result, which can catch problems tests miss. Cursor's best-practices guide says its agent can control a browser to take screenshots and test your app. Whatever your tool, do the by-hand checks yourself. Clicking the main button once yourself is the fastest way to catch the "nothing happens" bug.
3.3 Have a Fresh Reviewer Check It Against the Spec
Untested: not yet run against a model.
Use this when the tests pass and you want a second opinion before you accept the work. It's for a review that compares the changes to the spec only, from a reviewer that didn't write the code, and skips style nitpicks.
Fill in: [MY SPEC FILE] (e.g. "SPEC.md").
Review the changes for this feature against [MY SPEC FILE]. Use a fresh reviewer that didn't write the code if you can, such as a subagent. Don't change anything.
Check:
1. Every numbered acceptance criterion is actually built, not just tested.
2. Every edge case in the spec has a test.
3. Nothing out of scope was added.
4. No test was changed, skipped or loosened to make it pass.
Report only gaps that affect whether the feature works as the spec says. Skip style, naming and "nice to have" ideas.
Give me a numbered list of gaps, each with the criterion number and one suggested fix. If there are none, say so.
Tips to customize: Keep the "skip style" line. Anthropic's best-practices guide warns that a reviewer asked to find problems will always find something, and fixing every finding piles on extra code. In Claude Code in the terminal, /code-review reviews your changes in a fresh subagent that never saw your conversation. In Cursor, Agent Review in the Source Control tab compares your changes against your main branch. Fix real gaps with Prompt 3.1, then run the review once more.
Section 4: Big Features, Small Specs
4.1 Split a Big Feature Into Small Specs
Untested: not yet run against a model.
Use this when a feature is too big to build in one go, like "add accounts, teams and billing." It's for cutting it into small specs that each work on their own, in the right order, with a few checks each.
Fill in: [THE BIG FEATURE] (e.g. "people can create teams, invite friends by email, and share a task list"), [WHAT I WANT FIRST] (e.g. "one person can create a team and see it").
Don't write any code. Help me split a big feature into small specs I can build one at a time.
The big feature: [THE BIG FEATURE]
What I want working first: [WHAT I WANT FIRST]
Please:
1. Read the project, then split the feature into 3 to 7 small pieces. Each piece should be something I can use and check on its own when it's done.
2. Order them so each piece builds on the last one, and the first piece is the smallest useful version.
3. For each piece, write a mini spec: a one-line goal, 2 to 5 acceptance criteria written as yes-or-no checks, and what it leaves for later.
4. Point out any piece that changes the database or logins. Those need extra care and a backup first.
5. Save it as SPECS.md, with a checkbox next to each piece.
Show me the list and wait for my OK.
Tips to customize: If a piece has more than 5 acceptance criteria, it's probably two pieces. Ask the agent to split it again. In Cursor, Plan Mode can save a plan to your project's .cursor/plans/ folder with Save to workspace, which makes it easy to pick up interrupted work later. In either tool, keeping SPECS.md in your project means any new chat can read where you're up to.
4.2 One Small Spec at a Time
Untested: not yet run against a model.
Use this when you have a list of small specs and want to build the next one. It's for a short routine the agent repeats for each piece: tests first, build until they pass, prove it, tick it off, then stop.
Fill in: [MY SPECS FILE] (e.g. "SPECS.md"), [MY TEST COMMAND] (e.g. "npm test").
Let's build the next unchecked piece in [MY SPECS FILE]. Only that piece.
Test command: [MY TEST COMMAND]
Follow these steps and stop where I say:
1. Tell me which piece you're building and repeat its acceptance criteria back to me.
2. Write the tests for this piece only. Run them and show me that they fail. Stop and wait for my OK.
3. After my OK, build until this piece's tests pass, plus every earlier test. Don't change any test. If one looks wrong, stop and ask me.
4. Show me the final test output, and give me 2 or 3 checks to do by hand.
5. After I confirm, tick the piece's checkbox in [MY SPECS FILE] and suggest a short commit message.
Don't start the next piece. I'll ask for it.
Tips to customize: Start a fresh chat for each piece (in Claude Code, /clear; in Cursor, a new chat). The specs file carries what matters, and a clean start keeps old mistakes from tagging along. Running every earlier test in step 3 is how you find out right away if a new piece broke an old one. If a piece goes badly, Cursor's Plan Mode docs suggest reverting the changes, making the plan more specific and running it again, which is often faster than fixing it with follow-up prompts.
Get new free packs in your inbox
Optional. Every prompt here is free, and you don't need to sign up to use any of them. We email when we add new free packs. Unsubscribe anytime.
Thanks, you're on the list. Watch your inbox for the next prompt drop.