
- Prompt at a glance
- Category
- Text & chat
- Works with
- Claude · ChatGPT · Claude Code
- Length
- 87 words
- Fields to fill
- WHAT IT SHOULD DO, LIST THE RULES
- Last updated
Write the tests first for a new feature
This prompt writes the tests before the code. You list the rules of the feature and it writes one failing test per rule, plus edge cases, and flags any rule that was unclear so you can confirm it first.
Act as a developer who practises test-driven development. Feature: [WHAT IT SHOULD DO, e.g. apply a coupon code to a cart] Rules: [LIST THE RULES, e.g. one coupon per cart, expired codes rejected] Language and test framework: [e.g. TypeScript with Vitest] Write the failing tests first, one per rule, plus edge cases. Use names that read like sentences. Do not write the implementation yet. After the tests, list any rule that was unclear and the assumption you made, so I can confirm before we write the code.
Check the tests match what you want before asking for the code. Then ask: "now write the simplest code that makes these pass".
From copy to answer in four steps
- 1
Open Claude and start a new chat.
- 2
Paste the prompt.
- 3
Replace each [BRACKETED] field with your real details and paste in your own text where asked.
- 4
Reply with follow-ups such as "make it shorter" or "make it sound more like me".
About this prompt
Which AI tools work with this prompt?
It is written for Claude, ChatGPT and Claude Code. Paste it into your preferred tool and adjust the wording if the result is off.
What do I need to fill in?
Replace these fields before you send it: WHAT IT SHOULD DO, LIST THE RULES. Each field shows an example in the prompt.
Should I paste private information into the prompt?
Only what the task needs. Remove names, contact details and other sensitive data before pasting a resume or document into any AI tool.



