tdd
できること
このスキルは、テストを先に書き、それを通す最小限のコードを書くことで、エージェントにコードを作らせます。各変更が、コードより前に書かれたテストで証明されてほしい開発者向けです。
使う場面
- ✓新しい動作を、テストファーストで1つずつ小さな手順で作りたいとき。
- ✓バグを、それを再現するテストを先に書いてから直したいとき。
- ✓コードそのものからではなく、信頼できる情報源からテストを書きたいとき。
スキルのリンク
https://github.com/Yeachan-Heo/oh-my-claudecode/blob/main/skills/tdd/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“価格ルールのテストを、1つずつ小さな手順で先に書いてください。仕様書の例を使ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、合意された節目で次のテストを書き、それが期待どおりの理由で失敗することを確認します。その後、テストを通す最小限の変更を書きます。このサイクルを繰り返し、リファクタリングは後のレビューの段階に回します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
TDD
Red-green in small steps, at seams that were agreed in advance. In a launch run the seam list is C2's approved output; outside launch, agree the seams with the user before the first test exists — a seam nobody approved gets no tests.
The loop
One test → one implementation → repeat:
- Write the next test at a seam. Run it. Watch it fail for the reason you expect — a test that cannot fail is not a test.
- Implement the smallest change that turns it green.
- Repeat. Each test is a tracer bullet: a narrow but complete path through the behavior, not a layer finished in isolation.
Rules
- Expected values come from an independent source of truth — a spec line, a worked example, a documented output. Never from the implementation under test: a test that asserts what the code happens to do is a mirror, not a check.
- Substitute at the seam's declared boundary class only — in-process, locally substitutable, owned-remote port, or true-external, the class C2 records for each seam. No substitutes inside the boundary the test is exercising.
- Refactoring is not part of the loop. It belongs to the review stage; the repair worker owns it. Do not refactor mid-red-green.
- A bug fix starts with the failing test that reproduces it — reproduction before theory, the debugger's rule.
- When proposing a seam, say in one line what it catches and what it lets through — a seam choice nobody can price is a guess, not a decision.
When no seam fits
If the behavior cannot be tested at any approved seam, stop and say so: report the missing seam as a finding (it feeds architecture-survey and refit) rather than inventing a seam or testing through internals.
Output
- The seam list used, with boundary classes and each seam's catch/miss line
- Red/green evidence — the failing run and the passing run
- Any seam-absence findings
よくある質問
テストはコードの動作をそのままコピーしますか?
いいえ。期待値は、仕様書や具体例などの独立した情報源から来ます。テスト対象のコードからは取りません。
テストはどこに書かれますか?
事前に合意された箇所だけに書かれます。誰も承認していない箇所に対してテストは書きません。
リファクタリングはいつ行われますか?
赤と緑のループの中ではなく、後のレビューの段階で行われます。
詳細
作者による元の説明
Test-first at pre-agreed seams — one test, one implementation, tracer-bullet red/green; independent expected values; substitutions only at the seam's boundary class; launch Phase 4 reference.
人気
- GitHubのスター
- 41k
- ランキング
- #7027
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
agent-doc-discipline
41kエージェントが、他のAIエージェントが独力で従える指示を書けるよう支援します。確認できるルールと、各ルールの理由を明示します。
ai-slop-cleaner
41kエージェントが、動くけれど肥大化して繰り返しの多いAI生成コードを整理できるよう支援します。動作を変えずに、余分なコードを取り除きます。
architecture-survey
41kエージェントが、コードベースの構造を確認し、変更が難しくなっている部分を根拠とともに挙げます。自分では何も変更しません。
ask-navigator
41kエージェントが、あいまいなプロジェクトを明確な決定事項の一覧に変え、1つずつ検討して進む道筋を見えるようにします。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。