Test driven development

From bobmatnyc/claude-mpm · View interactive version

Test driven development is an AI agent skill from the GitHub repository bobmatnyc/claude-mpm. Write the test first, watch it fail, write minimal code to pass

How to use this skill

Skill file

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:

Exceptions (ask human partner):

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:

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:

Key Reminders

Red Flags - STOP and Start Over

If you catch yourself:

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

Real-World Impact

From TDD practice:

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.