tdd

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

1|Updated Jul 23, 2026
One-click install
npx skills add https://github.com/sanjanb/my-agent-harness --skill tdd-sanjanb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/sanjanb/my-agent-harness/tree/main/skills/mp-tdd
Command: npx skills add https://github.com/sanjanb/my-agent-harness --skill tdd-sanjanb

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle, implementation-coupled tests that break during refactors and fail to verify real behavior. This Skill enforces a disciplined test-first workflow so tests act as durable specifications of behavior. ## Core Features & Use Cases - Red-Green Loop Discipline: Enforces writing a failing test before any implementation, one vertical slice at a time, with no speculative features. - Seam-Based Test Placement: Defines tests only at pre-agreed public boundaries, confirmed with the user before any test is written. - Anti-Pattern Detection: Identifies implementation-coupled, tautological, and horizontally sliced tests, with mocking guidelines restricted to system boundaries like external APIs, time, and file systems. - Use Case: When adding a checkout feature, write one failing test through the public interface ("user can checkout with valid cart"), implement the minimal code to pass it, then repeat for the next slice. ## Quick Start Use the tdd skill to build the new payment retry feature test-first, one red-green cycle 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 the red-green-refactor loop?

Write one failing test against a public interface first, then implement only the minimal code needed to make it pass. Repeat one vertical slice at a time, and leave refactoring for a separate review stage rather than mixing it into the loop.

What is a seam in testing and where should tests go?

A seam is the public boundary where you observe behavior without reaching into internals. Tests should live only at pre-agreed seams confirmed with the user before writing, never against private methods or internal structure.

When should I use mocks in unit tests?

Mock only at system boundaries such as external APIs, databases, time, randomness, and file systems. Never mock your own classes or internal collaborators, and prefer dependency injection plus SDK-style interfaces to keep mocks simple.

What makes a test tautological or implementation-coupled?

A tautological test recomputes its expected value the same way the code does, so it passes by construction. An implementation-coupled test mocks internal collaborators or asserts on call counts, breaking whenever you refactor without changing behavior.

Should I write all tests before implementing a feature?

No. Writing all tests upfront is horizontal slicing, which verifies imagined behavior and commits to test structure prematurely. Work in vertical slices instead: one test, one minimal implementation, then repeat.