From sw
Executes a full red-green-refactor TDD cycle with configurable coverage thresholds and refactoring triggers. Supports single-phase execution via --phase flag.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sw:tdd-cycleThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
`sw:tdd-cycle` supports a `--phase` flag to run a single phase of the RED → GREEN → REFACTOR cycle. Omitting the flag (or passing `--phase all`) runs the full cycle.
sw:tdd-cycle supports a --phase flag to run a single phase of the RED → GREEN → REFACTOR cycle. Omitting the flag (or passing --phase all) runs the full cycle.
| Flag | Behavior |
|---|---|
--phase all (default) | Full RED → GREEN → REFACTOR cycle. Same as omitting the flag. |
--phase red | Runs only the RED phase — write failing tests. See Phase 2 below. |
--phase green | Runs only the GREEN phase — write minimal code to make tests pass. See Phase 3 below. |
--phase refactor | Runs only the REFACTOR phase — improve code quality with tests as safety net. See Phase 4 below. |
The following deprecated single-phase skills are aliased in marketplace.json to route through sw:tdd-cycle --phase <x>:
/sw:tdd-red → /sw:tdd-cycle --phase red/sw:tdd-green → /sw:tdd-cycle --phase green/sw:tdd-refactor → /sw:tdd-cycle --phase refactorThe aliases emit a one-time migration warning pointing users to the canonical --phase form. The three tdd-* skills are scheduled for removal in v1.3.0 — see .specweave/docs/internal/specs/skill-deprecation-policy.md.
# Full cycle (default)
sw:tdd-cycle "user authentication"
# Single phases
sw:tdd-cycle --phase red "user authentication"
sw:tdd-cycle --phase green "user authentication"
sw:tdd-cycle --phase refactor "user authentication"
# Same as default — explicit
sw:tdd-cycle --phase all "user authentication"
Skill Memories: If .specweave/skill-memories/tdd-cycle.md exists, read and apply its learnings.
Execute a comprehensive Test-Driven Development (TDD) workflow with strict red-green-refactor discipline:
[Extended thinking: This workflow enforces test-first development through coordinated agent orchestration. Each phase of the TDD cycle is strictly enforced with fail-first verification, incremental implementation, and continuous refactoring. The workflow supports both single test and test suite approaches with configurable coverage thresholds.]
For test-by-test development:
Use this approach by adding --incremental flag to focus on one test at a time.
For comprehensive test suite development:
Use this approach by adding --suite flag for batch test development.
Generate coverage reports after each phase:
If TDD discipline is broken:
Track and report:
These excuses signal you're about to break TDD discipline. Recognize them and return to the correct phase.
| Excuse | Rebuttal | Why It Matters |
|---|---|---|
| "I'll test after" | Tests written after implementation pass immediately, proving nothing. You can't verify a test catches bugs if you never saw it fail. | Tests-after are biased by implementation — you test what you built, not what's required |
| "This is too simple to test" | Simple code has the most unexamined assumptions. Simple code breaks at integration boundaries where you least expect it. | The simpler it seems, the more likely you'll miss an edge case |
| "TDD slows me down" | TDD prevents 2-3 hour debugging sessions. Writing a test takes minutes; debugging an untested bug takes hours. | The time you "save" skipping tests is borrowed against future debugging |
| "Just this once" | Every "just this once" becomes the new standard. Discipline has no exceptions — the exception IS the precedent. | One skip normalizes skipping. There is no "just this once" |
| "I already manually tested it" | Manual testing leaves no record, isn't repeatable, and doesn't catch regressions. It proves nothing to anyone but you, right now. | Manual tests evaporate. Automated tests compound |
| "Deleting my code is wasteful" | Sunk cost fallacy — keeping bad code costs more than writing it correctly. Code written without tests is unverified code. | Bad code costs more to maintain than to rewrite correctly |
| "The spirit matters, not the ritual" | The ritual IS the spirit — the specific order (test → fail → implement → pass → refactor) is what produces the quality guarantee. | Skipping steps while claiming to follow TDD is not following TDD |
| "I'll keep deleted code as reference" | Reference code biases you toward the wrong implementation. Start fresh — the test tells you what to write. | Prior code anchors you to assumptions that may be wrong |
TDD implementation for: $ARGUMENTS
npx claudepluginhub anton-abyzov/specweave --plugin swExecutes a comprehensive Test-Driven Development workflow with strict red-green-refactor discipline, including test specification, architecture design, and failing test verification.
Enforces strict red-green-refactor TDD cycle with automated test specification, failure verification, coverage thresholds, and refactoring triggers for developers practicing test-driven development.
Enforces strict RED-GREEN-REFACTOR TDD discipline with verifiable gates. Use when you want test-first discipline or to audit code for TDD compliance.