jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ TDD Workflows TDD Red

tdd-workflows-tdd-red

TDDのレッドフェーズで、期待される動作やエッジケースを明確にするための失敗するテストを生成するSkill。

⏱ RAG構築 1週間 → 1日

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Generate failing tests for the TDD red phase to define expected behavior and edge cases.

🇯🇵 日本人クリエイター向け解説

一言でいうと

TDDのレッドフェーズで、期待される動作やエッジケースを明確にするための失敗するテストを生成するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o tdd-workflows-tdd-red.zip https://jpskill.com/download/3576.zip && unzip -o tdd-workflows-tdd-red.zip && rm tdd-workflows-tdd-red.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3576.zip -OutFile "$d\tdd-workflows-tdd-red.zip"; Expand-Archive "$d\tdd-workflows-tdd-red.zip" -DestinationPath $d -Force; ri "$d\tdd-workflows-tdd-red.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して tdd-workflows-tdd-red.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → tdd-workflows-tdd-red フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • Tdd Workflows Tdd Red を使って、最小構成のサンプルコードを示して
  • Tdd Workflows Tdd Red の主な使い方と注意点を教えて
  • Tdd Workflows Tdd Red を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[スキル名] tdd-workflows-tdd-red

TDDのレッドフェーズの原則に従って、包括的な失敗するテストを作成します。

[拡張思考: test-automator エージェントを使用して、期待される動作を適切に定義する失敗するテストを生成します。]

このスキルを使用する場面

  • 新しい動作のTDDレッドフェーズを開始するとき
  • 期待される動作を捉える失敗するテストが必要なとき
  • 実装前にエッジケースをカバーしたいとき

このスキルを使用しない場面

  • グリーンフェーズまたはリファクタリングフェーズにいるとき
  • パフォーマンスベンチマークのみが必要なとき
  • テストを本番システムに対して実行する必要があるとき

手順

  1. 動作、制約、エッジケースを特定します。
  2. 期待される結果を定義する失敗するテストを生成します。
  3. 失敗がセットアップエラーではなく、不足している動作によるものであることを確認します。
  4. テストの実行方法と失敗の検証方法を文書化します。

安全性

  • テストデータを隔離し、本番環境を避けてください。
  • レッドフェーズでは、不安定な外部依存関係を避けてください。

ロール

サブエージェントタイプが「unit-testing::test-automator」のTaskツールを使用して、失敗するテストを生成します。

プロンプトテンプレート

「$ARGUMENTS のための包括的な失敗するテストを生成してください。」

コア要件

  1. テスト構造

    • フレームワークに適したセットアップ (Jest/pytest/JUnit/Go/RSpec)
    • Arrange-Act-Assert パターン
    • should_X_when_Y の命名規則
    • 相互依存性のない独立したフィクスチャ
  2. 動作カバレッジ

    • ハッピーパスシナリオ
    • エッジケース (空、null、境界値)
    • エラー処理と例外
    • 同時アクセス (該当する場合)
  3. 失敗の検証

    • テストは実行時に必ず失敗すること
    • 正しい理由 (構文/インポートエラーではない) で失敗すること
    • 意味のある診断エラーメッセージ
    • カスケードする失敗がないこと
  4. テストカテゴリ

    • ユニット: 独立したコンポーネントの動作
    • 統合: コンポーネント間の相互作用
    • 契約: API/インターフェースの契約
    • プロパティ: 数学的な不変条件

フレームワークパターン

JavaScript/TypeScript (Jest/Vitest)

  • vi.fn() または jest.fn() で依存関係をモックします。
  • React コンポーネントには @testing-library を使用します。
  • fast-check でプロパティテストを行います。

Python (pytest)

  • 適切なスコープを持つフィクスチャ
  • 複数のテストケースのためのパラメタライズ
  • プロパティベースのテストのための Hypothesis

Go

  • サブテストを含むテーブル駆動テスト
  • 並列実行のための t.Parallel()
  • よりクリーンなアサーションのための testify/assert

Ruby (RSpec)

  • 遅延ロードのための let、即時ロードのための let!
  • 異なるシナリオのためのコンテキスト
  • 共通の動作のための共有例

品質チェックリスト

  • 意図を文書化した読みやすいテスト名
  • 1つのテストにつき1つの動作
  • 実装の漏洩がないこと
  • 意味のあるテストデータ ('foo'/'bar' ではない)
  • テストが生きているドキュメントとして機能すること

避けるべきアンチパターン

  • すぐにパスするテスト
  • 動作ではなく実装をテストすること
  • 複雑なセットアップコード
  • 1つのテストに複数の責任を持たせること
  • 特定の詳細に縛られた壊れやすいテスト

エッジケースカテゴリ

  • Null/Empty: undefined、null、空の文字列/配列/オブジェクト
  • 境界: 最小/最大値、単一要素、容量制限
  • 特殊ケース: Unicode、空白、特殊文字
  • 状態: 無効な遷移、同時変更
  • エラー: ネットワーク障害、タイムアウト、権限

出力要件

  • インポートを含む完全なテストファイル
  • テストの目的の文書化
  • 失敗を実行および検証するためのコマンド
  • メトリクス: テスト数、カバレッジ領域
  • グリーンフェーズの次のステップ

検証

生成後:

  1. テストを実行し、失敗することを確認します。
  2. 役立つ失敗メッセージであることを確認します。
  3. テストの独立性を確認します。
  4. 包括的なカバレッジであることを確認します。

例 (最小限)

// auth.service.test.ts
describe('AuthService', () => {
  let authService: AuthService;
  let mockUserRepo: jest.Mocked<UserRepository>;

  beforeEach(() => {
    mockUserRepo = { findByEmail: jest.fn() } as any;
    authService = new AuthService(mockUserRepo);
  });

  it('should_return_token_when_valid_credentials', async () => {
    const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };
    mockUserRepo.findByEmail.mockResolvedValue(user);

    const result = await authService.authenticate('test@example.com', 'pass');

    expect(result.success).toBe(true);
    expect(result.token).toBeDefined();
  });

  it('should_fail_when_user_not_found', async () => {
    mockUserRepo.findByEmail.mockResolvedValue(null);

    const result = await authService.authenticate('none@example.com', 'pass');

    expect(result.success).toBe(false);
    expect(result.error).toBe('INVALID_CREDENTIALS');
  });
});

テスト要件: $ARGUMENTS

制限事項

  • このスキルは、タスクが上記の範囲と明確に一致する場合にのみ使用してください。
  • 出力を、環境固有の検証、テスト、または専門家によるレビューの代わりとして扱わないでください。
  • 必要な入力、権限、安全境界、または成功基準が不足している場合は、停止して説明を求めてください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Write comprehensive failing tests following TDD red phase principles.

[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]

Use this skill when

  • Starting the TDD red phase for new behavior
  • You need failing tests that capture expected behavior
  • You want edge case coverage before implementation

Do not use this skill when

  • You are in the green or refactor phase
  • You only need performance benchmarks
  • Tests must run against production systems

Instructions

  1. Identify behaviors, constraints, and edge cases.
  2. Generate failing tests that define expected outcomes.
  3. Ensure failures are due to missing behavior, not setup errors.
  4. Document how to run tests and verify failures.

Safety

  • Keep test data isolated and avoid production environments.
  • Avoid flaky external dependencies in the red phase.

Role

Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".

Prompt Template

"Generate comprehensive FAILING tests for: $ARGUMENTS

Core Requirements

  1. Test Structure

    • Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)
    • Arrange-Act-Assert pattern
    • should_X_when_Y naming convention
    • Isolated fixtures with no interdependencies
  2. Behavior Coverage

    • Happy path scenarios
    • Edge cases (empty, null, boundary values)
    • Error handling and exceptions
    • Concurrent access (if applicable)
  3. Failure Verification

    • Tests MUST fail when run
    • Failures for RIGHT reasons (not syntax/import errors)
    • Meaningful diagnostic error messages
    • No cascading failures
  4. Test Categories

    • Unit: Isolated component behavior
    • Integration: Component interaction
    • Contract: API/interface contracts
    • Property: Mathematical invariants

Framework Patterns

JavaScript/TypeScript (Jest/Vitest)

  • Mock dependencies with vi.fn() or jest.fn()
  • Use @testing-library for React components
  • Property tests with fast-check

Python (pytest)

  • Fixtures with appropriate scopes
  • Parametrize for multiple test cases
  • Hypothesis for property-based tests

Go

  • Table-driven tests with subtests
  • t.Parallel() for parallel execution
  • Use testify/assert for cleaner assertions

Ruby (RSpec)

  • let for lazy loading, let! for eager
  • Contexts for different scenarios
  • Shared examples for common behavior

Quality Checklist

  • Readable test names documenting intent
  • One behavior per test
  • No implementation leakage
  • Meaningful test data (not 'foo'/'bar')
  • Tests serve as living documentation

Anti-Patterns to Avoid

  • Tests passing immediately
  • Testing implementation vs behavior
  • Complex setup code
  • Multiple responsibilities per test
  • Brittle tests tied to specifics

Edge Case Categories

  • Null/Empty: undefined, null, empty string/array/object
  • Boundaries: min/max values, single element, capacity limits
  • Special Cases: Unicode, whitespace, special characters
  • State: Invalid transitions, concurrent modifications
  • Errors: Network failures, timeouts, permissions

Output Requirements

  • Complete test files with imports
  • Documentation of test purpose
  • Commands to run and verify failures
  • Metrics: test count, coverage areas
  • Next steps for green phase"

Validation

After generation:

  1. Run tests - confirm they fail
  2. Verify helpful failure messages
  3. Check test independence
  4. Ensure comprehensive coverage

Example (Minimal)

// auth.service.test.ts
describe('AuthService', () => {
  let authService: AuthService;
  let mockUserRepo: jest.Mocked<UserRepository>;

  beforeEach(() => {
    mockUserRepo = { findByEmail: jest.fn() } as any;
    authService = new AuthService(mockUserRepo);
  });

  it('should_return_token_when_valid_credentials', async () => {
    const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };
    mockUserRepo.findByEmail.mockResolvedValue(user);

    const result = await authService.authenticate('test@example.com', 'pass');

    expect(result.success).toBe(true);
    expect(result.token).toBeDefined();
  });

  it('should_fail_when_user_not_found', async () => {
    mockUserRepo.findByEmail.mockResolvedValue(null);

    const result = await authService.authenticate('none@example.com', 'pass');

    expect(result.success).toBe(false);
    expect(result.error).toBe('INVALID_CREDENTIALS');
  });
});

Test requirements: $ARGUMENTS

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.