Test-Driven Development Workflow
Implement $ARGUMENTS using strict TDD methodology.
Dynamic Context
- •Test framework: !
ls package.json 2>/dev/null && node -e "const p=require('./package.json');const d={...p.devDependencies,...p.dependencies};const f=['vitest','jest','mocha','ava','playwright','cypress'].find(t=>d[t]);console.log(f||'unknown')" 2>/dev/null || ls pytest.ini setup.cfg pyproject.toml Cargo.toml go.mod 2>/dev/null | head -1 || echo "unknown" - •Existing test patterns: !
find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' 2>/dev/null | head -5 || echo "No tests found" - •Source structure: !
ls src/ app/ lib/ 2>/dev/null | head -10 || echo "N/A"
Red-Green-Refactor Protocol
Phase 1: RED - Write Failing Test
- •Create test file following project naming convention
- •Write one test case for the simplest expected behavior
- •Run test suite — confirm the test fails with expected error
- •If test passes without implementation, the test is wrong — rewrite it
Phase 2: GREEN - Minimal Implementation
- •Write the minimum code to make the failing test pass
- •No optimization, no generalization, no cleanup
- •Run test suite — confirm all tests pass (new + existing)
- •If any test fails, fix implementation (not the test)
Phase 3: REFACTOR - Improve Design
- •Remove duplication in both test and production code
- •Improve naming, extract methods, simplify logic
- •Run test suite after every change — maintain green
- •Apply SOLID principles where applicable
Phase 4: REPEAT
Return to Phase 1 with the next behavior. Continue until feature is complete.
Cycle Discipline
- •One assertion per test (except closely related state checks)
- •No production code without a failing test first
- •No refactoring while red — get green first, then refactor
- •Commit after each green phase (small, reversible increments)
Completion Criteria
Before declaring done:
- • All acceptance criteria covered by tests
- • Edge cases tested (null, empty, boundary, invalid input)
- • Error paths tested (exceptions, failure modes)
- • No skipped or commented-out tests
- • All tests pass in isolation and as suite
- • Existing tests unbroken (no regressions)
Per-Cycle Report
After each Red-Green-Refactor cycle, report:
code
Cycle [N]: Test: [test name and file] Status: RED → GREEN → REFACTORED Implementation: [file:line changed] Tests passing: [X/Y]
Final Summary
code
Feature: $ARGUMENTS Cycles completed: [N] Tests added: [N] Files created: [list] Files modified: [list] All tests passing: YES/NO