| name | tdd-cycle |
| description | Execute a complete TDD cycle (RED → GREEN → REFACTOR) for one test. Orchestrates the full workflow from writing a failing test through implementation and refactoring to commit. |
Complete TDD Cycle
Overview
This skill orchestrates a complete Test-Driven Development cycle, guiding through all phases: RED (write failing test), GREEN (make it pass), REFACTOR (improve structure), and proper commits. Use this when you want to complete one full TDD iteration.
When to Use
Use this skill when:
- Ready to implement next test from PLAN.md
- Want to follow complete TDD workflow
- Need guidance through all TDD phases
- Want structured approach to one iteration
- Following disciplined TDD practice
Complete Workflow
Phase 1: RED - Write Failing Test
Execute tdd-red skill:
- Find next unmarked test in PLAN.md
- Write a failing test with Korean description
- Run tests to confirm failure
- Mark test as [ ] in PLAN.md
Success Criteria:
- Test fails for the right reason (missing functionality)
- Test name clearly describes behavior
- All other tests still pass
- No compilation errors
Use: /red command or tdd-red skill
Phase 2: GREEN - Make It Pass
Execute tdd-green skill:
- Verify we have a failing test
- Implement MINIMUM code to make test pass
- Run ALL tests to confirm they pass
- Mark test as [x] in PLAN.md
Success Criteria:
- New test now passes
- All existing tests still pass
- No compiler warnings
- Used simplest possible implementation
Use: /green command or tdd-green skill
Phase 3: REFACTOR - Improve Structure
Execute tdd-refactor skill (if needed):
- Verify all tests are passing
- Identify code smells or duplication
- Make structural improvements one at a time
- Run tests after each change
- Keep tests green throughout
Success Criteria:
- All tests still passing
- Code quality improved
- Duplication reduced
- Structure is clearer
When to Skip:
- Code is already clean
- No obvious improvements needed
- Would be premature optimization
Use: /refactor command or tdd-refactor skill
Phase 4: COMMIT - Save Progress
Commit Strategy:
If Structural Changes Were Made:
First, commit structural changes separately:
/commit-tidy- Use "refactor:" or "tidy:" prefix
- Clearly indicate structural changes only
Then, commit behavioral changes:
/commit-behavior- Use "feat:", "fix:", or appropriate prefix
- Describe what functionality was added
If No Structural Changes:
- Just commit behavioral changes:
/commit-behavior
Commit Prerequisites:
- ALL tests passing
- NO compiler warnings
- NO linter errors
- Clear commit message
Phase 5: REPEAT - Next Test
Prepare for Next Cycle:
- Verify clean state (all tests pass)
- Review PLAN.md for next test
- Start new RED phase when ready
Execution Flow
START
↓
RED: Write failing test
↓
Confirm test fails? ──No──> Fix test
↓ Yes
GREEN: Implement minimum code
↓
All tests pass? ──No──> Debug & fix
↓ Yes
Need refactoring? ──Yes──> REFACTOR: Improve structure
↓ No ↓
←───────────────────────────┘
COMMIT: Save changes
↓
Next test? ──Yes──> START
↓ No
DONE
Key Principles
RED Phase:
- Write smallest failing test
- Test one thing only
- Fail for right reason
GREEN Phase:
- Simplest implementation
- No premature optimization
- Make it work, not perfect
REFACTOR Phase:
- Only when green
- One change at a time
- Keep tests green
COMMIT Phase:
- Separate structural from behavioral
- All tests passing
- Clear messages
Important Reminders
- NEVER skip RED - always write test first
- NEVER write more code than needed in GREEN
- NEVER refactor on red tests
- ALWAYS run tests after each phase
- ALWAYS keep commits small and focused
- ONE test at a time
- ONE refactoring at a time
Useful Commands
Within this cycle, you can use:
/red- Execute RED phase/green- Execute GREEN phase/refactor- Execute REFACTOR phase/tidy- Make structural changes (Tidy First)/commit-tidy- Commit structural changes/commit-behavior- Commit behavioral changes/run-tests- Run all tests/next-test- View next test in PLAN.md
Example Complete Cycle
RED: Write test "should calculate total price with discount"
- Test fails:
calculateTotalWithDiscount is not defined
- Test fails:
GREEN: Implement basic calculation
function calculateTotalWithDiscount(price, discount) { return price - discount; }- All tests pass
REFACTOR: Extract validation logic
- Add input validation
- Extract discount calculation
- All tests still pass
COMMIT:
- Commit refactoring: "refactor: extract discount calculation logic"
- Commit feature: "feat: add total price calculation with discount"
REPEAT: Move to next test
Next Steps
After completing one full cycle:
- Verify clean state
- Check PLAN.md for next test
- Start new cycle with RED phase
- Continue until feature complete