Tdd

From excatt/superclaude-plusplus · View interactive version

Tdd is an AI agent skill from the GitHub repository excatt/superclaude-plusplus. Test-Driven Development with enforced RED-GREEN-REFACTOR cycle and Git checkpoints per phase. Use for new testable features and bug fixes (reproduction test first) — not for config, docs, or renames.

How to use this skill

Skill file

When to Use

Use proactively when:

Triggers: TDD, test-driven, test first, red green refactor,

write test first, failing test, reproduction test

Do NOT use for: config changes, documentation, simple renames, UI-only changes

Dynamic Context

Recent TDD commits:

!git log --oneline -5 --grep="red:\|green:\|refactor:" 2>/dev/null || echo "No TDD commits found"

Test infrastructure:

!ls tests/ __tests__/ test/ 2>/dev/null | head -10 || echo "No test directory found"

TDD Workflow Skill

Purpose

Enforce disciplined RED-GREEN-REFACTOR cycle with Git checkpoints to prevent skipping steps.

Usage

/tdd "user login validation"      # new feature
/tdd "fix: timeout on large files" # bug reproduction
/tdd                               # prompt for description

The Cycle

RED → GREEN → REFACTOR → (repeat)
 │      │        │
 │      │        └─ git commit "refactor: ..."
 │      └─ git commit "green: ..."
 └─ git commit "red: ..."

Phase 1: RED (Write Failing Test)

Goal: Write a test that describes the desired behavior. It MUST fail.

Rules

RED Gate (CRITICAL)

DO NOT edit production code until RED state is confirmed.

Acceptable RED states:

NOT acceptable:

Checkpoint

git add -A && git commit -m "red: [describe expected behavior]"

Phase 2: GREEN (Make It Pass)

Goal: Write the MINIMUM production code to make the test pass. Nothing more.

Rules

GREEN Gate

ALL tests must pass. No new test failures introduced.

Checkpoint

git add -A && git commit -m "green: [describe what was implemented]"

Phase 3: REFACTOR (Clean Up)

Goal: Improve code quality without changing behavior. Tests stay green throughout.

Rules

Checkpoint

git add -A && git commit -m "refactor: [describe improvement]"

Cycle Completion

After REFACTOR, evaluate:

Coverage Gate

After all cycles complete:

# JavaScript/TypeScript
pnpm test -- --coverage

# Python
pytest --cov --cov-report=term-missing

Minimum threshold: Report actual coverage. Flag untested paths. Do not set arbitrary percentage targets unless the project defines one.

Anti-patterns — Must Avoid

Integration with Verification Iron Law

TDD checkpoints feed directly into the Verification Iron Law:

Each commit is a verification artifact.

Output Format

## TDD Cycle 1: [behavior]

### RED
- Test: `test/auth.test.ts` — `should reject empty password`
- Status: FAIL ✓ (assertion error: expected rejection)
- Commit: `red: reject empty password validation`

### GREEN
- Implementation: `src/auth.ts:validatePassword()`
- Status: ALL PASS ✓
- Commit: `green: implement password validation`

### REFACTOR
- Change: extracted validation rules to constants
- Status: ALL PASS ✓
- Commit: `refactor: extract validation constants`

## Coverage: 87% (src/auth.ts: 100%)

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.