Guides developers through a strict test-first implementation cycle for reliable, behavior-driven code.

Install

mkdir -p .claude/skills/tdd-skastvnt && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14304" && unzip -o skill.zip -d .claude/skills/tdd-skastvnt && rm skill.zip

Installs to .claude/skills/tdd-skastvnt

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Test-driven development with red-green-refactor loop. Use when building a new feature or fixing a bug with TDD, or when asked for test-first development.
153 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Plan which behaviors to test before writing code
  • Identify the correct test seam (unit, integration, SSE endpoint)
  • Design public interfaces first for test-driven development
  • Write one test for one behavior (RED phase)
  • Write minimal code to pass the current test (GREEN phase)
  • Refactor code only after all tests pass

How it works

The skill implements a red-green-refactor loop, starting with planning behaviors to test, writing a failing test, then writing minimal code to pass it, and finally refactoring. This process focuses on testing public interfaces.

Inputs & outputs

You give it
A new feature or bug to implement
You get back
Tested and refactored code with verified behavior

When to use tdd

  • Build new features with TDD
  • Refactor legacy modules safely
  • Implement bug fixes via test-first

About this skill

TDD — Test-Driven Development

Vertical slices via tracer bullets. One test → one implementation → repeat.

Philosophy

Tests verify behavior through public interfaces, not implementation details.

  • Good: exercises a real code path through a public API — "user can send message, gets SSE stream back"
  • Bad: mocks internal collaborators, tests private methods, checks DB state directly

If renaming an internal function breaks your test, the test was testing implementation, not behavior.

Anti-pattern: Horizontal Slices

Do NOT write all tests first, then all code.

WRONG:  RED: test1, test2, test3, test4  →  GREEN: impl1, impl2, impl3, impl4

RIGHT:  RED→GREEN: test1→impl1
        RED→GREEN: test2→impl2
        RED→GREEN: test3→impl3

Workflow

1. Plan — before any code

  • Confirm which behaviors to test (prioritise critical paths)
  • Identify the correct test seam (unit vs integration vs SSE endpoint)
  • Design public interface first — what will callers see?
  • List behaviors to test (not implementation steps)
  • Get user approval

For chatbot tasks — seam selection guide:

What to testCorrect seam
Tool functioncore/tools.py function directly
Route returns right JSONpytest with Flask test client
SSE stream fieldsroutes/stream.py integration test
Provider routingcore/chatbot.py or chatbot_v2.py unit test
DB read/writedatabase/repositories/ with test DB

Run existing tests first: cd services/chatbot && pytest tests/ -v

2. Tracer Bullet

Write ONE test confirming ONE behavior:

RED:   Write test for first behavior → fails
GREEN: Write minimal code to pass → passes

3. Incremental Loop

For each remaining behavior:

RED:   Write next test → fails
GREEN: Minimal code to pass → passes

Rules:

  • One test at a time
  • Only enough code to pass current test
  • Don't anticipate future tests
  • Tests must be runnable: pytest tests/<file> -v

4. Refactor

Only after ALL tests pass:

  • Extract duplication
  • Simplify over-engineered paths
  • Run tests after each refactor step

Never refactor while RED.

Checklist per cycle

[ ] Test describes behavior, not implementation
[ ] Test uses public interface only
[ ] Test would survive internal refactor
[ ] Code is minimal for this test
[ ] No speculative features added
[ ] Tests pass: pytest tests/ -v

When not to use it

  • When writing all tests first before any code
  • When refactoring while tests are failing

Limitations

  • Do NOT write all tests first, then all code
  • Never refactor while RED

How it compares

This skill enforces a strict red-green-refactor cycle and emphasizes testing public behavior over internal implementation details, which is a more disciplined approach to development than writing code first and then adding tests.

Compared to similar skills

tdd side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
tdd (this skill)03moNo flagsIntermediate
tdd-workflow64moReviewIntermediate
qlty-check57moReviewBeginner
superpowers-tdd56moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry