| name | tdd-workflow |
| description | Test-Driven Development process knowledge, quality standards, and workflow guidance |
TDD Workflow Skill
Overview
This skill module provides comprehensive TDD workflow guidance, including the RED-GREEN-REFACTOR cycle, quality gates, test patterns, and anti-patterns to avoid.
Note: Examples use Java/Spring Boot conventions (JUnit 5, Gradle). Adapt commands for your stack while following the same patterns.
TDD Cycle: RED → GREEN → REFACTOR
- RED: Write a failing test that describes the expected behavior
- GREEN: Implement the minimum code to make the test pass
- REFACTOR: Improve code quality while keeping tests green
Quality Hierarchy
Quality gates are enforced in priority order:
| Priority | Gate | Tool | Threshold | Enforcement |
|---|---|---|---|---|
| 🥇 PRIMARY | Mutation Testing | PIT (pitest) | ≥80% | Blocks merge |
| 🥈 SECONDARY | Code Coverage | JaCoCo | ≥80% | Blocks merge |
| 🥉 BASELINE | Tests Pass | JUnit 5 | 100% | Always required |
Why this order?
- Code coverage can be 100% with weak assertions (tests run but don't verify)
- Mutation testing validates that tests actually catch bugs
- Both together ensure comprehensive, high-quality test suites
Core Testing Principles
- Test behavior, not implementation: Test what code should do, not how it does it
- No reflection hacks: Don't test private methods via reflection
- Test rules, not formulas: "higher values produce larger results" not exact arithmetic
- Keep test files focused: Split by behavior if tests become unwieldy
What do you need help with?
TDD Phase:
- write - Writing tests first (RED phase)
- implement - Making tests pass (GREEN phase)
- validate - Running quality gates (coverage + mutation)
- refactor - Improving code while keeping tests green (REFACTOR phase)
- lookup - Reference information (patterns, commands, anti-patterns)
What phase are you in? (write/implement/validate/refactor/lookup)
Response Routing
| Response | Workflow/Reference | Description |
|---|---|---|
| write | workflows/write-tests-first.md | RED phase - write failing tests |
| implement | workflows/make-tests-pass.md | GREEN phase - implement code |
| validate | workflows/validate-coverage.md | Run quality gates |
| refactor | workflows/refactor-safely.md | REFACTOR phase - improve code |
| lookup patterns | references/test-patterns.md | AAA, parameterized tests, factories |
| lookup commands | references/commands.md | Test commands reference |
| lookup gates | references/quality-gates.md | Thresholds and enforcement |
| lookup anti-patterns | references/anti-patterns.md | What to avoid |
Reference Files
Workflows
workflows/write-tests-first.md- RED phase workflowworkflows/make-tests-pass.md- GREEN phase workflowworkflows/validate-coverage.md- Quality gate validationworkflows/refactor-safely.md- REFACTOR phase workflow
References
references/quality-gates.md- Mutation and coverage thresholdsreferences/test-patterns.md- AAA pattern, parameterized tests, factoriesreferences/anti-patterns.md- Common anti-patterns to avoidreferences/commands.md- Test and validation commands
Templates
templates/test-file.md- New test file structuretemplates/describe-block.md- Behavior-organized test structure
Quick Reference
# CUSTOMIZE: Replace with your project's test commands
# Run tests
./gradlew test
# Run with coverage (JaCoCo)
./gradlew test jacocoTestReport
# Run mutation testing (PIT)
./gradlew pitest