# TDD loop

> TDD loop is an open-source agent skill for developer tools. Runs a red-green-refactor test loop with auto-detected test runners and exit codes. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/ramboz/jig/tree/main/hosts/claude/skills/tdd-loop
- **Repository:** https://github.com/ramboz/jig
- **GitHub stars:** 6
- **License:** MIT
- **Skill name:** tdd-loop
- **Collection:** https://github.com/ramboz/jig
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill guides an agent through test-driven development: write one failing test for a single acceptance criterion, implement the minimum to pass it, then refactor while re-running the suite. It adds a discipline rule for pre-existing tests: when one goes red, the agent should first suspect its own change rather than weaken or skip the test.

A bundled Python helper, tdd.py, handles the mechanics. Its detect subcommand identifies the project's runner among pytest, vitest, jest and Node's built-in node --test, using filesystem signals and a fixed priority order. Its run subcommand executes the suite, optionally scoped to a file or a single test, streams output, and normalizes the result to exit 0 for green, 1 for red and 2 when tests could not run. Projects using other stacks can supply a .jig/test-command file that follows the same exit contract, with a companion reference document of recipes.

The skill expects Python 3 on the path and the project's own test tooling installed; live vitest, jest and node runs need dependencies and Node available, and pytest must be importable. A second helper, quality.py, produces a deterministic snapshot of test-quality signals from a diff for use in review.

## When your agent uses it

> Drive the red-green-refactor loop for any non-trivial code change. Auto-detect the project's test runner (pytest / vitest / jest / node --test), invoke it via the `tdd.py` helper, and act on the normalized exit code. Use when you write a test, TDD this feature, let me test-drive a behaviour, are about to implement [feature], want to run my tests, ask is my coverage complete, or ask are tests green. Do not use for one-off exploratory scripts, throwaway spikes, or pure-documentation edits that touch no executable code.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs Python scripts](https://github.com/ramboz/jig/tree/HEAD/hosts/claude/skills/tdd-loop)
- [No network calls found in its scripts](https://github.com/ramboz/jig/tree/HEAD/hosts/claude/skills/tdd-loop)
- [License: MIT](https://github.com/ramboz/jig/tree/HEAD/hosts/claude/skills/tdd-loop)

## Features

- **Red-green-refactor workflow:** Guides the agent through writing a failing test, minimal implementation and safe refactoring one criterion at a time.
- **Automatic runner detection:** Identifies pytest, vitest, jest or node --test from project files and applies a fixed priority.
- **Normalized exit codes:** Maps every run to green, red or could-not-run so the agent can branch reliably.
- **Focused test runs:** Runs a whole suite, a single test file or one named test through the same helper.
- **Custom test command support:** Lets projects on other stacks define their own test command under the same exit contract.
- **Protection of existing tests:** Tells the agent to treat a pre-existing failing test as a signal to investigate, not to weaken it.
- **Test quality snapshot:** Includes a companion script that reports test-quality ratios from a diff for review.

## Good for

- Test-drive a new function before implementing it
- Run the project's tests and report whether they are green
- Check whether a change broke an existing test
- Run only the tests in one file while iterating
- Set up a custom test command for a Gradle or Go project

## Install

### Claude Code

This skill ships in the `jig` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ramboz/jig
/plugin install jig@jig
```

Or copy only this skill to `~/.claude/skills/tdd-loop`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ramboz/jig.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/tdd-loop &&
cp -R "$tmp/hosts/claude/skills/tdd-loop" ~/.claude/skills/tdd-loop &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/tdd-loop` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/tdd-loop` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ramboz/jig.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/tdd-loop &&
cp -R "$tmp/hosts/claude/skills/tdd-loop" ~/.agents/skills/tdd-loop &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/tdd-loop` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/tdd-loop` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ramboz/jig.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/tdd-loop &&
cp -R "$tmp/hosts/claude/skills/tdd-loop" ~/.cursor/skills/tdd-loop &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/tdd-loop` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ramboz/jig.git --path hosts/claude/skills/tdd-loop
```

Or copy the folder to `~/.gemini/skills/tdd-loop` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/tdd-loop`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ramboz/jig.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/tdd-loop &&
cp -R "$tmp/hosts/claude/skills/tdd-loop" ~/.copilot/skills/tdd-loop &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/tdd-loop` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ramboz/jig.git
```

Then copy `jig/hosts/claude/skills/tdd-loop` into your agent's skills folder as `tdd-loop`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need to run?

Python 3 for the helper script, and the project's test runner installed. Live vitest and jest runs need node_modules, live node --test runs need Node on PATH, and pytest must be importable.

### Which test frameworks are detected automatically?

pytest, vitest, jest and Node's built-in node --test. Other stacks such as Gradle, Maven, Go, Rust and .NET connect through a .jig/test-command file instead.

### What do the exit codes mean?

0 means all tests passed, 1 means at least one test ran and failed, and 2 means the tests could not be run, for example because no runner was detected or a binary was missing.

### Can TDD loop run only one test?

Yes. The run subcommand accepts a test path or a single test selector, with the selector format depending on the runner.

### How do I install TDD loop in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/tdd-loop to use it in all your projects, or to .claude/skills/tdd-loop in one project. Or install the jig plugin, which includes it: /plugin marketplace add ramboz/jig, then /plugin install jig@jig.

### Does TDD loop run scripts?

Yes. It runs Python scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use TDD loop?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to TDD loop?

The closest alternatives to TDD loop are TDD, TDD, Mt build, Django TDD and Develop.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [TDD](https://ai-powered.com/skills/tdd): TDD is an open-source agent skill for developer tools.
- [TDD](https://ai-powered.com/skills/tdd-michael-denyer): TDD is an open-source agent skill for developer tools.
- [Mt build](https://ai-powered.com/skills/mt-build): Mt build is an open-source agent skill for developer tools.
- [Django TDD](https://ai-powered.com/skills/django-tdd): Django TDD is an open-source agent skill for developer tools.
- [Develop](https://ai-powered.com/skills/develop): Develop is an open-source agent skill for developer tools.
- [Test](https://ai-powered.com/skills/test): Test is an open-source agent skill for developer tools.
- [Prd v07 implementation loop](https://ai-powered.com/skills/prd-v07-implementation-loop): Prd v07 implementation loop is an open-source agent skill for developer tools.
- [Testing strategy](https://ai-powered.com/skills/testing-strategy): Testing strategy is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/tdd-loop
