Use when working with tdd workflows tdd cycle
Add this skill
npx mdskills install sickn33/tdd-workflows-tdd-cycleComprehensive TDD workflow with strict phase gating, coverage thresholds, and orchestration
1---2name: tdd-workflows-tdd-cycle3description: "Use when working with tdd workflows tdd cycle"4---56## Use this skill when78- Working on tdd workflows tdd cycle tasks or workflows9- Needing guidance, best practices, or checklists for tdd workflows tdd cycle1011## Do not use this skill when1213- The task is unrelated to tdd workflows tdd cycle14- You need a different domain or tool outside this scope1516## Instructions1718- Clarify goals, constraints, and required inputs.19- Apply relevant best practices and validate outcomes.20- Provide actionable steps and verification.21- If detailed examples are required, open `resources/implementation-playbook.md`.2223Execute a comprehensive Test-Driven Development (TDD) workflow with strict red-green-refactor discipline:2425[Extended thinking: This workflow enforces test-first development through coordinated agent orchestration. Each phase of the TDD cycle is strictly enforced with fail-first verification, incremental implementation, and continuous refactoring. The workflow supports both single test and test suite approaches with configurable coverage thresholds.]2627## Configuration2829### Coverage Thresholds30- Minimum line coverage: 80%31- Minimum branch coverage: 75%32- Critical path coverage: 100%3334### Refactoring Triggers35- Cyclomatic complexity > 1036- Method length > 20 lines37- Class length > 200 lines38- Duplicate code blocks > 3 lines3940## Phase 1: Test Specification and Design4142### 1. Requirements Analysis43- Use Task tool with subagent_type="comprehensive-review::architect-review"44- Prompt: "Analyze requirements for: $ARGUMENTS. Define acceptance criteria, identify edge cases, and create test scenarios. Output a comprehensive test specification."45- Output: Test specification, acceptance criteria, edge case matrix46- Validation: Ensure all requirements have corresponding test scenarios4748### 2. Test Architecture Design49- Use Task tool with subagent_type="unit-testing::test-automator"50- Prompt: "Design test architecture for: $ARGUMENTS based on test specification. Define test structure, fixtures, mocks, and test data strategy. Ensure testability and maintainability."51- Output: Test architecture, fixture design, mock strategy52- Validation: Architecture supports isolated, fast, reliable tests5354## Phase 2: RED - Write Failing Tests5556### 3. Write Unit Tests (Failing)57- Use Task tool with subagent_type="unit-testing::test-automator"58- Prompt: "Write FAILING unit tests for: $ARGUMENTS. Tests must fail initially. Include edge cases, error scenarios, and happy paths. DO NOT implement production code."59- Output: Failing unit tests, test documentation60- **CRITICAL**: Verify all tests fail with expected error messages6162### 4. Verify Test Failure63- Use Task tool with subagent_type="tdd-workflows::code-reviewer"64- Prompt: "Verify that all tests for: $ARGUMENTS are failing correctly. Ensure failures are for the right reasons (missing implementation, not test errors). Confirm no false positives."65- Output: Test failure verification report66- **GATE**: Do not proceed until all tests fail appropriately6768## Phase 3: GREEN - Make Tests Pass6970### 5. Minimal Implementation71- Use Task tool with subagent_type="backend-development::backend-architect"72- Prompt: "Implement MINIMAL code to make tests pass for: $ARGUMENTS. Focus only on making tests green. Do not add extra features or optimizations. Keep it simple."73- Output: Minimal working implementation74- Constraint: No code beyond what's needed to pass tests7576### 6. Verify Test Success77- Use Task tool with subagent_type="unit-testing::test-automator"78- Prompt: "Run all tests for: $ARGUMENTS and verify they pass. Check test coverage metrics. Ensure no tests were accidentally broken."79- Output: Test execution report, coverage metrics80- **GATE**: All tests must pass before proceeding8182## Phase 4: REFACTOR - Improve Code Quality8384### 7. Code Refactoring85- Use Task tool with subagent_type="tdd-workflows::code-reviewer"86- Prompt: "Refactor implementation for: $ARGUMENTS while keeping tests green. Apply SOLID principles, remove duplication, improve naming, and optimize performance. Run tests after each refactoring."87- Output: Refactored code, refactoring report88- Constraint: Tests must remain green throughout8990### 8. Test Refactoring91- Use Task tool with subagent_type="unit-testing::test-automator"92- Prompt: "Refactor tests for: $ARGUMENTS. Remove test duplication, improve test names, extract common fixtures, and enhance test readability. Ensure tests still provide same coverage."93- Output: Refactored tests, improved test structure94- Validation: Coverage metrics unchanged or improved9596## Phase 5: Integration and System Tests9798### 9. Write Integration Tests (Failing First)99- Use Task tool with subagent_type="unit-testing::test-automator"100- Prompt: "Write FAILING integration tests for: $ARGUMENTS. Test component interactions, API contracts, and data flow. Tests must fail initially."101- Output: Failing integration tests102- Validation: Tests fail due to missing integration logic103104### 10. Implement Integration105- Use Task tool with subagent_type="backend-development::backend-architect"106- Prompt: "Implement integration code for: $ARGUMENTS to make integration tests pass. Focus on component interaction and data flow."107- Output: Integration implementation108- Validation: All integration tests pass109110## Phase 6: Continuous Improvement Cycle111112### 11. Performance and Edge Case Tests113- Use Task tool with subagent_type="unit-testing::test-automator"114- Prompt: "Add performance tests and additional edge case tests for: $ARGUMENTS. Include stress tests, boundary tests, and error recovery tests."115- Output: Extended test suite116- Metric: Increased test coverage and scenario coverage117118### 12. Final Code Review119- Use Task tool with subagent_type="comprehensive-review::architect-review"120- Prompt: "Perform comprehensive review of: $ARGUMENTS. Verify TDD process was followed, check code quality, test quality, and coverage. Suggest improvements."121- Output: Review report, improvement suggestions122- Action: Implement critical suggestions while maintaining green tests123124## Incremental Development Mode125126For test-by-test development:1271. Write ONE failing test1282. Make ONLY that test pass1293. Refactor if needed1304. Repeat for next test131132Use this approach by adding `--incremental` flag to focus on one test at a time.133134## Test Suite Mode135136For comprehensive test suite development:1371. Write ALL tests for a feature/module (failing)1382. Implement code to pass ALL tests1393. Refactor entire module1404. Add integration tests141142Use this approach by adding `--suite` flag for batch test development.143144## Validation Checkpoints145146### RED Phase Validation147- [ ] All tests written before implementation148- [ ] All tests fail with meaningful error messages149- [ ] Test failures are due to missing implementation150- [ ] No test passes accidentally151152### GREEN Phase Validation153- [ ] All tests pass154- [ ] No extra code beyond test requirements155- [ ] Coverage meets minimum thresholds156- [ ] No test was modified to make it pass157158### REFACTOR Phase Validation159- [ ] All tests still pass after refactoring160- [ ] Code complexity reduced161- [ ] Duplication eliminated162- [ ] Performance improved or maintained163- [ ] Test readability improved164165## Coverage Reports166167Generate coverage reports after each phase:168- Line coverage169- Branch coverage170- Function coverage171- Statement coverage172173## Failure Recovery174175If TDD discipline is broken:1761. **STOP** immediately1772. Identify which phase was violated1783. Rollback to last valid state1794. Resume from correct phase1805. Document lesson learned181182## TDD Metrics Tracking183184Track and report:185- Time in each phase (Red/Green/Refactor)186- Number of test-implementation cycles187- Coverage progression188- Refactoring frequency189- Defect escape rate190191## Anti-Patterns to Avoid192193- Writing implementation before tests194- Writing tests that already pass195- Skipping the refactor phase196- Writing multiple features without tests197- Modifying tests to make them pass198- Ignoring failing tests199- Writing tests after implementation200201## Success Criteria202203- 100% of code written test-first204- All tests pass continuously205- Coverage exceeds thresholds206- Code complexity within limits207- Zero defects in covered code208- Clear test documentation209- Fast test execution (< 5 seconds for unit tests)210211## Notes212213- Enforce strict RED-GREEN-REFACTOR discipline214- Each phase must be completed before moving to next215- Tests are the specification216- If a test is hard to write, the design needs improvement217- Refactoring is NOT optional218- Keep test execution fast219- Tests should be independent and isolated220221TDD implementation for: $ARGUMENTS222
Full transparency — inspect the skill content before installing.