# TDD a Feature

> Red → green → refactor. Failing test first, minimum-code to pass, refactor only after green.

- **Kind**: Shell tool
- **Category**: engineering
- **Owner**: Sentinel (/sentinel)
- **Default model**: sonnet
- **Cost class**: standard (Sonnet-class model. Default for most skills.)
- **Turn budget**: 15
- **Execution**: synchronous (result lands in the same turn)
- **Canonical URL**: https://app.51ultron.com/docs/skills/tdd-feature

## What it does

Strict TDD discipline. Writes the failing test via shell_write, runs it via shell_exec, watches it fail (red), implements the minimum code to make it pass (green), only then considers refactoring (per minimal-patch/SKILL.md). Forbidden to skip the red phase. Forbidden to refactor while red.

## When to use this

- user wants to build a new feature TDD-style
- user says 'TDD this' / 'red green refactor' / 'write the test first'
- user wants strong test coverage from day one

## When NOT to use this

- feature has no testable interface → use spin-up-web-app or shell_exec directly
- user is fixing a bug, not adding a feature → use minimal-patch + add regression test

## Example prompts

- `TDD a function that validates email addresses`
- `build the rate-limiter TDD style`
- `red-green-refactor a new endpoint /api/foo`

## Inputs

- **feature**: what to build in one sentence
- **test_runner**: pnpm test | bun test | etc.

## Output

Implementation file + test file + the green test-runner output.

## Tools used

`shell_exec`, `shell_write`, `shell_read`

## Execution template

Shell tools dispatch through `shell_exec` with the following command template:

```bash
write failing test for {{feature}} -> {{test_runner}} (RED) -> implement min code -> {{test_runner}} (GREEN) -> refactor per minimal-patch/SKILL.md
```

## Tags

`engineering`, `test`, `discipline`

## Keywords

tdd, test driven, red green refactor, write test first, failing test

