Enforces Test-Driven Development: write failing tests first, then minimal code to pass, refactor. For implementation tasks, bug fixes needing regression tests, behavior changes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/superpowers-optimized:test-driven-developmentThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write failing tests first. Then write minimal code to pass.
Write failing tests first. Then write minimal code to pass.
No production code before a failing test proves the behavior is missing.
If code was written first, delete it and restart from a test. No exceptions.
This is the hardest rule to follow and the most important. Every rationalization to skip it leads to untested behavior that breaks later.
Repeat per behavior. Never skip VERIFY steps.
Wrong — code first:
1. Write the handler function
2. Write tests to verify it works
3. All tests pass on first run ← this means the tests prove nothing
Right — test first:
1. Write test: POST /users returns 201 with valid body
2. Run test → FAILS (handler doesn't exist yet) ← good
3. Write minimal handler to return 201
4. Run test → PASSES ← test proved the behavior was missing, now it works
5. Refactor handler if needed, tests stay green
| Temptation | Why it fails |
|---|---|
| "This is too simple to test" | Simple code has the longest lifespan. It will be changed by someone who doesn't know the intent. |
| "I'll write tests after" | After never comes. And tests written after pass immediately, proving nothing. |
| "I'm just refactoring, no new behavior" | If behavior doesn't change, existing tests must stay green. Run them. |
| "Tests slow me down" | Tests save you from debugging sessions that take 10x longer. |
| "The type system catches this" | Types catch shape errors, not logic errors. Test the logic. |
| "I need to see the shape of the code first" | Spike in a scratch file. Then delete it and TDD the real implementation. |
test_expired_token_returns_401).For complex, high-risk, or hard-to-test behavior, go beyond basic unit tests while still following RED-GREEN-REFACTOR:
Choose appropriate frameworks and libraries for the current stack. Write tests that are fast, deterministic, and maintainable.
systematic-debugging to find root cause before writing the fix test.verification-before-completion before success claims.testing-anti-patterns.md when introducing heavy mocking.npx claudepluginhub repozy/superpowers-optimizedEnforces RED-GREEN-REFACTOR TDD cycle: write a failing test first, then minimal code to pass, then refactor. Use when implementing features or fixing bugs during the implement phase.
Enforces strict Test-Driven Development (TDD): write failing test first for features, bug fixes, refactors before any production code.