---
description: Test-Driven Development workflow (Red-Green-Refactor)
---

# TDD Workflow Skill

## Principles
1. **Red**: Never write implementation code without a failing test first.
2. **Green**: Write just enough code to pass the test.
3. **Refactor**: Clean up the code while keeping tests green.

## Cycle
1. **Create Test**: Write a test case for the specific functionality you are about to build.
   - E.g., `it('should calculate total price correctly', ...)`
2. **Run Test**: Confirm it fails (`RED`).
3. **Implement**: Write the logic.
4. **Run Test**: Confirm it passes (`GREEN`).
5. **Optimize**: Refactor for readability/performance.
6. **Repeat**.

## Guidelines
- **Unit Tests**: For pure logic/functions. use `vitest` or `jest`.
- **Integration Tests**: For API/Database interactions.
- **Coverage**: Aim for high coverage on critical paths.
