tdd

motoki317's avatarfrom motoki317

Guide Test-Driven Development using Kent Beck's Red-Green-Refactor cycle. Use when writing tests, implementing features via TDD, or following plan.md test instructions.

⭐1stars🔀0forks📁View on GitHub🕐Updated Dec 26, 2025

When & Why to Use This Skill

This Claude skill facilitates professional Test-Driven Development (TDD) by enforcing Kent Beck's Red-Green-Refactor cycle. It streamlines the software engineering process by guiding users through writing failing tests, implementing minimal code solutions, and performing systematic refactoring to ensure high-quality, maintainable codebases and reduced technical debt.

Use Cases

  • Feature Implementation: Build new software components from scratch using a test-first approach to ensure 100% functional alignment and high code coverage.
  • Legacy Code Refactoring: Safely improve existing code structures by applying 'Tidy First' principles, ensuring behavioral consistency through incremental testing and small commits.
  • Technical Plan Execution: Systematically follow complex development instructions (such as those in a plan.md) while maintaining strict adherence to professional TDD quality standards.
  • Code Quality Optimization: Eliminate duplication and improve code readability by integrating mandatory refactoring phases into the daily development loop.
nametdd
descriptionGuide Test-Driven Development using Kent Beck's Red-Green-Refactor cycle. Use when writing tests, implementing features via TDD, or following plan.md test instructions.

INSTRUCTIONS

Follow Kent Beck's TDD and Tidy First principles using the three-phase workflow:

  1. RED - /tdd:red - Write ONE small failing test
  2. GREEN - /tdd:green - Make it pass with minimal code, then commit
  3. REFACTOR - /tdd:refactor - Improve structure without changing behavior, commit each step

Workflow Pattern

/tdd:red → write failing test → /tdd:green → pass test → /git:commit
                                                              ↓
        ← next feature ← /tdd:red ← satisfied? ← /tdd:refactor (repeat as needed)

Core Principles

  • One test at a time: Each RED adds exactly ONE failing test
  • Minimal code: GREEN phase writes just enough to pass
  • Never skip REFACTOR: Every TDD cycle must complete all three phases
  • Tidy First: Separate structural changes (refactor) from behavioral changes (feat/fix)
  • Small commits: Commit after GREEN, commit after EACH refactor step

Strategy Selection (GREEN Phase)

Confidence Strategy Use When
Low Fake It Return constant, generalize later
High Obvious Implementation Solution is clear
Generalizing Triangulation Add test to break a fake

Quality Standards

  • Eliminate duplication between test and production code
  • Express intent through clear naming
  • Keep methods small and focused
  • Run ALL tests after EVERY change