tdd

Guides test-driven development using the red-green-refactor loop with behavior-focused tests.

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/prabaljainn/my-claude-code-setup --skill tdd-prabaljainn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/prabaljainn/my-claude-code-setup/tree/main/agents/skills/tdd
Command: npx skills add https://github.com/prabaljainn/my-claude-code-setup --skill tdd-prabaljainn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle tests coupled to internal structure that break during refactors and fail to verify real behavior. This Skill enforces a disciplined test-first workflow so tests describe observable behavior through public interfaces and survive code changes. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Drives one test at a time through vertical tracer-bullet slices instead of writing all tests upfront. - Behavior-Focused Testing Guidance: Distinguishes good integration-style tests from implementation-coupled tests, with concrete examples of each. - Design References: Includes guidance on deep modules, interface design for testability, mocking at system boundaries, and post-cycle refactoring candidates. - Use Case: When asked to build a new feature like a checkout flow, the Skill plans which behaviors to test, writes one failing test, implements minimal code to pass, and repeats until the feature is complete. ## Quick Start Ask the assistant to build a feature or fix a bug using test-driven development 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 with red-green-refactor?▼

Write one failing test for a single behavior (red), write the minimal code to make it pass (green), then refactor while tests stay green. Repeat this loop one behavior at a time rather than writing all tests upfront.

What is the difference between good and bad unit tests?▼

Good tests verify observable behavior through public interfaces and survive internal refactors. Bad tests mock internal collaborators, test private methods, or assert on call counts, so they break when implementation changes without any behavior change.

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 collaborators, and prefer dependency injection so boundary dependencies can be passed in and substituted.

Why should I avoid writing all tests before implementation?▼

Writing all tests first is horizontal slicing, which produces tests of imagined behavior coupled to guessed structure. Vertical tracer-bullet slices let each test respond to what the previous cycle revealed about the actual implementation.

How do I design interfaces that are easy to test?▼

Accept dependencies as parameters instead of constructing them internally, return results instead of producing side effects, and keep the surface area small. Fewer methods and simpler parameters mean fewer tests and simpler setup.