AdvancedCoding AgentsFree prompt

Turn a Coding Agent into a Test-First TDD Partner

Direct a coding agent to write failing tests first, then implement just enough code to pass them.

Get higher-quality, regression-resistant changes by enforcing a red-green-refactor loop with the agent.

TDDtestingcoding agentred-green-refactorquality

At a glance

Access

Free prompt

Open to copy — no account or payment needed.

Prompt objective

Get higher-quality, regression-resistant changes by enforcing a red-green-refactor loop with the agent.

Real use case

A team's coding agent writes implementation and tests together, so the tests just rubber-stamp whatever it built. They want genuine test-first discipline.

Customize these fields first

DESCRIBE BEHAVIORE.G. TYPESCRIPT + VITESTPOINT TO EXAMPLES

Replace the placeholders with your own context before you run the prompt. That usually improves the first output more than adding more instructions later.

Prompt

You are a test-driven development partner working as a coding agent. Follow strict red-green-refactor.

Feature to build: [DESCRIBE BEHAVIOR]
Language/test framework: [E.G. TYPESCRIPT + VITEST]
Existing patterns to follow: [POINT TO EXAMPLES]

Loop, one behavior at a time:
1. RED: write a single failing test that specifies the next smallest behavior. Show the test and explain what it asserts. Run it and confirm it fails for the right reason.
2. GREEN: write the minimum implementation to make that test pass — no extra features. Run the test and confirm it passes.
3. REFACTOR: improve naming/structure without changing behavior; keep all tests green.
4. Restate which behaviors remain, then repeat.

Rules: never write implementation ahead of a test; keep each step tiny; do not delete or weaken a test to make it pass; report the test count and pass/fail after each loop. Start with the first RED test now.

Open directly in an AI — the text is pre-filled:

How to use this prompt

  1. 1Replace the key placeholders first: DESCRIBE BEHAVIOR, E.G. TYPESCRIPT + VITEST, POINT TO EXAMPLES.
  2. 2Replace any bracketed placeholders like [this] with your own context.
  3. 3Add extra background information when you want more tailored results.
  4. 4Combine multiple prompts in one conversation when you need a richer output.
  5. 5Save your best-performing prompts so they are easy to reuse later.

Next best step

Open the guide first, then branch only if you still need more.

A guide for technical builders choosing between prompts, coding workflows, and agent-based implementation.

If this prompt is close but not quite right, generate variants next. If the job is recurring, move into the course library after the guide.

Related prompts

View all

Explore other prompt categories

Move sideways into adjacent libraries when the current category is not the full answer.

Every prompt here is free. The course teaches the thinking behind them.

Copy as many prompts as you like. When you want to move from single prompts to a repeatable AI workflow, Learn AI in 30 Days walks through it, one day at a time.

Get the courseSee the 30-day curriculum first

Buy the course once ($15/$20 by length), or go all-access for $10/mo with a verifiable certificate.