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.
This skill is limited to using the following tools:
EVALUATIONS.mdREADME.mdassets/jest.config.jsassets/vitest.config.tsreferences/tdd-rgrc.mdreferences/test-design.mdThis skill provides systematic guidance for Test-Driven Development (TDD) combining:
Keywords that activate this skill:
For guaranteed activation:
/code commandtest-generator agent"Make the smallest possible change at each step" - t_wada
Why it matters:
2-Minute Cycle:
Goal: "Clean code that works" (動作するきれいなコード) - Ron Jeffries
Write failing test → Verify correct failure reason
Minimal code to pass → "You can sin" (quick/dirty OK)
Apply SOLID/DRY → Improve structure → Keep tests green
All checks pass → Save stable state
Copy this checklist and track your progress:
TDD Cycle:
- [ ] Step 1: Red - 失敗するテスト作成
- [ ] Step 2: Green - 最小限のコードで通過
- [ ] Step 3: Refactor - コード改善
- [ ] Step 4: Commit - 変更をコミット
// 1. テストファイルを作成/開く
// 2. AAA パターンでテストを書く
test('should validate email format', () => {
// Arrange
const email = 'invalid-email'
// Act
const result = validateEmail(email)
// Assert
expect(result).toBe(false)
})
git add .
git commit -m "feat: add email validation"
Quality > Quantity - Fewer well-designed tests catch more bugs
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', () => ...)
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)', () => ...)
Complex logic with multiple conditions:
// isLoggedIn × isPremium × isActive → canAccess
// Use decision table to cover all combinations systematically
# In agent YAML frontmatter
dependencies: [tdd-test-generation]
Or explicit reference:
[@~/.claude/skills/generating-tdd-tests/SKILL.md]
Industry-recommended targets:
Why: Cost-benefit balance, focus on critical paths
Skip for:
TDD is working when:
Comprehensive documentation loaded as needed:
tdd-rgrc.md - Detailed RGRC cycle implementationtest-design.md - Complete test design techniques guideFor command output testing and document quality standards:
Test automation utilities:
run-tests.sh - Auto-detect package manager and test runnercoverage-check.sh - Verify coverage thresholds (default: 100%)generate-test.sh - Generate test scaffolds with AAA patternConfiguration file templates (TDD-optimized with 100% coverage targets):
vitest.config.ts - Vitest configuration templatejest.config.js - Jest configuration template