tdd-red-green-refactor
Installation
SKILL.md
One-line summary
The TDD cycle: write a failing test (red), write the minimum code to pass it (green), refactor while staying green. Repeat one tiny step at a time. The discipline is in the order and the minimum — both are easy to skip.
When to use this skill
- Building new behavior in code where you can articulate the desired outcome as a test.
- Bug fixing — write the regression test first (see
tdd-regression-test), then fix. - Designing an API from the consumer's side — the first test forces you to consider what calling code wants.
- Working in a codebase with a healthy test suite where TDD adds little friction.
When NOT to use this skill
- Pure exploration / spike work where you don't yet know the shape of what you're building. Spike first, then test-drive the rewrite.
- Throwaway scripts, one-shot utilities, or rapid prototyping that won't be maintained.
- UI tweaks where the cycle of "write a test, change a pixel, see the test pass" is more pain than benefit.
- Codebases with no existing test infrastructure where setting up the harness for one feature is disproportionate. Add tests; don't pretend you're doing TDD if you can't.