SKILL: TDD Workflow
The RED → GREEN → REFACTOR Cycle
RED Phase (QA Agent)
- •Read the acceptance criterion or task description.
- •Write a test that will fail because the implementation doesn't exist.
- •Run the test. It MUST fail with a meaningful error (not a syntax error).
- •If the test passes immediately → the test is wrong. Rewrite it.
- •Report: file path, test name, failure message.
GREEN Phase (Specialist Agent)
- •Read the failing test file at the provided path.
- •Implement the MINIMUM code to make ONLY that test pass.
- •Do not implement anything not required by the test.
- •Run the test. It must pass.
- •Run the full unit suite to verify no regressions.
- •If the test fails after 3 attempts → escalate to Orchestrator.
REFACTOR Phase (Specialist Agent)
- •Look for: duplication, poor naming, long functions, complex conditionals.
- •Clean up without changing behavior.
- •Run the test again. It must still pass.
- •Commit:
git commit -m "refactor: {what was cleaned up}"
ATDD Pattern (Acceptance Test-Driven Development)
- •Write the E2E/acceptance test from the acceptance criterion (Given/When/Then).
- •Watch it fail (RED).
- •Drive out unit tests and implementation to make it pass (GREEN).
- •Acceptance test goes green last.
Integration Test Container Lifecycle
bash
# Before integration tests docker compose -f docker-compose.test.yml up -d --wait # Seed test data ./scripts/seed-test.sh # or make seed-test # Run integration tests make test-integration # After tests docker compose -f docker-compose.test.yml down -v
Rules
- •Test file is created BEFORE implementation file.
- •Test name format: "should {expected outcome} when {condition}".
- •Never weaken an assertion to make a test pass.
- •Never mock what you can test with a real dependency (use containers).
- •Implementation agent receives FILE PATH, not requirement text.
- •Gate: test must fail before implementation, pass after.