MCP HubMCP Hub
スキル一覧に戻る

test-driven-development

bobmatnyc
更新日 Today
73 閲覧
22
3
22
GitHubで表示
テストtddtestingred-green-refactortest-first

について

このClaudeスキルは、実装コードの前に失敗するテストを最初に書くことを要求することで、厳格なテスト駆動開発を実施します。RED/GREEN/REFACTORサイクルに従い、テストを書き、それが失敗することを確認し、合格するための最小限のコードを書き、その後リファクタリングを行います。すべての新機能、バグ修正、動作変更にこのスキルを使用し、テストファースト開発プラクティスを確実に実践してください。

クイックインストール

Claude Code

推奨
プラグインコマンド推奨
/plugin add https://github.com/bobmatnyc/claude-mpm
Git クローン代替
git clone https://github.com/bobmatnyc/claude-mpm.git ~/.claude/skills/test-driven-development

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Test-Driven Development (TDD)

Overview

Write the test first. Watch it fail. Write minimal code to pass.

Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.

This skill enforces strict test-first development following the RED/GREEN/REFACTOR cycle. Violating the letter of the rules is violating the spirit of the rules.

When to Use This Skill

Always:

  • New features
  • Bug fixes
  • Refactoring
  • Behavior changes

Exceptions (ask human partner):

  • Throwaway prototypes
  • Generated code
  • Configuration files

Thinking "skip TDD just this once"? Stop. That's rationalization.

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

Write code before the test? Delete it. Start over.

No exceptions:

  • Don't keep it as "reference"
  • Don't "adapt" it while writing tests
  • Delete means delete

Core Principles

  1. RED: Write a failing test first
  2. GREEN: Write minimal code to make test pass
  3. REFACTOR: Improve code while keeping tests green
  4. NEVER: Write implementation before tests

Quick Start

The RED/GREEN/REFACTOR Cycle

RED → Verify RED → GREEN → Verify GREEN → REFACTOR → Repeat
  1. RED: Write one minimal test showing desired behavior
  2. Verify RED: Run test, confirm it fails for right reason
  3. GREEN: Write simplest code to pass test
  4. Verify GREEN: Run test, confirm it passes
  5. REFACTOR: Clean up while keeping tests green
  6. Repeat: Next test for next feature

Cycle Details

RED: Write one minimal test (one behavior, clear name, real code) Verify RED: MANDATORY - watch it fail for right reason GREEN: Write simplest code to pass (no extras) Verify GREEN: MANDATORY - watch it pass, all tests pass REFACTOR: Clean up while keeping tests green (optional)

Navigation

For detailed information:

  • Workflow: Complete RED/GREEN/REFACTOR workflow with detailed examples
  • Examples: Real-world TDD scenarios with step-by-step walkthroughs
  • Philosophy: Why order matters and why tests-after don't work
  • Anti-patterns: Common mistakes, rationalizations, and red flags
  • Integration: Using TDD with debugging and other skills

Key Reminders

  • ALWAYS write the test BEFORE implementation
  • Make each test fail FIRST to verify it's testing something
  • Keep implementation minimal - just enough to pass tests
  • Refactor only when tests are green
  • One cycle at a time - small steps
  • If test passes immediately, it's not testing new behavior

Red Flags - STOP and Start Over

If you catch yourself:

  • Writing code before test
  • Test passes immediately
  • Can't explain why test failed
  • "I'll test after"
  • "Keep as reference"
  • "Already spent X hours, deleting is wasteful"
  • "Tests after achieve the same purpose"

ALL of these mean: Delete code. Start over with TDD.

Why Order Matters

Tests-after pass immediately (proves nothing), test-first fail then pass (proves it works). See Philosophy for detailed explanation.

Integration with Other Skills

  • systematic-debugging: Create failing test in Phase 4 (bug reproduction)
  • verification-before-completion: Verify tests exist and watched them fail
  • defense-in-depth: Add validation tests after implementing feature

Real-World Impact

From TDD practice:

  • Test-first: 95%+ first-time correctness
  • Test-after: 40% first-time correctness
  • TDD time: 25-45 minutes per feature (including tests)
  • Non-TDD time: 15 minutes coding + 60-120 minutes debugging

TDD is pragmatic - finds bugs before commit, prevents regressions, documents behavior, enables refactoring.

GitHub リポジトリ

bobmatnyc/claude-mpm
パス: src/claude_mpm/skills/bundled/testing/test-driven-development

関連スキル

content-collections

メタ

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

スキルを見る

evaluating-llms-harness

テスト

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

スキルを見る

cloudflare-turnstile

メタ

This skill provides comprehensive guidance for implementing Cloudflare Turnstile as a CAPTCHA-alternative bot protection system. It covers integration for forms, login pages, API endpoints, and frameworks like React/Next.js/Hono, while handling invisible challenges that maintain user experience. Use it when migrating from reCAPTCHA, debugging error codes, or implementing token validation and E2E tests.

スキルを見る

webapp-testing

テスト

This Claude Skill provides a Playwright-based toolkit for testing local web applications through Python scripts. It enables frontend verification, UI debugging, screenshot capture, and log viewing while managing server lifecycles. Use it for browser automation tasks but run scripts directly rather than reading their source code to avoid context pollution.

スキルを見る