tdd

Guides test-driven development using the red-green loop with behavior-focused tests at public seams.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle tests coupled to internal structure that break on every refactor. This Skill enforces a disciplined test-driven development workflow so tests verify 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: Requires agreeing on public interface seams with the user before any test is written, focusing effort on critical paths. - Anti-Pattern Detection: Flags implementation-coupled, tautological, and horizontally-sliced tests with concrete good and bad examples. - Mocking Guidelines: Provides rules for mocking only at system boundaries like external APIs, time, and file systems, with dependency injection patterns. - Use Case: When adding a checkout feature, use this Skill to write a failing integration test like "user can checkout with valid cart", implement the minimal code to pass, and repeat slice by slice. ## Quick Start Ask the assistant to build the next feature or bug fix using test-driven development with the red-green 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 on a new feature?

Write one failing test against a public interface seam, then implement only enough code to make it pass, and repeat one vertical slice at a time. Confirm the seams under test with stakeholders before writing any test.

What is the red-green-refactor loop in TDD?

Red-green means writing a failing test first, then the minimal code to pass it. In this workflow, refactoring is deliberately excluded from the loop and deferred to a separate code review stage.

When should I mock dependencies 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 for mockability.

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 call counts. Tests should verify observable behavior through public interfaces only.

What is a tautological test and why is it bad?

A tautological test recomputes the expected value the same way the implementation does, so it passes by construction and can never catch bugs. Expected values must come from an independent source such as a known literal or worked example.