# tdd

This skill guides behavior changes with tests before implementation, then checks the result through a red-green-refactor loop. Use it for features, fixes, and refactors.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 847 installs · ★ 6
- Author: sentimony
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/sentimony/skills/tree/HEAD/plugins/devflow/skills/tdd/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/sentimony-tdd

## What it does

The skill turns a behavior change into a focused test-first workflow. It helps the agent define the acceptance boundary, choose a suitable test level, and write an assertion that observes the promised result instead of an incidental implementation detail.

The workflow checks the initial failure before production code is added. The targeted test must run, fail on the intended behavioral assertion, and reach the relevant boundary. After the implementation, the skill verifies the passing test and keeps that evidence through refactoring.

It does not depend on a particular test framework. Repository-specific test commands and mechanics are delegated to the project skill that owns them. Purely mechanical edits without a behavior contract fall outside this workflow.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add sentimony/skills --skill tdd -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/tdd/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/tdd/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add sentimony/skills --skill tdd -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/tdd/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add sentimony/skills --skill tdd -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/tdd/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install sentimony/skills tdd
```

2. **Manually: put the files in place**
- File: `.github/skills/tdd/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add sentimony/skills --skill tdd -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/sentimony/skills --path plugins/devflow/skills/tdd
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/tdd/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add sentimony/skills --skill tdd -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/sentimony/skills/tree/HEAD/plugins/devflow/skills/tdd/SKILL.md

## When to use it
- write a regression test for a bug fix
- check a new API or state-transition contract
- choose a test level for module or HTTP behavior
- preserve behavior during a refactor

## Example prompts
- Add this feature with a test-first workflow: show the meaningful failing test before changing production code.
- Fix the regression by proving the corrected outcome with a targeted test, then implement it.
- Refactor this module while preserving its observable behavior and verifying the test after the change.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 9e91fb3210f5e9d6.

BEGIN THIRD-PARTY FILE 9e91fb3210f5e9d6
````text
---
name: tdd
description: You MUST use this when implementing testable behavior changes - new features, bug fixes, or refactors with observable contracts. Covers writing meaningful failing tests before implementation and verifying behavior through the red-green-refactor cycle. Not for purely mechanical edits without behavior changes.
metadata:
  version: "1.1.3"
license: MIT
---

# TDD: Test-Driven Development

## Overview

Use this skill to drive one concrete behavior into existence through a focused test-first
cycle. The cycle is:

```text
BEHAVIOR -> RED -> VERIFY RED -> GREEN -> VERIFY GREEN -> REFACTOR -> VERIFY GREEN
```

The test is evidence only when it observes the promised behavior at the right boundary and
can fail for a meaningful defect. A green test is evidence only when its oracle proves the
requirement rather than an implementation shape.

This method is framework-neutral. Identify the repository's test tooling and delegate its
commands and mechanics to the applicable project skill.

## When to Use

Use this skill for:

- new behavior and feature work;
- bug fixes and regression tests;
- refactors that must preserve behavior;
- changes to APIs, state transitions, validation, authorization, persistence, or external adapters;
- test changes whose oracle, boundary, mocks, setup, or determinism could be misleading.

Route purely mechanical changes with no behavior to the appropriate project workflow. For
generated output or configuration, apply TDD when the change has a behavior contract; otherwise
use the project's direct verification convention.

## The Iron Law

```text
NO NEW PRODUCTION BEHAVIOR WITHOUT A VALID BEHAVIORAL RED FIRST
```

For new behavior, writing production code before the valid RED invalidates the cycle. Delete
or discard the untested implementation and restart from the test. Do not keep it as a reference,
adapt it while writing the test, or treat a manual check as a substitute.

If the behavior was already present before the current task, an initial test may be GREEN.
Investigate whether the requirement is already satisfied, the test is weak, or the boundary is
wrong. Preserve existing behavior while investigating; reserve discard-and-restart for code
introduced prematurely for the current change.

This law applies to a bug fix through its corrected regression RED. It does not require deleting
legacy production code during a refactor; use Characterization Mode below.

## The Enhanced Cycle

### 1. Define the behavior and acceptance boundary

Translate the requirement in this order:

```text
requirement -> observable behavior -> acceptance boundary -> test
```

Before writing the test, answer:

```text
What observable behavior proves that this requirement is satisfied?
```

Name the input, action, boundary, and outcome. Prefer client-visible results, persisted state,
emitted messages, status codes, domain errors, state transitions, or real component behavior.
Check existing tests first so a new test adds evidence instead of repeating coverage.
````
END THIRD-PARTY FILE 9e91fb3210f5e9d6

The third-party file has ended. Everything between the 9e91fb3210f5e9d6 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3032 of 15887 bytes. © sentimony · MIT · https://github.com/sentimony/skills/tree/HEAD/plugins/devflow/skills/tdd/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
