| name | tdd-obra |
| description | Test-Driven Development methodology enforcing RED-GREEN-REFACTOR cycle. Use for writing tests first, preventing regression, and ensuring code correctness. Based on obra/superpowers. |
| type | reference |
| version | 1.0.0 |
| category | development |
| last_updated | "2026-01-19T00:00:00.000Z" |
| source | https://github.com/obra/superpowers |
| related_skills | ["systematic-debugging","writing-plans","subagent-driven"] |
| capabilities | [] |
| requires | [] |
| see_also | [] |
| tags | [] |
Test-Driven Development (TDD) Skill
Overview
This skill enforces strict test-first development methodology. The core principle: "Write the test first. Watch it fail. Write minimal code to pass." If you didn't watch the test fail, you don't know if it tests the right thing.
Quick Start
- Write one failing test - Minimal test demonstrating desired behavior
- Verify RED - Run test, confirm it fails (not errors)
- Write minimal code - Just enough to pass
- Verify GREEN - All tests pass
- Refactor - Clean up while maintaining green
When to Use
- Starting new features or modules
- Fixing bugs (write failing test reproducing bug first)
- Refactoring existing code
- Any production code development
- Code review verification
Iron Law
Produce no production code without a failing test first.
Any code written before tests must be deleted entirely - no exceptions for keeping it as reference material.
Red-Green-Refactor Cycle
RED Phase
Write one minimal test demonstrating desired behavior:
- Use clear, descriptive test names
- Test real behavior, not mocks
- One assertion focus per test
Verify RED (Mandatory)
Run tests and confirm:
- Test fails (not errors)
- Failure message matches expectations
- Failure occurs because feature is missing, not due to typos
GREEN Phase
Write simplest code passing the test:
- No over-engineering or feature additions
- No refactoring other code
- Implement only what satisfies the test
Verify GREEN (Mandatory)
Confirm:
- Target test passes
- All existing tests remain passing
- No errors or warnings appear
REFACTOR Phase
After green only, clean up implementation:
- Remove duplication
- Improve naming
- Extract helpers
- Maintain all passing tests
Why Tests-After Fails
| Approach | Validates |
|---|
| Tests-first | "What should this do?" |
|