wiki / raw / simon-willison-red-green-tdd-2026

Red/green TDD

updated 2026-08-22

Original source: https://simonwillison.net/guides/agentic-engineering-patterns/red-green-tdd/ SHA256: a578765f0bee9430776c214d892afe9fd74dd1b9107a24305f7dd89b4d6e1810

Red/green TDD

Simon Willison’s Weblog Subscribe Sponsored by: Teleport — AI agents don’t sleep and will try anything to achieve their goal. Teleport explains how to deploy AI safely, starting with an isolated ephemeral trusted runtime.

Guides > Agentic Engineering Patterns

Red/green TDD

“Use red/green TDD” is a pleasingly succinct way to get better results out of a coding agent.

TDD stands for Test Driven Development. It’s a programming style where you ensure every piece of code you write is accompanied by automated tests that demonstrate the code works.

The most disciplined form of TDD is test-first development. You write the automated tests first, confirm that they fail, then iterate on the implementation until the tests pass.

This turns out to be a fantastic fit for coding agents. A significant risk with coding agents is that they might write code that doesn’t work, or build code that is unnecessary and never gets used, or both.

Test-first development helps protect against both of these common mistakes, and also ensures a robust automated test suite that protects against future regressions. As projects grow the chance that a new change might break an existing feature grows with them. A comprehensive test suite is by far the most effective way to keep those features working.

It’s important to confirm that the tests fail before implementing the code to make them pass. If you skip that step you risk building a test that passes already, hence failing to exercise and confirm your new implementation.

That’s what “red/green” means: the red phase watches the tests fail, then the green phase confirms that they now pass.

Every good model understands “red/green TDD” as a shorthand for the much longer “use test driven development, write the tests first, confirm that the tests fail before you implement the change that gets them to pass”.

Example prompt:

← Subagents First run the tests →

This is a chapter from the guide Agentic Engineering Patterns.

Chapters in this guide

Principles What is agentic engineering? Writing code is cheap now Hoard things you know how to do AI should help us produce better code Anti-patterns: things to avoid Working with coding agents How coding agents work Using Git with coding agents Subagents Testing and QA Red/green TDD First run the tests Agentic manual testing Understanding code Linear walkthroughs Interactive explanations Annotated prompts GIF optimization tool using WebAssembly and Gifsicle Adding a new content type to my blog-to-newsletter tool Appendix Prompts I use testing 93 tdd 5 coding-agents 240 ai-assisted-programming 403 agentic-engineering 59

Created: 23rd February 2026 Last modified: 28th February 2026 6 changes

Previous: Subagents

Next: First run the tests

Disclosures Colophon © 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026