tdd-development
TDD(テスト駆動開発)のRed-Green-Refactorサイクルでコードを「実装」する。「エンティティ」「サービス」「API」「機能」の実装時に使用。「テスト駆動」「TDD」で品質を担保する。
When & Why to Use This Skill
This Claude skill automates the Test-Driven Development (TDD) workflow, guiding developers through the professional Red-Green-Refactor cycle. It ensures high-quality code implementation for entities, services, and APIs by enforcing a test-first approach that minimizes technical debt and guarantees functional reliability.
Use Cases
- Implementing Core Business Logic: Build robust entities and services by defining behavior through failing tests before writing any production code.
- API Development and Integration: Ensure reliable API endpoints by following a disciplined TDD cycle to validate request/response structures and edge cases.
- Safe Code Refactoring: Improve existing code architecture and remove technical debt with the confidence that existing functionality is protected by the TDD suite.
- Incremental Feature Implementation: Break down complex software requirements into small, manageable cycles (5-15 minutes) to maintain steady progress and high code quality.
| name | tdd-development |
|---|---|
| description | TDD(テスト駆動開発)のRed-Green-Refactorサイクルでコードを「実装」する。「エンティティ」「サービス」「API」「機能」の実装時に使用。「テスト駆動」「TDD」で品質を担保する。 |
TDD開発ワークフロー
基本サイクル: Red-Green-Refactor
実装作業では以下のサイクルを繰り返す:
- Red: 失敗するテストを先に書く
- Green: テストを通す最小限のコードを書く
- Refactor: コードを整理する(テストは通ったまま)
ワークフロー手順
Step 1: テスト作成(Red)
- 実装したい機能・振る舞いをテストとして記述
- テストを実行し、失敗することを確認
- 失敗理由が「未実装」であることを確認
Step 2: 最小実装(Green)
- テストを通すための最小限のコードを書く
- 過度な設計・最適化は行わない
- テストを実行し、成功することを確認
Step 3: リファクタリング(Refactor)
- コードの重複を除去
- 命名・構造を改善
- テストを実行し、引き続き成功することを確認
実装の粒度
- 1サイクルは小さく保つ(5-15分程度で完了する単位)
- 機能を細かく分割し、段階的に実装
- 複雑な機能は複数サイクルで構築
テスト実行タイミング
- Red: テスト作成後に必ず実行(失敗確認)
- Green: 実装後に必ず実行(成功確認)
- Refactor: 変更のたびに実行(回帰確認)
このプロジェクトでの適用
- ユニットテスト:
*.spec.tsファイル - E2Eテスト:
test/ディレクトリ - テスト実行:
npm run test:task(ユニット)、npm run test:task:e2e(E2E) - 設計参照:
docs/design/、テストシナリオ参照:docs/user-stories/