Red/green TDD

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Appending 'use red/green TDD' to coding agent prompts makes them verify their own work with failing-then-passing tests, reducing broken or unused code.

Read this as

Simon Willison recommends a short phrase, 'use red/green TDD', for getting better results from AI coding tools. Test-driven development is a way of writing software where the tests are written first, confirmed to fail, and then the code is written until they pass. This stops AI assistants from producing code that does not work or that is never used. He demonstrated it with simple prompts to Claude and ChatGPT.

Simon Willison argues that telling coding agents to 'use red/green TDD' is a cheap, effective way to reduce the two most common AI coding failures: code that does not work and unnecessary code that never gets used. The technique also builds a test suite that protects existing features as projects grow. Teams using agents like Claude Code or OpenAI Codex can adopt it immediately with a prompt change, though no cost or productivity figures are given.

Willison's 'red/green TDD' pattern instructs an agent to write tests first, verify they fail (red), then implement until they pass (green). Confirming the red phase is essential: without it, a test may pass already and exercise nothing. It mitigates agents producing non-functional or unnecessary code while accumulating a regression suite. He tested the prompt with Claude and ChatGPT, noting ChatGPT needed 'Use your code environment' appended or it never executed the tests.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Simon Willison Claude ChatGPT Claude Code OpenAI Codex

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading