Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
Add this skill
npx mdskills install sickn33/tdd-workflowComprehensive TDD principles with clear phase guidance, but lacks agent trigger conditions and workflow
1---2name: tdd-workflow3description: Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.4allowed-tools: Read, Write, Edit, Glob, Grep, Bash5---67# TDD Workflow89> Write tests first, code second.1011---1213## 1. The TDD Cycle1415```16š“ RED ā Write failing test17 ā18š¢ GREEN ā Write minimal code to pass19 ā20šµ REFACTOR ā Improve code quality21 ā22 Repeat...23```2425---2627## 2. The Three Laws of TDD28291. Write production code only to make a failing test pass302. Write only enough test to demonstrate failure313. Write only enough code to make the test pass3233---3435## 3. RED Phase Principles3637### What to Write3839| Focus | Example |40|-------|---------|41| Behavior | "should add two numbers" |42| Edge cases | "should handle empty input" |43| Error states | "should throw for invalid data" |4445### RED Phase Rules4647- Test must fail first48- Test name describes expected behavior49- One assertion per test (ideally)5051---5253## 4. GREEN Phase Principles5455### Minimum Code5657| Principle | Meaning |58|-----------|---------|59| **YAGNI** | You Aren't Gonna Need It |60| **Simplest thing** | Write the minimum to pass |61| **No optimization** | Just make it work |6263### GREEN Phase Rules6465- Don't write unneeded code66- Don't optimize yet67- Pass the test, nothing more6869---7071## 5. REFACTOR Phase Principles7273### What to Improve7475| Area | Action |76|------|--------|77| Duplication | Extract common code |78| Naming | Make intent clear |79| Structure | Improve organization |80| Complexity | Simplify logic |8182### REFACTOR Rules8384- All tests must stay green85- Small incremental changes86- Commit after each refactor8788---8990## 6. AAA Pattern9192Every test follows:9394| Step | Purpose |95|------|---------|96| **Arrange** | Set up test data |97| **Act** | Execute code under test |98| **Assert** | Verify expected outcome |99100---101102## 7. When to Use TDD103104| Scenario | TDD Value |105|----------|-----------|106| New feature | High |107| Bug fix | High (write test first) |108| Complex logic | High |109| Exploratory | Low (spike, then TDD) |110| UI layout | Low |111112---113114## 8. Test Prioritization115116| Priority | Test Type |117|----------|-----------|118| 1 | Happy path |119| 2 | Error cases |120| 3 | Edge cases |121| 4 | Performance |122123---124125## 9. Anti-Patterns126127| ā Don't | ā Do |128|----------|-------|129| Skip the RED phase | Watch test fail first |130| Write tests after | Write tests before |131| Over-engineer initial | Keep it simple |132| Multiple asserts | One behavior per test |133| Test implementation | Test behavior |134135---136137## 10. AI-Augmented TDD138139### Multi-Agent Pattern140141| Agent | Role |142|-------|------|143| Agent A | Write failing tests (RED) |144| Agent B | Implement to pass (GREEN) |145| Agent C | Optimize (REFACTOR) |146147---148149> **Remember:** The test is the specification. If you can't write a test, you don't understand the requirement.150
Full transparency ā inspect the skill content before installing.