tdd

Guides test-driven development using the red-green loop with seam-based test design.

Updated May 28, 2026
One-click install
npx skills add https://github.com/changfengpro/agent-skills --skill tdd-changfengpro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/changfengpro/agent-skills/tree/main/skills/tdd
Command: npx skills add https://github.com/changfengpro/agent-skills --skill tdd-changfengpro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle, implementation-coupled tests that break on every refactor. This Skill enforces a disciplined test-first workflow so tests verify real behavior through public interfaces and survive code changes. ## Core Features & Use Cases - Red-Green Loop Rules: Enforces writing a failing test first, then only enough code to pass it, one vertical slice at a time. - Seam Identification: Helps you agree on public interface boundaries before writing any test, focusing effort on critical paths. - Anti-Pattern Detection: Flags implementation-coupled, tautological, and horizontally-sliced tests with concrete good/bad examples. - Mocking Guidance: Explains when to mock (system boundaries only) and how to design mockable interfaces via dependency injection. - Use Case: When adding a checkout feature, use this Skill to write a failing integration test like "user can checkout with valid cart" first, then implement just enough code to make it pass. ## Quick Start Use the tdd skill to build the new payment feature test-first, starting by agreeing on the seams we should test.

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?

Test-driven development follows the red-green loop: write one failing test against a public interface, then write only enough code to make it pass. Work in vertical slices of one test and one implementation per cycle rather than writing all tests upfront.

When should I mock dependencies in unit tests?

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

What is a seam in software testing?

A seam is the public boundary where you observe behavior without reaching inside the code. Tests should live only at pre-agreed seams confirmed with the team, which focuses testing effort on critical paths and complex logic.

Why do my tests break every time I refactor code?

Tests break on refactoring when they are coupled to implementation details, such as mocking internal collaborators, testing private methods, or asserting on call counts. Rewrite them to verify observable behavior through public interfaces instead.

What makes a test tautological and how do I avoid it?

A tautological test recomputes its expected value the same way the implementation does, so it passes by construction and can never catch bugs. Avoid this by deriving expected values from independent sources like known literals, worked examples, or the specification.