Skip to content

Structured guide that teaches the RED-GREEN-REFACTOR cycle with rules and anti-patterns for each phase.

CCM score
50 of 100
skills.sh installs
290
GitHub stars
34.3K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the RED, GREEN, and REFACTOR phases, plus the three laws of TDD and the AAA test structure
  • Includes phase-specific rules, a test prioritization order from happy path through performance, and a table of common anti-patterns
  • Guides when TDD pays off most, marking new features, bug fixes, and complex logic as high value and UI layout as low
  • Designed for developers and AI agent workflows that need a disciplined test-first sequence

Install

$ npx -y skills add davila7/claude-code-templates --skill tdd-workflow -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

TDD Workflow

Write tests first, code second.


1. The TDD Cycle

πŸ”΄ RED β†’ Write failing test
    ↓
🟒 GREEN β†’ Write minimal code to pass
    ↓
πŸ”΅ REFACTOR β†’ Improve code quality
    ↓
   Repeat...

2. The Three Laws of TDD

  1. Write production code only to make a failing test pass
  2. Write only enough test to demonstrate failure
  3. Write only enough code to make the test pass

3. RED Phase Principles

What to Write

FocusExample
Behavior"should add two numbers"
Edge cases"should handle empty input"
Error states"should throw for invalid data"

RED Phase Rules

  • Test must fail first
  • Test name describes expected behavior
  • One assertion per test (ideally)

4. GREEN Phase Principles

Minimum Code

PrincipleMeaning
YAGNIYou Aren't Gonna Need It
Simplest thingWrite the minimum to pass
No optimizationJust make it work

GREEN Phase Rules

  • Don't write unneeded code
  • Don't optimize yet
  • Pass the test, nothing more

5. REFACTOR Phase Principles

What to Improve

Details

Repository
github.com/davila7/claude-code-templates
Categories
Testing & QA, Agent Workflow & Planning
First seen
Jun 3, 2026

Questions

What is the tdd-workflow skill for?

The tdd-workflow skill sets out Test-Driven Development principles for an agent, following the RED-GREEN-REFACTOR cycle: write a failing test, write minimal code to pass it, then improve the code while keeping tests green. It also covers the AAA test pattern and when TDD suits new features, bug fixes and complex logic. It is listed under the Testing & QA category on Claude Marketplaces, alongside tdd, test-driven-development and webapp-testing.

How do I install the tdd-workflow skill?

Run npx -y skills add davila7/claude-code-templates --skill tdd-workflow -y in your project to install it. Once installed, the tdd-workflow skill lets the agent guide you through writing tests before code, with allowed tools for reading, writing, editing, searching and running shell commands.

Which tools does the tdd-workflow skill use?

The tdd-workflow skill is allowed to use Read, Write, Edit, Glob, Grep and Bash. It needs no separate accounts or API keys, so it works inside any project where the agent can read and change files and run tests.

When should I use the tdd-workflow skill instead of skipping tests?

Use the tdd-workflow skill for new features, bug fixes and complex logic, where its RED phase guidance has the most value. For exploratory spikes or UI layout work, the skill itself suggests lower TDD value, so a spike first and then test-first work is the approach it recommends.

More from davila7/claude-code-templates

All 398

Similar to Tdd Workflow

More Testing & QA