active
TDD Workflow
Safe
System VerifiedSafe
Enforces strict Red-Green-Refactor TDD cycle. Tests first, minimal implementation, then refactor. Inspired by obra/superpowers and Aider architect mode.
@api/tdd-workflow
tdd
testing
workflow
methodology
TDD Workflow
Purpose: Enforce a strict Red-Green-Refactor test-driven development cycle. The agent writes tests FIRST, then implements just enough code to make them pass, then refactors.
Invocation
code
/tdd <feature_description>
The Cycle
Phase 1: RED — Write Failing Tests
- Create a test file (or add to existing)
- Write test cases that describe the desired behavior
- Run the test suite — confirm tests FAIL
- Do NOT write any implementation yet
bash
$ npx vitest run src/utils/slug.test.ts
FAIL src/utils/slug.test.ts
✗ converts spaces to hyphens
✗ lowercases all characters
✗ removes special characters
✗ handles empty string
Phase 2: GREEN — Write Minimum Implementation
- Write the simplest code that makes ALL tests pass
- No extra features, no optimization, no "while I'm here" additions
- Run tests — confirm they PASS
bash
$ npx vitest run src/utils/slug.test.ts
✓ src/utils/slug.test.ts (4 tests)
✓ converts spaces to hyphens
✓ lowercases all characters
✓ removes special characters
✓ handles empty string
Phase 3: REFACTOR — Clean Up
- Improve code quality WITHOUT changing behavior
- Run tests after each refactor step — they must stay GREEN
- Look for: duplication, unclear naming, complex conditionals, missing types
- Commit when satisfied
Rules
- Never write implementation before tests — If you catch yourself coding logic before a test exists, stop and write the test first.
- One test at a time — Write one test, see it fail, make it pass. Then the next.
- Minimal implementation — Don't write code "you'll need later." Only satisfy current tests.
- Tests must fail first — If a new test passes immediately, either the test is wrong or the behavior already exists. Investigate.
- Refactor only when green — Never refactor while tests are failing.
- Small commits — Commit at the end of each RED-GREEN-REFACTOR cycle.
Commit Convention
code
test: add tests for slug utility (RED)
feat(utils): implement slug generation (GREEN)
refactor(utils): simplify slug regex (REFACTOR)
When to Break the Cycle
It's okay to skip TDD for:
- Configuration files (no logic to test)
- Type definitions (TypeScript compiler is the test)
- One-line wrappers around well-tested libraries
- UI layout (visual testing is better here)
But ALWAYS use TDD for:
- Business logic
- Data transformations
- Validation rules
- API endpoint handlers
- State management logic
Dormant$0/mo
$20 more to next tier
Created by
Info
Created February 18, 2026
Version 1.0.0
Agent-invoked
Terminal output
Embed
Add this skill card to any webpage.
<iframe src="https://skillslap.com/skill/da1d3157-e1a7-40b6-8cd5-2a4ebc99e09d/embed"
width="400" height="200"
style="border:none;border-radius:12px;"
title="SkillSlap Skill: TDD Workflow">
</iframe>