brainstorming
MUST USE when the user wants new features, behavior changes, refactoring with new capabilities, or architecture decisions and no…
MUST USE for any behavior change: write failing tests before production code. No exceptions. Triggers on: "TDD", "write tests first", any implementation task, bug fix needing regression tests, behavior changes during execution. Routed by using-superpowers, or invoke directly via
$ npx -y skills add REPOZY/superpowers-optimized --skill test-driven-development --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/test-driven-developmentContext preview
The summary Claude sees to decide when to auto-load this skill.
MUST USE for any behavior change: write failing tests before production code. No exceptions. Triggers on: "TDD", "write tests first", any implementation task, bug fix needing regression tests, behavior changes during execution. Routed by using-superpowers, or invoke directly via
name: test-driven-development description: > MUST USE for any behavior change: write failing tests before production code. No exceptions. Triggers on: "TDD", "write tests first", any implementation task, bug fix needing regression tests, behavior changes during execution. Routed by using-superpowers, or invoke directly via /test-driven-development.
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.
1. **RED**: Write one small failing test for one behavior. 2. **VERIFY RED**: Run the test. Confirm it fails **for the expected reason** (not a syntax error or import issue). 3. **GREEN**: Write the **minimum** production code to make the test pass. Nothing more. 4. **VERIFY GREEN**: Run the target test plus the suite for the module you changed. Confirm pass. Do not run the whole repo suite on every cycle — that belongs at the end of the task, scoped per `verification-before-completion`.
**Report every failure the run shows, including ones you did not cause.** Scope bounds which command you run; it never bounds what you report. If the module suite goes red on a test your change did not touch, name that test in your report as a pre-existing failure. A red test you watched scroll past and did not mention is a report falsified by omission — and the next person to run the suite inherits it as your bug. 5. **REFACTOR**: Improve structure without changing behavior. Tests must stay green.
Repeat per behavior. Never skip VERIFY steps.
Before writing the first test, verify the project has a test runner:
1. Check for test config: `jest.config.*`, `vitest.config.*`, `pytest.ini`, `pyproject.toml [tool.pytest]`, `go.mod`, `Cargo.toml`, `.rspec`, `phpunit.xml` 2. Check for test script: `npm test`, `yarn test`, `make test`, or equivalent 3. If no test infrastructure exists:
Do not skip this step — a "failing test" that fails because the runner doesn't exist teaches nothing.
**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. |
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.
The production-grade fork of obra/superpowers — same trusted workflow, dramatically leaner, safer, and more intelligent.
MUST USE when the user wants new features, behavior changes, refactoring with new capabilities, or architecture decisions and no…
Creates minimal, high-signal CLAUDE.md and AGENTS.md context files based on empirical best practices. Invoke on /init command,…
Use in long or noisy sessions to persist durable state across session boundaries via state.md. Also generates project-map.md when…
Use BEFORE brainstorming when facing a complex architectural, technology, or design decision where the options are not yet…
MUST USE when updating, migrating, or auditing project dependencies: upgrading packages, fixing security vulnerabilities (CVEs),…
Use when 2+ tasks are independent and can run concurrently without file or state conflicts or sequential dependencies. Triggers…