MCPInstall

tdd

テスト駆動開発(TDD)ワークフローを実行するスキル。 使用タイミング: (1) 新機能の実装開始時 (2) バグ修正時 (3) リファクタリング前 (4) 「テストから書いて」と言われた時 (5) 品質重視の実装が必要な時。 トリガー例: 「TDDで実装して」「テスト駆動で」「テストから書いて」 「RED-GREEN-REFACTORで」「UserServiceのテストを書いて」

Installs
66
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/kimny1143/claude-code-template --skill tdd
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads tdd automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

/tdd - Test-Driven Development

テスト駆動開発ワークフローを実行する。

使い方

/tdd                    # 対話的にTDDを開始
/tdd UserService        # UserServiceのテストから開始
/tdd handlePayment edge # handlePaymentのエッジケーステスト

TDDサイクル

┌─────────────────────────────────────────────────┐
│  1. RED    → テストを書く(失敗することを確認) │
│  2. GREEN  → 最小限のコードで通す               │
│  3. REFACTOR → リファクタ(テストは通ったまま)│
└─────────────────────────────────────────────────┘

ワークフロー

Step 1: RED(テストを書く)

  1. テスト対象を特定

    • 新機能: 期待する入出力を定義
    • バグ修正: バグを再現するテストを書く
  2. テストファイルを作成/更新

    // tests/unit/services/user.service.test.ts
    describe('UserService', () => {
      describe('createUser', () => {
        it('should create user with valid data', async () => {
          const result = await userService.createUser({
            email: 'test@example.com',
            name: 'Test User',
          });
          expect(result.id).toBeDefined();
          expect(result.email).toBe('test@example.com');
        });
    
        it('should throw error for duplicate email', async () => {
          // エッジケース
          await expect(
            userService.createUser({ email: 'existing@example.com', name: 'Test' })
          ).rejects.toThrow('Email already exists');
        });
      });
    });
    
  3. テスト実行 → 失敗を確認

    npm run test -- --watch tests/unit/services/user.service.test.ts
    

Step 2: GREEN(実装する)

  1. 最小限の実装で通す

    • 完璧を目指さない
    • ハードコードでもOK(後でリファクタ)
    • テストが通ることだけに集中
  2. テスト実行 → 成功を確認

Step 3: REFACTOR(改善する)

  1. テストが通った状態で:

    • 重複を排除
    • 命名を改善
    • 構造を整理
  2. テスト実行 → まだ通ることを確認

  3. 満足したら次のテストへ(Step 1に戻る)


テストの書き方ガイド

命名規則

describe('[対象]', () => {
  describe('[メソッド/機能]', () => {
    it('should [期待する動作] when [条件]', () => {
      // ...
    });
  });
});

カバーすべきケース

ケース例
正常系有効な入力で期待通り動作
境界値0, 空文字, 配列の最初/最後
エラー系無効な入力、null/undefined
エッジケース並行アクセス、タイムアウト

モックの使い方

// 外部依存はモック
vi.mock('@/db', () => ({
  db: {
    select: vi.fn().mockReturnValue({
      from: vi.fn().mockReturnValue({
        where: vi.fn().mockResolvedValue([{ id: '1', name: 'Test' }]),
      }),
    }),
  },
}));

テストコマンド例

Vitest

npm run test                           # 全テスト
npm run test -- --watch               # ウォッチモード
npm run test -- tests/unit/specific   # 特定ディレクトリ
npm run test -- --coverage            # カバレッジ

Jest

npm test                              # 全テスト
npm test -- --watch                   # ウォッチモード
npm test -- --coverage                # カバレッジ

Playwright (E2E)

npm run test:e2e                      # 全E2E
npx playwright test --grep "login"    # 特定テスト

チェックリスト

TDD完了時の確認:

  • テストが先に書かれた(実装より前)
  • テストが一度失敗した(REDフェーズ)
  • 最小限の実装で通した(GREEN)
  • リファクタ後もテストが通る
  • エッジケースがカバーされている
  • テスト名が動作を説明している

FAQ

What does the tdd skill do?

テスト駆動開発(TDD)ワークフローを実行するスキル。 使用タイミング: (1) 新機能の実装開始時 (2) バグ修正時 (3) リファクタリング前 (4) 「テストから書いて」と言われた時 (5) 品質重視の実装が必要な時。 トリガー例: 「TDDで実装して」「テスト駆動で」「テストから書いて」 「RED-GREEN-REFACTORで」「UserServiceのテストを書いて」

How do I install tdd?

Run npx skills add https://github.com/kimny1143/claude-code-template --skill tdd in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/tdd/ (personal) or .claude/skills/tdd/ (project).

Which AI agents can use tdd?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is tdd safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains tdd?

It is published by kimny1143 in kimny1143/claude-code-template. It has 66 recorded installs.

More from kimny1143/claude-code-template

View all →

ui-ux-pro-max

kimny1143/claude-code-template

UI/UX design intelligence. Plan, build, design, implement, review, improve UI/UX code. Styles: image-first, editorial design, minimalism, dark mode, responsive. Projects: landing page, dashboard, SaaS, mobile app.

Frontend & Design4.7K installs

remotion

kimny1143/claude-code-template

汎用Remotion動画制作スキル。プロモーション動画、マスコットアニメーション、 LP用動画、チュートリアル動画、SNS短尺動画の制作に使用。 トリガー: "プロモ動画", "アニメーション", "動画を作って", "Remotion", "動画コンテンツ", "ビデオ制作", "モーショングラフィックス", "LP動画", "チュートリアル動画", "OGP動画", "動画素材" Remotionを使ったReactベースの動画生成全般でこのスキルを使うこと。 プロモーション映像やアニメーション素材の話が出たら積極的にこのスキルを参照すること。

Media & Creative162 installs

ux-psychology

kimny1143/claude-code-template

Open the skill to read its SKILL.md instructions.

Frontend & Design114 installs

copywriting

kimny1143/claude-code-template

Open the skill to read its SKILL.md instructions.

Marketing & SEO89 installs

ios-app-store-submission

kimny1143/claude-code-template

Open the skill to read its SKILL.md instructions.

Mobile88 installs

marketing-psychology

kimny1143/claude-code-template

When the user wants to apply psychological principles, mental models, or behavioral science to marketing. Also use when the user mentions 'psychology,' 'mental models,' 'cognitive bias,' 'persuasion,' 'behavioral science,' 'why people buy,' 'decision-making,' or 'consumer behavior.' This skill provides 70+ mental models organized for marketing application.

Marketing & SEO82 installs

Popular testing & qa skills

View category →

tdd

mattpocock/skills

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

Testing & QA1.2M installs

grilling

mattpocock/skills

Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.

Testing & QA996.2K installs

migrate-to-shoehorn

mattpocock/skills

Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.

Testing & QA484.1K installs

run-train

lllllllama/rigorpilot-skills

Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.

Testing & QA337.8K installs

test-driven-development

obra/superpowers

Use when implementing any feature or bugfix, before writing implementation code

Testing & QA261.8K installs

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

Testing & QA216.8K installs