About this skill
Red-Green TDD Loop
Ask a coding agent to "add tests" and it often writes the code first, then tests that pass by construction, and when something stays red it skips the test or loosens the assertion. This skill holds the agent to a real test-driven loop: one failing test per behaviour, shown failing for the right reason, the smallest code that turns it green, a refactor with the tests still green, then a commit point. After every step it prints the same seven-line status block, so you can follow the work without reading the diff.
How it works. Type /tdd-red-green-loop with the feature or bug. The agent finds your test runner, runs the suite once to note anything already broken, and shows you a short list of behaviours to build, simplest first. You can reorder or cut it. Then it works through the list cycle by cycle. Before each green it checks its own diff against a "no fake green" list: no skipped, deleted or xfail tests, no weakened assertions, no sleeps, no test-only branches in production code, no mocking the code under test. If the same test stays red three times, it stops and tells you what it thinks the design problem is instead of trying a fourth time. On code with no tests it writes characterization tests first, pinning down today's behaviour before changing anything.
What you get. SKILL.md (the loop, status block, no-fake-green checklist, stop rule and legacy-code steps), references/runners.md (for Vitest, Jest, pytest, Go, Rust and PHPUnit/RSpec: the one-test command, the watch command, how to read a failure, and the most common way that stack lets a test pass for the wrong reason) and templates/cycle-log.md (the status block with field rules).
Pairs with the Risemi skill systematic-debugging-loop: use that one to find the root cause of a bug, this one to build the fix and its regression test.
What to change
- Commits: the skill marks a commit point after each cycle but commits only if you ask it to commit as you go. Tell it once at the start if you want a commit per cycle.
- Stop rule: three red cycles on one test is the default. Change the number in the "Stop rule" section of
SKILL.mdif you want it stricter or looser. - Runners: add your own stack (Elixir, Kotlin, .NET) to
references/runners.mdin the same four-line shape. - Status block: fields are defined in
templates/cycle-log.md; remove lines you do not need, but keepran:andresult:, which are what keep the agent honest.
Checked against
The files follow the Agent Skills SKILL.md format: spec-only frontmatter, name matching the folder, description under 1024 characters, SKILL.md under 8 KB. Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and Antigravity read that format from a skills folder. We checked the files against the spec on 2026-11-07, and checked by script that every file SKILL.md names exists. The runner commands follow each tool's documentation; we have not recorded a test session in each agent. The example output on this page comes from a real run of the skill in Claude Code (Claude Opus) on 2026-11-07 with the request shown under "You say", in a throwaway TypeScript project where Vitest really ran red and then green.
How to install
Copy the files/ folder of the download to .agents/skills/tdd-red-green-loop/ (Codex, Cursor, Copilot, Gemini CLI, Antigravity) and/or .claude/skills/tdd-red-green-loop/ (Claude Code), or download the zip from this page and unpack it there. Start a new agent session and type /tdd-red-green-loop followed by what you want built or fixed.
