tdd

Guides test-driven development using the red-green-refactor loop with vertical slices.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/yamcodes/the-hat --skill tdd-yamcodes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/yamcodes/the-hat/tree/main/skills/tdd
Command: npx skills add https://github.com/yamcodes/the-hat --skill tdd-yamcodes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle tests coupled to internal structure that break during refactors, while writing all tests upfront leads to testing imagined behavior instead of real behavior. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Enforces one test at a time with minimal implementation, using tracer bullets to prove the path end-to-end before iterating. - Behavior-Focused Testing: Promotes integration-style tests through public interfaces that survive internal refactors, with guidance on when to mock (system boundaries only). - Design Guidance: Includes references on deep modules, interface design for testability, and post-cycle refactor candidates. - Use Case: When building a new checkout feature, use this Skill to write one failing test for a single behavior, implement minimal code to pass, then repeat incrementally until the feature is complete. ## Quick Start Ask the AI to build the next feature using test-driven development with the red-green-refactor loop, one behavior at a time.

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 cycle per behavior rather than writing all tests upfront.

Should I write all tests before implementation in TDD?▼

No. Writing all tests first is horizontal slicing and produces tests of imagined behavior. Use vertical slices: one test, one implementation, repeat, so each test responds to what you learned from the previous cycle.

When should I use mocks in unit tests?▼

Mock only at system boundaries such as external APIs, time, randomness, and sometimes databases or file systems. Never mock your own classes or internal collaborators, since that couples tests to implementation details.

Why do my tests break when I refactor code?▼

Tests break during refactoring when they verify implementation details like private methods, mock call counts, or internal structure instead of observable behavior. Write integration-style tests through public interfaces so they survive internal changes.

What makes a good test versus a bad test?▼

Good tests describe what the system does through public APIs and survive refactors. Bad tests mock internal collaborators, assert on call order, bypass interfaces to check databases directly, or fail when behavior has not changed.