agentleFS
youhei-ushioyouhei-ushio/dotclaude-public/skills/global/tdd/SKILL.md

tdd

Skill1 starsChanged 2 months agoMITView on GitHub

テストを伴う機能開発(新規実装・改修)に着手するとき。 test-first(先にテストを書いて失敗を観測してから実装)で進めたいとき。 「TDD で」「テストファーストで」「先にテストを書いて」のような自然言語でも起動。

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use capture-learning-tools, design-frontend-dev and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • The-Vibe-CompanySkill

    capture-learning-tools

    Turn technical conversations, bugs, CI failures, review comments,

    Also in 5 projects that use this

  • The-Vibe-CompanySkill

    design-frontend-dev

    Clean Impeccable frontend design skill. Use when the user wants to

    Also in 5 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 14 projects that use this

  • jaydubya818Skill

    figure-it-out

    Use when novel or multi-phase work needs an auditable workflow and no narrower playbook fits.

    Also in 54 projects that use this

  • jaydubya818Skill

    principle-laziness-protocol

    Apply when a refactor is adding wrappers or abstractions instead of simplifying.

    Also in 45 projects that use this

  • +2 more from The-Vibe-Company
  • +5 more from jaydubya818

The file

Files
SKILL.md

TDD(test-first / RED を必ず観測)

テストの書ける領域での機能開発における test-first の既定手順。

大原則: テストの失敗を見ていないなら、正しいものをテストしている確証は無い

実装を書く前に、まず失敗するテストを書き、その失敗(RED)を実際に観測する。 「通ると思ったテストが最初から通ってしまった」場合、そのテストは対象を検証していない (誤った前提・誤ったアサーション・実装済みの何かを叩いているだけ)。RED を見て初めて、 そのテストが意味を持つ。

サイクル: RED → GREEN → REFACTOR

  1. RED: これから作る振る舞いに対する失敗するテストを 1 つ書く。実行して失敗を観測する。 失敗メッセージが「期待した理由で」失敗しているかまで確認する(未定義エラーで落ちただけ、を避ける)。
  2. GREEN: そのテストを通す最小限の実装を書く。ここで余計な機能を足さない(YAGNI)。 テストを実行し、**通る(GREEN)**ことを確認する。
  3. REFACTOR: GREEN を保ったまま整理する。リファクタの前後でテストが通り続けることを確認する。

1 サイクル 1 振る舞い。複数の振る舞いを 1 サイクルに詰め込まない。

最小例(一例: PHP + Pest。他言語・他ランナは読み替える)

// tests/Feature/InvoiceTotalTest.php
it('合計に消費税を加算する', function () {
    $invoice = Invoice::factory()->create(['subtotal' => 1000]);

    expect($invoice->total())->toBe(1100); // 消費税 10%: 1000 * 1.1 = 1100(int 返却想定)。未実装なので RED
});

テストランナで先に失敗を観測してから、total() を実装して GREEN にする (実行コマンドは各プロジェクト・各フレームワークの方式に従う)。 単体/機能テストは本 skill 内で完結する。実装後の画面影響・回帰確認は affected-area-testing skill やブラウザ自動化(Playwright 等)で行う。

適用範囲(強制しない場所)

  • 機能開発の既定手順として借用する。絶対法ではない。
  • superpowers の「テスト前に書いた本番コードは全て削除する」絶対ルールは採らない。 「シンプル第一」「字面でなく意図で動く」と衝突しうるため。既に妥当な実装がある/ 探索的に書いたコードが正しいなら、テストを後追いで固める判断もしてよい(意図で動く)。 ただし後追いで固める場合も、実装を一時的に壊す等して失敗(RED 相当)を一度は観測し、 そのテストが対象を本当に検証していることを担保する(大原則は死守する)。
  • 設定・インフラ・ビルド/CI・自明な変更・テストの書きづらい UI 微調整には強制しない。
  • テストランナの無い領域(設定・shell スクリプト等)は対象外。そこでは「失敗を先に固定してから直す」 バグ調査の規律(systematic-debugging skill)で代替する。

関連 skill との棲み分け

  • tdd(本 skill)= 開発前の test-first(これから作る振る舞いを RED から始める)。
  • バグ調査での RED 観測(既存の不具合を再現する失敗を先に固定)= systematic-debugging skill。
  • 改修後の段階テスト(基本→新機能→統合→回帰、ブラウザ自動化中心)= affected-area-testing skill。単体テストは本 skill 側で回す。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.