tdd

Guides test-driven development using red-green-refactor cycles with integration-style tests.

Updated Jun 2, 2026
One-click install
npx skills add https://github.com/lfuuu/claude-rules --skill tdd-lfuuu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/lfuuu/claude-rules/tree/main/global-skills/tdd
Command: npx skills add https://github.com/lfuuu/claude-rules --skill tdd-lfuuu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing tests after implementation often produces brittle tests coupled to internal details that break during refactoring. This Skill enforces a disciplined test-first workflow where tests verify observable behavior through public interfaces, so they survive internal code changes. ## Core Features & Use Cases - Red-Green-Refactor Loop: Enforces vertical slicing with one failing test followed by minimal implementation, avoiding the anti-pattern of writing all tests before all code. - Behavior-Focused Testing: Provides criteria and examples distinguishing good integration-style tests from implementation-coupled tests that mock internal dependencies. - Design Guidance: Includes references on deep modules, interface design for testability, mocking boundaries, and refactoring candidates. - Use Case: When adding a checkout feature to an application, use this Skill to plan the public interface, write one failing test for the first behavior, implement minimal code to pass it, and repeat incrementally before refactoring. ## Quick Start Use the tdd skill to implement the new feature with a test-first red-green-refactor workflow.

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 with red-green-refactor?

Write one failing test for a single behavior (red), implement the minimal code to make it pass (green), then refactor while keeping tests green. Repeat this cycle per behavior instead of writing all tests upfront.

What is the difference between good and bad unit tests?

Good tests verify observable behavior through public APIs and survive internal refactoring. Bad tests mock internal dependencies, test private methods, or check call counts, causing failures when implementation changes but behavior does not.

When should I use mocks in testing?

Mock only at system boundaries such as external APIs, payment gateways, time, and randomness. Never mock your own classes or internal dependencies, and prefer dependency injection plus SDK-style interfaces to make boundary mocking straightforward.

Why do my tests break every time I refactor code?

Tests break during refactoring when they are coupled to implementation details like private methods, internal structure, or mock call verification. Rewrite them to assert behavior through public interfaces so they only fail when actual behavior changes.

Should I write all tests before writing any implementation code?

No, writing all tests first is the horizontal slicing anti-pattern that produces tests for imagined behavior. Use vertical slicing instead: alternate one test with one implementation so each test reflects what you learned from the previous cycle.