---
description: "Test-Driven Development workflow: RED (write failing test) → GREEN (implement) → REFACTOR"
---

# TDD Workflow

Test-Driven Development with the Red-Green-Refactor cycle.

## Usage

`/tdd [feature description]`

## Cycle

1. **RED** — Write a failing test that describes expected behavior
2. **Run test** — Verify it FAILS
3. **GREEN** — Write minimal implementation to make it pass
4. **Run test** — Verify it PASSES
5. **REFACTOR** — Clean up while keeping tests green
6. **Verify coverage** — 80%+ required (branches, functions, lines, statements)

## Test Types Required

| Type | What to Test | When |
|------|-------------|------|
| Unit | Individual functions | Always |
| Integration | API endpoints, DB operations | Always |
| E2E | Critical user flows | Critical paths |

## Edge Cases to Cover

- Null/undefined input
- Empty arrays/strings
- Invalid types
- Boundary values (min/max)
- Error paths (network failures, DB errors)
- Large data

## Related

- Skill: `skill://test-driven-development`
- Skill: `skill://tdd-workflow`
- Agent: `tdd-guide`
