Skip to content
Back to skills

Add Tdd

ASecurity

RED-GREEN-REFACTOR execution discipline for AI agents. Use when implementing any feature or bugfix that has (or should have) tests — forces a failing test confirmed for the right reason before any production code. Loaded by add-build.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 29, 2026
developmentgotesting

Security analysis

A100/100

Scanned September 29, 2026

npx -y skills add brabos-ai/code-addiction --skill add--tdd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Tdd?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Add  Tdd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/brabos-ai-add-tdd/badge)](https://www.skillsdirectory.com/skills/brabos-ai-add-tdd)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: add--tdd
description: RED-GREEN-REFACTOR execution discipline for AI agents. Use when implementing any feature or bugfix that has (or should have) tests — forces a failing test confirmed for the right reason before any production code. Loaded by add-build.
---

# TDD — RED-GREEN-REFACTOR Discipline

> **LANG:** Respond in user's native language. Tech terms in English.

## Iron Law

**NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.**

If you wrote implementation before its test: delete it, start over from RED. "Keep it as reference" is testing-after — delete means delete.

## The Cycle (one feature at a time)

### RED — write ONE failing test
1. Write a test describing the expected behavior (from the acceptance criterion / contract).
2. Run the test. It **MUST fail**.
3. Confirm it fails for the **RIGHT reason**: missing implementation, wrong return value, unmet condition — **NOT** a syntax error, import error, or typo.
4. If it passes: the feature already exists or the test is wrong. Investigate before continuing.

### GREEN — minimal code to pass
1. Write the **smallest** code that makes the test pass. No cleverness, no optimization, no extra features.
2. Run the test. It **MUST pass**.
3. Run the existing suite. No regressions. **CI-tier is CI's job** — re-run only the file(s) the
   current task's `Verify:` line names, never the whole CI-tier suite inside this cycle. Local-tier
   still runs in full, as above. Inert wherever no `Verify:` line exists.

### REFACTOR — only while GREEN
1. Improve names, remove duplication, extract helpers.
2. Tests stay green. **Never refactor while RED** — get to GREEN first.
3. Do **not** add behavior during refactor.

Then loop to RED for the next behavior. One test ↔ one implementation step. Do **not** write all tests first then all implementation (horizontal slicing produces tests for imagined, not actual, behavior).

## Anti-Rationalization

| Rationalization | Reality |
|-----------------|---------|
| "I'll add the test right after" | You won't, and the code will shape the test. Test first, always. |
| "I need to see the design first" | The test IS the design. Let it drive the interface. |
| "Already wrote it, deleting is wasteful" | Sunk cost. Delete it. Start from RED. |
| "The test passes immediately, good" | It proves nothing — it never failed. Fix the test or pick new behavior. |
| "Syntax error counts as RED" | No. It must fail because the behavior is missing. |
| "I'll batch these trivial features" | Trivial enough to batch = trivial enough to skip TDD; use a plain task. |

## When NOT to use

- Throwaway spikes / exploratory prototypes you will delete.
- Pure config or doc changes with no behavior.
- Generated code with no logic.

## Bug-fix mode

When a bug is reported: do not start by fixing it. First write a test that **reproduces** it (RED), then fix to GREEN.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.