name: tdd-test-generation
description: >
Comprehensive TDD (Test-Driven Development) guide with RGRC cycle, Baby Steps methodology,
and systematic test design techniques. Use when implementing TDD (テスト駆動開発),
discussing Red-Green-Refactor, Baby Steps, test generation (テスト生成), test design
(テスト設計), test cases (テストケース), equivalence partitioning, boundary value
analysis (境界値分析), decision tables, coverage (カバレッジ), or unit testing
(ユニットテスト). Provides t_wada-style Baby Steps approach with systematic test case
generation and SOW integration. Essential for test-generator agent and /code TDD implementations.
allowed-tools: Read, Write, Edit, Grep, Glob, Task
TDD Test Generation - Comprehensive Test-Driven Development Guide
Overview
This skill provides systematic guidance for Test-Driven Development (TDD) combining:
- RGRC Cycle - Red-Green-Refactor-Commit workflow inspired by t_wada
- Baby Steps - Incremental development with 2-minute cycles
- Systematic Test Design - Equivalence partitioning, boundary value analysis, decision tables
- Test Generation - From SOW test plans to executable test cases
When to Use This Skill
Automatic Triggers
Keywords that activate this skill:
- TDD, Test-Driven Development, テスト駆動開発
- RGRC, Red-Green-Refactor, Baby Steps
- Test generation, test design, test cases
- Equivalence partitioning, boundary value, decision table
- Coverage, test first, unit test
Explicit Invocation
For guaranteed activation:
- "Apply TDD skill"
- "Use TDD test generation skill"
- "Follow RGRC cycle"
Common Scenarios
- Implementing features with
/code command
- Generating tests with
test-generator agent
- Planning test coverage strategies
- Refactoring with test safety nets
- Reviewing test design quality
Core Concepts
1. Baby Steps - The Foundation
"Make the smallest possible change at each step" - t_wada
Why it matters:
- Immediate error localization (bug is in last 2-minute change)
- Continuous working state (always seconds from green)
- Rapid feedback loop
- Confidence through small successes
2-Minute Cycle:
- Write smallest failing test (30s)
- Make it pass minimally (1min)
- Run tests (10s)
- Tiny refactor (30s)
- Commit if green (20s)
2. RGRC Cycle
Goal: "Clean code that works" (動作するきれいなコード) - Ron Jeffries
Red Phase
Write failing test → Verify correct failure reason
Green Phase
Minimal code to pass → "You can sin" (quick/dirty OK)
Refactor Phase
Apply SOLID/DRY → Improve structure → Keep tests green
Commit Phase
All checks pass → Save stable state
3. Systematic Test Design
Quality > Quantity - Fewer well-designed tests catch more bugs
Equivalence Partitioning
Group inputs with same behavior, test one from each:
// Age validation: <18 (invalid), 18-120 (valid), >120 (invalid)
test('partition 1: rejects 17', () => ...)
test('partition 2: accepts 30', () => ...)
test('partition 3: rejects 121', () => ...)
Boundary Value Analysis
Test edges [min-1, min, max, max+1]:
test('boundary: rejects 17 (18-1)', () => ...)
test('boundary: accepts 18 (min)', () => ...)
test('boundary: accepts 120 (max)', () => ...)
test('boundary: rejects 121 (120+1)', () => ...)
Decision Table Testing
Complex logic with multiple conditions:
// isLoggedIn × isPremium × isActive → canAccess
// Use decision table to cover all combinations systematically
Detailed Knowledge Base
Reference Documents
- [@./references/tdd-rgrc.md] - Complete RGRC cycle guide with t_wada's methodology
- [@./references/test-design.md] - Systematic test design techniques, coverage goals (C0: 80%, C1: 70%), framework-agnostic patterns
Integration Points
With Agents
- test-generator - Generates tests from SOW using this skill's principles
- testability-reviewer - Evaluates test design quality
With Commands
- /code - Applies TDD during implementation
- /test - Validates coverage and quality
Integration Method
# In agent YAML frontmatter
dependencies: [tdd-test-generation]
Or explicit reference:
[@~/.claude/skills/tdd-test-generation/SKILL.md]
Quick Start
New Feature
- Red - Write failing test
- Green - Minimal code
- Refactor - Clean up
- Commit - Save
- Repeat
From SOW
- Read SOW test plan
- Apply equivalence partitioning
- Add boundary values
- Generate test cases
- Verify coverage
Refactoring
- Ensure comprehensive tests
- Verify green
- Refactor incrementally
- Run frequently
- Commit when green
Best Practices
Do's ✅
- Write test before code
- Keep steps small (Baby Steps)
- Run tests frequently
- Commit when green
- Use systematic test design
- Apply SOLID/DRY in Refactor, not before
Don'ts ❌
- Skip Red phase
- Write multiple tests before any pass
- Refactor without green tests
- Commit with failing tests
- Random test selection
- Complex architecture in Green phase
Coverage Goals
Industry-recommended targets:
- C0 (Statement): 80% minimum
- C1 (Branch): 70% minimum
Why: Cost-benefit balance, focus on critical paths
When NOT to Use TDD
Skip for:
- Prototypes (throwaway code)
- External API integration (use mocks)
- Simple one-off scripts
- UI experiments (visual iteration first)
Success Metrics
TDD is working when:
- Tests written before code (100%)
- Cycles complete in <5 min
- Refactoring feels safe
- Coverage meets targets
- Velocity increases over time
Resources
references/
Comprehensive documentation loaded as needed:
tdd-rgrc.md - Detailed RGRC cycle implementation
test-design.md - Complete test design techniques guide
Command Output Testing
For validating command output quality using Golden Master methodology:
- ~/.claude/tests/README.md - Command test strategy and verification checklists
- ~/.claude/tests/golden-masters/ - Expected output samples for commands
- ~/.claude/tests/scenarios/ - Test scenarios for command validation
scripts/
Currently empty - no automation scripts needed (knowledge-only skill)
assets/
Currently empty - no template files needed (knowledge-only skill)