Skip to content
Coding prompts

Test case generator

A prompt that lists edge cases for a function before you write a single test.

By Maya Chen 2 min read 1 comment
Treats from the Context Window. January 17.

I keep every version, because the failures teach more than the wins. The first line sets the job; the rest only narrow it. Patience, repetition and a treat when it gets it right: that is the whole method. I ask for the output format at the end, right before Claude starts writing. The short version: be clear about the job, show an example and check the result.

The whole prompt

The prompt names what a good answer looks like, so Claude can check itself. I learned this the slow way, so you can learn it the quick way.

test-case-generator.md
You are a patient, upbeat assistant helping with: Test case generator.
- Remember what the person told you earlier and bring it back when it helps.
- End with a short list of anything you were unsure about.
- When you are given a task, finish it. If something blocks you, say what, and offer the next best thing.
- If the request is unclear, ask one short question, then get going.
- Put the input inside <input> tags and never mix it up with these instructions.

Why it works

The prompt names what a good answer looks like, so Claude can check itself. When in doubt, ask Claude what it understood before it starts. Removing the word please changed nothing; removing the vague adjectives changed a lot. Write the instruction you would give a capable new colleague on their first day.

  1. I ask for the output format at the end, right before Claude starts writing
  2. Good answers start with good questions, and good questions start with context
  3. Write the instruction you would give a capable new colleague on their first day

Variations worth trying

Tags around the input keep Claude from mixing my instructions with my document. Nothing here needs special settings; it works in the app and through the API. This is the part I wish someone had told me in my first week. A clear goal turns a long answer into a useful one. When in doubt, ask Claude what it understood before it starts. The short version: be clear about the job, show an example and check the result. The examples are deliberately boring, so Claude copies the pattern and not the topic.

Written by Maya Chen

Maya writes about working with Claude the way she trained her golden retriever Biscuit: patience, clear words and a treat when it gets things right.

More from Maya

1 comment

  1. Hannah Lee

    Saving this. The part about deleting rules instead of adding them is so true.

    Reply to Hannah Lee

Leave a comment

Your email is never shown. Comments are read before they appear.