Use when implementing features with test-driven development, writing tests before code, or following the red-green-refactor cycle
View on GitHubJoshuaOliphant/claude-plugins
autonomous-sdlc
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/JoshuaOliphant/claude-plugins/blob/main/plugins/autonomous-sdlc/skills/tdd-workflow/SKILL.md -a claude-code --skill tdd-workflowInstallation paths:
.claude/skills/tdd-workflow/# Test-Driven Development Workflow
TDD is the foundation of verification-driven development. Write tests first, then implement code to make them pass.
## The Red-Green-Refactor Cycle
```
┌─────────────────────────────────────────────────────┐
│ │
│ RED: Write failing test │
│ ↓ │
│ GREEN: Write minimal code to pass │
│ ↓ │
│ REFACTOR: Improve code while keeping tests green │
│ ↓ │
│ (repeat) │
│ │
└─────────────────────────────────────────────────────┘
```
## Step-by-Step Process
### 1. RED - Write a Failing Test
```python
# tests/test_user_service.py
def test_create_user_returns_user_with_id():
"""Test that creating a user returns a user with an assigned ID."""
service = UserService()
user = service.create_user(name="Alice", email="alice@example.com")
assert user.id is not None
assert user.name == "Alice"
assert user.email == "alice@example.com"
```
Run test to confirm it fails:
```bash
uv run pytest tests/test_user_service.py::test_create_user_returns_user_with_id -x
# Expected: FAILED (UserService doesn't exist)
```
### 2. GREEN - Minimal Implementation
Write just enough code to make the test pass:
```python
# src/user_service.py
from dataclasses import dataclass
import uuid
@dataclass
class User:
id: str
name: str
email: str
class UserService:
def create_user(self, name: str, email: str) -> User:
return User(id=str(uuid.uuid4()), name=name, email=email)
```
Run test to confirm it passes:
```bash
uv run pytest tests/test_user_service.py::test_create_user_returns_user_with_id -x
# Expected: PASSED
```
### 3. REFACTOR - Improve While Green
Now improve the code (