tdd

Implements features test-first using red-green-refactor cycles with behavior-focused tests.

Updated Sep 17, 2026
One-click install
npx skills add https://github.com/hkw2028/toy-project --skill tdd-hkw2028
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/hkw2028/toy-project/tree/main/.agents/skills/tdd
Command: npx skills add https://github.com/hkw2028/toy-project --skill tdd-hkw2028

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after code often produces tests coupled to implementation details that break during refactoring. This Skill enforces a disciplined test-driven development loop so each behavior is verified through a failing test before any implementation exists. ## Core Features & Use Cases - Red-Green-Refactor Discipline: Enforces writing one failing test first, then only the minimal code to pass it, then refactoring while keeping tests green. - Seam Selection Guidance: Helps choose stable public boundaries for tests, avoiding mocks of internal collaborators and implementation-coupled assertions. - Anti-Pattern Detection: Flags tautological tests, horizontal slicing, and tests that verify private methods instead of observable behavior. - Use Case: When adding a new pricing rule to a checkout module, write one failing test against the public API stating the expected behavior, implement the minimal code to pass it, then refactor safely with the test suite green. ## Quick Start Use the tdd skill to implement this feature test-first, one red-green slice 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 on a new feature?

Write one failing test that states the expected behavior through a public interface, then implement only the minimal code to make it pass. After the test is green, refactor while keeping all tests passing, then choose the next single test.

What is red-green-refactor in TDD?

Red-green-refactor is the TDD cycle: write a failing test (red), write just enough code to pass it (green), then improve the code structure while keeping tests passing (refactor). Each cycle covers one behavior slice at a time.

When should I mock dependencies in unit tests?

Mock only at system boundaries such as external APIs, time, and randomness. Prefer a real test database over a mocked one, and avoid mocking internal collaborators since that couples tests to implementation details.

Why do my tests break every time I refactor code?

Tests break during refactoring when they are coupled to implementation, such as testing private methods or mocking internal collaborators. Test behavior through public interfaces and stable seams so internal changes do not affect the suite.

What are common TDD anti-patterns to avoid?

Three common anti-patterns are implementation-coupled tests that break on refactoring, tautological tests that derive expectations from the same logic being tested, and horizontal slicing where many tests are written before any implementation exists.