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.zipInstalls 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.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
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 test | Correct seam |
|---|---|
| Tool function | core/tools.py function directly |
| Route returns right JSON | pytest with Flask test client |
| SSE stream fields | routes/stream.py integration test |
| Provider routing | core/chatbot.py or chatbot_v2.py unit test |
| DB read/write | database/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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| tdd (this skill) | 0 | 3mo | No flags | Intermediate |
| tdd-workflow | 6 | 4mo | Review | Intermediate |
| qlty-check | 5 | 7mo | Review | Beginner |
| superpowers-tdd | 5 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
tdd-workflow
affaan-m
在编写新功能、修复错误或重构代码时使用此技能。强制执行测试驱动开发,包含单元测试、集成测试和端到端测试,覆盖率超过80%。
qlty-check
parcadei
Code quality checks, formatting, and metrics via qlty CLI
superpowers-tdd
anthonylee991
Applies tests-first discipline (red/green/refactor) and adds regression tests for bugs. Use when implementing features, fixing bugs, or refactoring.
solid
ramziddin
Use this skill when writing code, implementing features, refactoring, planning architecture, designing systems, reviewing code, or debugging. This skill transforms junior-level code into senior-engineer quality software through SOLID principles, TDD, clean code practices, and professional software design.
bunit-test-migration
FritzAndFriends
Migrate bUnit test files from deprecated beta API (1.0.0-beta-10) to bUnit 2.x stable API. Use this when working on .razor test files in BlazorWebFormsComponents.Test that contain old patterns like TestComponentBase, Fixture, or SnapshotTest.
code-refactor
luongnv89
Systematic code refactoring based on Martin Fowler's methodology. Use when users ask to refactor code, improve code structure, reduce technical debt, clean up legacy code, eliminate code smells, or improve code maintainability. This skill guides through a phased approach with research, planning, and safe incremental implementation.