tdd
RED-GREEN-REFACTOR cycle enforcement for test-driven development.
Files1
View on GitHubSKILL.mdskills/tdd/SKILL.md
GitHubTDD Command
Enforce a strict RED-GREEN-REFACTOR test-driven development cycle.
Usage
[tdd] Add retry logic to circuit breaker
[tdd] Fix delegation token expiry off-by-one
Execution
Phase 1: RED (Write a failing test)
- Ask the user to clarify the expected behavior if
$ARGUMENTSis ambiguous. - Write the test first in the appropriate test file under
$PROJECT_ROOT/tests/. - Run the test and verify it FAILS:
python -m pytest <test_file>::<test_function> -v - Hard gate: The test MUST fail. If it passes, the behavior already exists -- inform the user and stop.
- Commit with message:
test: add failing test for <description>
Phase 2: GREEN (Minimal implementation)
- Write the minimum code to make the test pass. No extras.
- Run the test and verify it PASSES:
python -m pytest <test_file>::<test_function> -v - Hard gate: The test MUST pass. If it fails, fix the implementation (not the test).
- Run the full suite to check for regressions:
python -m pytest $PROJECT_ROOT/tests/ -x -q - Commit with message:
feat: implement <description>orfix: <description>
Phase 3: REFACTOR (Clean up)
- Review the implementation for clarity, duplication, naming.
- Make improvements without changing behavior (tests must still pass).
- Run the full suite again to confirm no regressions.
- Commit with message:
refactor: clean up <description>
Output Format
Report status at each phase gate:
TDD Cycle | <description>
═════════════════════════
🔴 RED — Test written: <test_file>::<test_name>
Result: FAIL (expected) ✓
🟢 GREEN — Implementation: <file>:<lines>
Result: PASS ✓
Regressions: 0
🔵 REFACTOR — Changes: <summary>
Result: PASS ✓
Regressions: 0
Constraints
- Never skip a phase. The gates are mandatory.
- Write the test BEFORE any implementation code.
- The GREEN phase implements the MINIMUM to pass -- no gold-plating.
- If the user asks to skip RED, explain why it matters but comply if they insist.
- All commits use conventional commit format.