# Test Driven Development

Write software using the RED-GREEN-REFACTOR cycle for reliable, well-tested code

- Repository: https://github.com/taracodlabs/aiden (868 stars)
- Category: Writing
- License: Apache-2.0
- Last updated: 2026-10-19
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add taracodlabs/aiden --skill test-driven-development -g -a claude-code -y`
Codex: `npx skills add taracodlabs/aiden --skill test-driven-development -g -a codex -y`
Cursor: `npx skills add taracodlabs/aiden --skill test-driven-development -g -a cursor -y`
Gemini CLI: `npx skills add taracodlabs/aiden --skill test-driven-development -g -a gemini-cli -y`

## Description

Write software using the RED-GREEN-REFACTOR cycle for reliable, well-tested code

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Test-Driven Development (TDD)

Use the RED-GREEN-REFACTOR cycle to write reliable, well-tested software. Write tests first, then write the minimal code to pass them, then clean up.

## When to Use

- User wants to implement a new function or module correctly
- User wants to ensure edge cases are handled before they become bugs
- User is refactoring and wants a safety net
- User wants tests for business-critical logic
- User wants to document behavior through executable tests

## How to Use

### The TDD cycle

```
RED    → Write a failing test for the behavior you want
GREEN  → Write the minimum code to make the test pass
REFACTOR → Clean up the code without breaking tests
Repeat for each small behavior increment
```

### Phase 1: RED, Write a failing test first

Write the test before the implementation. It must fail to prove the test works.

```python
# test_calculator.py, write this BEFORE calculator.py
import pytest
from calculator import add

def test_add_two_positive_numbers():
  assert add(2, 3) == 5

def test_add_negative_number():
  assert add(-1, 5) == 4

def test_add_floats():
  assert abs(add(0.1, 0.2) - 0.3) < 1e-9
```

Run the tests, they should fail with `ModuleNotFoundError` or `ImportError`:

```powershell
pytest test_calculator.py -v
# Expected: FAILED (module not found)
```

### Phase 2: GREEN, Minimal implementation to pass

Write only enough code to make the tests pass, nothing more.

```python
# calculator.py
def add(a, b):
  return a + b
```

```powershell
pytest test_calculator.py -v
# Expected: 3 PASSED
```

### Phase 3: REFACTOR, Improve code quality

Clean up implementation and tests while keeping all tests green.

```python
# calculator.py, add type hints and docstring
def add(a: float, b: float) -> float:
  """Return the sum of a and b."""
  return a + b
```

```powershell
pytest test_calculator.py -v  # must still pass after refactor
```

### Write tests with pytest (Python)

The rest: https://github.com/taracodlabs/aiden/blob/HEAD/skills/test-driven-development/SKILL.md
