/superpowers-optimized:test-driven-developmentfrom superpowers-optimized
Enforces writing failing tests before production code for any behavior change. Covers the red-green-refactor cycle, test infrastructure setup, and verification steps.
Ships in superpowers-optimized. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
Scope: behavior, not appearance. A purely visual change — styling, layout, spacing, static copy — has no behavior a unit test can pin, and a test written for it cannot fail for a meaningful reason. Verify it by rendering the result (run the app, take a screenshot) per verification-before-completion, and say that is how you checked. The moment the change carries logic — a condition, a calculation, a state change, data that drives what is shown — it is behavior, and the Iron Law applies.
RED: Write one small failing test for one behavior.
VERIFY RED: Run the test. Confirm it fails for the expected reason (not a syntax error or import issue).
GREEN: Write the minimum production code to make the test pass. Nothing more.
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.
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:
jest.config.*, vitest.config.*, pytest.ini, pyproject.toml [tool.pytest], go.mod, Cargo.toml, .rspec, phpunit.xmlnpm test, yarn test, make test, or equivalentDo 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. |
test_expired_token_returns_401).verification-before-completion).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.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
24 skills in this plugin
/brainstormingUse when the user wants new features, behavior changes, refactoring with new capabilities, or architecture decisions and no approved design exists yet. Produces a design before any code is written — in the conversation for small changes, as an approved spec document for larger work. Triggers on: "build this", "add a feature", "I want to change", "how should we", "design", "architect", "new project", "refactor", "we need to add/build/create", "implement a new". Routed by using-superpowers, or invoke directly via /brainstorming.
/claude-md-creatorCreates minimal, high-signal CLAUDE.md and AGENTS.md context files based on empirical best practices. Invoke on /init command, "create CLAUDE.md", "update CLAUDE.md", "write AGENTS.md", or "set up Claude Code for this project". Also invoked by brainstorming when repo lacks a context file. tools: Read, Glob, Grep, Bash, Edit
/context-managementUse in long or noisy sessions to persist durable state across session boundaries via state.md. Also generates project-map.md when asked to map the project. Triggers on: user explicitly asks to "save state", "compress context", "map this project", "generate project map", "create project map", cross-session handoff needed, or repeated failures indicate context is getting stale.
/deliberationUse BEFORE brainstorming when facing a complex architectural, technology, or design decision where the options are not yet well-defined or the problem itself may need reframing. Assembles named stakeholder perspectives that each speak once without debate, then surfaces where they converge and where real tension remains — without forcing a premature choice. Triggers on: "should we use X or Y", "not sure which approach", "evaluate these options", "what are the trade-offs between", "help me think through this decision", "architecture decision", "technology choice". Routed by using-superpowers before brainstorming when the decision space is unclear.
/dependency-managementUse when updating, migrating, or auditing project dependencies: upgrading packages, fixing security vulnerabilities (CVEs), resolving breaking changes, migrating to new major versions, or auditing outdated dependencies. Enforces incremental updates with verification at each step. Distinct from systematic-debugging (which fixes application bugs) and refactoring (which restructures application code). Triggers on: "update dependencies", "upgrade packages", "npm update", "pip upgrade", "outdated", "vulnerability", "CVE", "security advisory", "breaking change", "migration guide", "dependency conflict", "peer dependency", "update to latest", "audit dependencies", "npm audit", "dependabot". Routed by using-superpowers, or invoke directly via /dependency-management.
/dispatching-parallel-agentsUse when 2+ tasks are independent and can run concurrently without file or state conflicts or sequential dependencies. Triggers on: "run these in parallel", "do these at the same time", plans with independent tasks, when subagent-driven-development identifies parallelizable work.
npx claudepluginhub repozy/superpowers-optimized --plugin superpowers-optimizedOther plugins' skills for the same job