This skill enforces Test-Driven Development (TDD) discipline through the RED-GREEN-REFACTOR cycle. It implements the Iron Law: no production code can be written without a failing test that justifies its existence.
Prerequisites
Understanding of TDD principles and RED-GREEN-REFACTOR cycle
Test framework for the target language (pytest, Jest, cargo test, etc.)
Version control (Git) for tracking TDD commits
AI Maestro for delegating to Remote Developer Agents
Instructions
Write a failing test (RED) - Create a test that documents the intended behavior. Run it to confirm it fails.
Make the test pass (GREEN) - Write the minimum code needed to make the test pass. Run all tests to confirm.
Refactor the code (REFACTOR) - Improve code quality while keeping all tests passing. Run tests after each refactoring step.
相關技能
Commit after each phase - Use git commits with RED:/GREEN:/REFACTOR: prefixes to track progress.
Return to RED for next feature - After completing one cycle, start the next feature with a new failing test.
Critical Rule: Never write production code without a failing test first.
Output
Output Type
Description
TDD Status Report
Current phase status (pending, RED, GREEN, refactor) for each feature being developed
Git Commit Messages
Structured commits following pattern: RED: test for [feature], GREEN: implement [feature], REFACTOR: improve [aspect]
Test Execution Results
Pass/fail status of test suites after each phase transition
Enforcement Decisions
Allow/deny decisions for code changes based on TDD compliance (tests must exist before code)
Documentation of TDD discipline violations with recovery procedures
Progress Tracking Updates
Multi-feature TDD cycle tracking with phase completion status
The Coordinator's Role
This skill enforces TDD discipline on remote agents. The coordinator delegates testing and coding to developer agents — it verifies compliance, not performs implementation.
Coordinator Responsibilities:
VERIFY remote agents follow TDD (tests before code)
REVIEW PRs to ensure TDD was followed
REJECT work that violates TDD principles
DELEGATE all test writing and code implementation to Remote Developer Agents via AI Maestro
The TDD Cycle
TDD operates through three phases in strict order:
RED: Write a failing test that documents intended behavior
GREEN: Write minimum code to make the test pass
REFACTOR: Improve code quality while maintaining behavior
After completing one cycle, return to RED for the next feature.
How to Use This Skill
This SKILL.md is a map to detailed reference documents. Each section below shows when to read each reference file. Click the links to access the full content.
# Phase 1: RED - Write failing test
git add tests/test_user_auth.py
git commit -m "RED: test for user authentication"
# Run tests - should FAIL
# Phase 2: GREEN - Implement minimum code
git add src/auth.py
git commit -m "GREEN: implement user authentication"
# Run tests - should PASS
# Phase 3: REFACTOR - Improve code quality
git add src/auth.py
git commit -m "REFACTOR: extract password validation to separate function"
# Run tests - should still PASS
Issue: Test passes on first run (RED phase failed)
Cause: Test is not testing the right thing or code already exists.
Solution: Ensure the test fails before writing implementation. If test passes immediately, either the test is wrong or you're not in a true RED state.
Issue: Production code written without failing test
Cause: TDD discipline violation.
Solution: Revert the production code, write the failing test first, then reimplement. Use the Violation Recovery Procedure in references/rules-and-constraints.md.
Issue: Refactoring breaks tests
Cause: Behavior changed during refactoring.
Solution: Refactoring must preserve behavior. Revert to GREEN state and try smaller refactoring steps.