CClaude Code Catalog
All Skills

TDD Guard

CodingIntermediate

Enforces the TDD cycle during feature implementation. Guides you through writing a failing test first, making it pass with minimal code, then refactoring -- the Red-Green-Refactor loop.

Trigger/tdd
FrequencyDaily

Developer who wants to try TDD but can't build the habit? Run /tdd to enforce the cycle and internalize it naturally

Team lead? Auto-verify TDD compliance during code review

TDDTestingQualityDevelopment Methodology

How It Works

Run /tdd [feature description]
Phase 1: 2 preparation tasks in parallel
test-plan
Design test cases
framework-detect
Detect test framework
Red -> Green -> Refactor loop iteration
Tests passing + refactored code

Skill Code

# TDD Guard Skill ## Trigger: /tdd [feature description] IMPORTANT: Enforce strict Red-Green-Refactor cycle. NEVER write implementation before a failing test. For EACH test case, follow this exact loop: ### 🔴 RED Phase - Write ONE failing test - Run it → confirm it FAILS - If it passes without new code → test is wrong ### 🟢 GREEN Phase - Write MINIMUM code to make test pass - No extra logic, no premature optimization - Run test → confirm it PASSES ### ♻️ REFACTOR Phase - Improve code quality - Run ALL tests → confirm everything PASSES - If any test fails → undo, try again Repeat for next test case. Output: --- ## ✅ TDD Complete ### Test Coverage | Test | Status | Cycle | |------|--------|-------| | [name] | ✅ | Red→Green→Refactor | ### Code Health - Tests: [N] passing - Coverage: [X%] ---

Copy and paste into your CLAUDE.md to start using immediately.

How TDD Guard Works

TDD Guard enforces the Red-Green-Refactor cycle by requiring you to write a failing test first, then implement just enough code to pass it, and finally refactor — blocking any implementation code that doesn't have a corresponding test.

When to Use TDD Guard

Critical for teams adopting TDD practices who need guardrails to maintain discipline, and for complex features where writing tests first reveals design issues early before they become expensive to fix.

Key Strengths

  • Enforces strict Red-Green-Refactor discipline automatically
  • Prevents untested code from being written
  • Improves code design by requiring testability upfront
  • Builds test-first habits that compound over time

Same Category

Coding View All

Popular in Other Categories