Agent skill
Practicing TDD
Guide Test-Driven Development workflow with Red-Green-Refactor cycle. Use when developing features, fixing bugs, or when user mentions TDD/テスト駆動開発/test-first.
Install this agent skill to your Project
npx add-skill https://github.com/camoneart/claude-code/tree/main/skills/practicing-tdd
SKILL.md
Practicing TDD
テスト駆動開発(TDD)のベストプラクティスに従った開発フローを管理するスキル。
いつ使うか
- プロジェクト(プロダクト、アプリ、サイト等)の開発時
- 新機能実装時
- バグ修正時
- ユーザーがTDD、テスト駆動開発について言及した時
基本原則
Red-Green-Refactor サイクル
1. Red → テストを書いて失敗させる
2. Green → テストを通す最小限のコード
3. Refactor → コードを整理整頓
4. 繰り返し
開発手順
ステップ1: ToDo リスト作成
やるべきことを箇条書きで整理(テストリスト)
ステップ2: Red(レッド)
- ToDo リストから1つピックアップ
- テストから書く(テストファースト)
- テストを実行して失敗させる
ステップ3: Green(グリーン)
- 失敗しているテストを成功させることに集中
- 最小限のコードを書く(綺麗より動作優先)
- 全てのテストが成功することを確認
ステップ4: Refactor(リファクタリング)
- 全てのテストが成功している状態で整理整頓
- テストは通ったままにする
- 実装コード、テストコード両方をリファクタリング
ステップ5: 繰り返し
- 気付きを ToDo リストに反映
- 次の ToDo を選んで Red に戻る
品質基準
テスト配置
- テストコードは
src/__tests__/または実装ファイルと同階層の*.test.ts(x)に配置 pnpm testで必ず全スイートを実行
カバレッジ基準
- コードカバレッジは常に 80% 以上 を維持
- CI で閾値を下回った場合はジョブを fail させる
バグ修正フロー
- 再現テスト(Red)を書く
- 修正(Green)
- リファクタリング(Refactor)
品質ゲート
テスト追加・変更後は必ず実行:
pnpm run lint && pnpm run typecheck
参考記事
詳細は references.md を参照。
注意事項
- テストを書かずに実装を進めない
- 複数の機能を同時に実装しない(1つずつ)
- テストが失敗したままリファクタリングしない
- カバレッジ80%未満でコミットしない
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
translating-technical-articles
Translates English technical articles (engineering blogs, documentation) to Japanese while preserving layout and structure. Use when the user asks to translate an article, convert English content to Japanese, or mentions translating a URL or technical blog post.
guiding-tdd-development
Guide Test-Driven Development with task splitting, Red-Green-Refactor cycle, and framework auto-detection. Use when developing features with TDD approach, fixing bugs test-first, or when user mentions "TDD", "テスト駆動開発", "test-first", "/tdd".
distributed-tracing
Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks. Use when debugging microservices, analyzing request flows, or implementing observability for distributed systems.
dependency-upgrade
Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
stripe-integration
Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.
typescript-advanced-types
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.
Didn't find tool you were looking for?