tdd

Guides test-driven development using the red-green-refactor loop for features and bug fixes.

2|Updated Jul 24, 2026
One-click install
npx skills add https://github.com/konstantinos-malavazos/claude-code-playbook --skill tdd-konstantinos-malavazos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/konstantinos-malavazos/claude-code-playbook/tree/main/templates/skills/tdd
Command: npx skills add https://github.com/konstantinos-malavazos/claude-code-playbook --skill tdd-konstantinos-malavazos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It enforces a disciplined test-first workflow so new features and bug fixes are backed by failing tests before any implementation code is written, preventing regressions and untested behavior. ## Core Features & Use Cases - Red-Green-Refactor Loop: Write a failing test that expresses the desired behavior, implement the minimum code to pass, then refactor with the test as a safety net. - Bug Reproduction Tests: For bug fixes, first write a test that reproduces the bug on current code, proving understanding and preventing regression. - Testing Rules: Test behavior through public interfaces, keep one behavior per test, and avoid testing frameworks or impossible states. - Use Case: When asked to fix a login bug, write a failing test that reproduces the broken login behavior first, then apply the smallest fix that turns it green. ## Quick Start Use the tdd skill to build this feature test-first with the red-green-refactor loop.

Frequently Asked Questions about tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I practice test-driven development on a new feature?

Follow the red-green-refactor loop: write a failing test expressing the desired behavior, write the minimum code to make it pass, then refactor while keeping the test green. Run the test at each stage to confirm the transitions.

How to write a test for a bug fix before fixing it?

Write a test that reproduces the bug and fails on the current code, proving you understand the defect. Then apply the smallest change that makes the test pass, which also guards against future regression.

Should unit tests target private methods or public interfaces?

Tests should target behavior through public interfaces, not private internals. This keeps tests stable during refactors that preserve behavior, since internal restructuring will not break them.

When should I not use TDD?

Exploratory spikes and throwaway prototypes do not require TDD. Once code is meant to survive beyond experimentation, back it with tests using the standard loop.

Why do my tests break every time I refactor code?

Tests break during refactoring when they assert on private internals instead of observable behavior. Rewrite them to verify outcomes through public interfaces with one clear expectation per test.