| name | test-driven-development |
| description | Write the test first, watch it fail, write minimal code to pass |
| version | 3.2.0 |
| category | testing |
| author | Jesse Vincent |
| license | MIT |
| source | https://github.com/obra/superpowers-skills/tree/main/skills/testing/test-driven-development |
| progressive_disclosure | {"entry_point":{"summary":"Enforce test-first development with strict RED/GREEN/REFACTOR cycle. Never write implementation before failing test.","when_to_use":"When implementing any feature or bugfix, before writing implementation code. Always for new features, bug fixes, refactoring, and behavior changes.","quick_start":"1. Write failing test 2. Watch it fail (verify) 3. Write minimal code to pass 4. Watch it pass (verify) 5. Refactor if needed 6. Repeat"},"references":["workflow.md","examples.md","philosophy.md","anti-patterns.md","integration.md"]} |
| context_limit | 800 |
| tags | ["tdd","testing","red-green-refactor","test-first"] |
| effort | high |
Test-Driven Development (TDD)
Overview
Write the test first. Watch it fail. Write minimal code to pass.
Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.
This skill enforces strict test-first development following the RED/GREEN/REFACTOR cycle. Violating the letter of the rules is violating the spirit of the rules.
When to Use This Skill
Always:
- New features
- Bug fixes
- Refactoring
- Behavior changes
Exceptions (ask human partner):
- Throwaway prototypes
- Generated code
- Configuration files
Thinking "skip TDD just this once"? Stop. That's rationalization.
The Iron Law
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? Delete it. Start over.
No exceptions:
- Don't keep it as "reference"
- Don't "adapt" it while writing tests
- Delete means delete
Core Principles
- RED: Write a failing test first
- GREEN: Write minimal code to make test pass
- REFACTOR: Improve code while keeping tests green
- NEVER: Write implementation before tests
Quick Start
The RED/GREEN/REFACTOR Cycle
RED → Verify RED → GREEN → Verify GREEN → REFACTOR → Repeat
- RED: Write one minimal test showing desired behavior
- Verify RED: Run test, confirm it fails for right reason
- GREEN: Write simplest code to pass test
- Verify GREEN: Run test, confirm it passes
- REFACTOR: Clean up while keeping tests green
- Repeat: Next test for next feature
Cycle Details
RED: Write one minimal test (one behavior, clear name, real code)
Verify RED: MANDATORY - watch it fail for right reason
GREEN: Write simplest code to pass (no extras)
Verify GREEN: MANDATORY - watch it pass, all tests pass
REFACTOR: Clean up while keeping tests green (optional)
Navigation