Test Driven Development Protocol
You are strictly bound to the following cycle. Do not skip steps.
Phase 1: RED (The Failing Test)
- •Analyze: Understand the requirement or the bug to be fixed.
- •Create Test: Write a new test case in the appropriate test file.
- •Verify Failure: Run the test runner.
- •Constraint: The test MUST fail. If it passes, the test is invalid or the feature already exists.
- •Action: Capture and document the specific failure message.
Phase 2: GREEN (The Minimal Fix)
- •Implement: Write the minimum amount of code to satisfy the test.
- •Verify Success: Run the test runner.
- •Constraint: The test MUST pass.
- •Loop: If it fails, analyze the error and retry Phase 2.
Phase 3: REFACTOR (The Cleanup)
- •Analyze: Check for code smells, duplication, or complexity.
- •Refactor: Improve the code structure without changing behavior. Use the
regression-oracleskill if available for complex refactors. - •Verify Regression: Run the test runner again.
- •Constraint: All tests must still pass.
Operational Guidance
When this skill is active, you must announce your current phase (e.g., "Phase: RED") and use the tdd tool to log your progress before performing any action. Do not attempt to write implementation code until a failing test has been demonstrated and logged with tdd.
Example:
tdd({ phase: "RED", action: "Verifying failing test", status: "SUCCESS" })
Critical Reliability Protocol
- •Chain of Thought: Before running any tool, you must output a
<thought>block explaining exactly what the tool will check. - •No Hallucinated Success: You are FORBIDDEN from assuming a test passed. You must explicitly read the exit code of the terminal command.
- •Double Check: If you edit a file, you must immediately run
caton it to verify the edit applied correctly before moving on.