# Developing Features with TDD — Strict Red/Green/Refactor

> Build features test-first in nine strict phases: design, failing test, minimum code, refactor, validate, slice by slice.

Developing Features with TDD — Strict Red/Green/Refactor is a free AI agent skill on Agensi by Cristhian Zanforlin Lousa, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Cristhian Zanforlin Lousa](https://www.agensi.io/creators/cristhian-zanforlin-lousa)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Uses: 3
- Version: 1.2
- Last updated: 2026-11-25
- Security: scan passed (2026-11-25); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/developing-features-with-tdd-strict-red-green-refactor
- Tags: testing, code-review, tdd, test-driven-development, coding, red-green-refactor, workflow

## About this skill

**Developing Features with TDD** builds a feature with strict test-driven development. Its core rule is to never write production code for a new behavior before a failing test proves that behavior is missing.

**Problems it solves**
- Tests written after the code that only confirm what the code already does.
- Tests that pass before the feature exists.
- Green tests on top of tangled architecture.
- No tests for abuse cases.
- LLM features shipped with no timeout, fallback or kill switch.

**The cycle (strict order)**
1. **UNDERSTAND.** Each acceptance criterion becomes Given/When/Then/So-That, with a threat model.
2. **DESIGN.** Slices, file structure, injected dependencies, threats that will become tests, and a "durability anchor" saying where each decision is recorded.
3. **RED.** A failing test for the next slice.
4. **VERIFY RED.** It must fail, and for the right reason.
5. **GREEN.** The minimum code to pass.
6. **VERIFY GREEN.**
7. **REFACTOR.** Clean up while tests stay green.
8. **VALIDATE.** Full suite, at least 75% branch coverage, linters, and complexity of 10 or less.
9. **REPEAT** for the next slice.

Slices go in a set order: happy path, edge cases, errors, adversarial cases, integration seams, then AI-runtime failure modes when the feature calls an LLM.

**References**
- `cycle.md`: each phase in detail, with adversarial slice examples.
- `test-quality.md`: `should_X_when_Y` naming, Arrange–Act–Assert, what not to test, anti-patterns such as mockery, liar and snowball tests.
- `ai-runtime.md`: the runtime profile an LLM feature needs (timeout, circuit breaker, fallback, cost ceiling, kill switch, SLO) and the failure-mode tests it requires.
- `checklist.md`: the end-of-feature gate, per-slice commit format and PR template.

It applies every rule of `developing-features` unchanged (security, SOLID, file limits, observability, data layer). TDD changes how you get there, not the quality bar.

**The spec is the boundary.** RED encodes only the requested behavior. GREEN is the minimum code to pass. REFACTOR touches only code the feature added or had to change. Existing tests are never edited to get green, a scope audit runs before VALIDATE ends, and ideas go to "Out of Scope (Follow-Ups)".

**When it triggers.** "TDD this", "tests first", "red green refactor", or features that must be verifiable from the spec.

Free and MIT-licensed. Part of the claude-skills-czl collection.

**Source on GitHub:** [this skill](https://github.com/Cristhianzl/claude-skills-czl/tree/main/configs/agnostic/skills/developing-features-tdd) · [full repository](https://github.com/Cristhianzl/claude-skills-czl)

## Requires

- Git

## Known limitations

SOLID, file-structure and observability details live in the developing-features skill, so install both. Needs a working test runner with branch coverage. The coverage threshold (75%, target 80%) and complexity limits are defaults you can override in learnings/.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Developing Features with TDD — Strict Red/Green/Refactor skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Does it work outside Claude Code?

Yes. Any agent that supports SKILL.md can follow it. It was built and tested mainly on Claude Code.

### Does it run my tests?

Yes. Running tests is central to the cycle. Every slice runs once to confirm the failure (RED) and again to confirm the pass (GREEN), and the full suite runs with coverage at the end. When something hasn't been run, it says so instead of reporting a pass.

### Do I need developing-features too?

It's recommended. This skill applies the `developing-features` rules unchanged and refers to that skill's reference files for details such as file-structure limits and security. The TDD cycle itself works on its own.

### Is it overkill for small changes?

It uses a lighter process for scripts, prototypes and features under about 30 lines. You still get at least one happy-path test and one adversarial test, but the written design step is skipped.

### How do I install it?

Unzip it into `~/.claude/skills/` to use it in every project, or into a project's `.claude/skills/` to use it in that repo only. Keep the folder named `developing-features-tdd/`.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
