tdd

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

1|Updated Mar 2, 2025
One-click install
npx skills add https://github.com/marjorg/setup --skill tdd-marjorg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/marjorg/setup/tree/main/home/.agents/skills/archive/0-matt/tdd
Command: npx skills add https://github.com/marjorg/setup --skill tdd-marjorg

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 Rules: Enforces writing a failing test before any implementation, one vertical slice at a time, with no speculative features. - Seam Identification: Defines tests only at pre-agreed public interface boundaries, confirmed with the user before any test is written. - Anti-Pattern Detection: Flags implementation-coupled, tautological, and horizontally-sliced tests with concrete good/bad examples. - Mocking Guidelines: Restricts mocks to system boundaries like external APIs, time, and file systems, with dependency injection patterns. - Use Case: When building a checkout feature, use this Skill to write a failing integration test through the public API first, then implement just enough code to pass it, repeating per slice. ## Quick Start Use the tdd skill to build the new checkout 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?

Start by agreeing on the seams, the public interfaces where tests will live, then write one failing test, implement just enough code to pass it, and repeat. Each cycle is one vertical slice responding to what the previous cycle taught you.

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

Red-green-refactor means writing a failing test first (red), then writing only enough code to make it pass (green). Refactoring is not part of this loop; it belongs to a separate code review stage after the implementation cycle.

When should I mock dependencies in unit tests?

Mock only at system boundaries such as external APIs, databases, time, randomness, and the file system. Never mock your own classes or internal collaborators, and use dependency injection to make boundary dependencies easy to substitute.

Why do my tests break every time I refactor code?

Tests break during refactors when they are coupled to implementation details, such as mocking internal collaborators, testing private methods, or asserting on call counts. Tests should verify behavior through public interfaces so internal changes leave them untouched.

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 a bug. Expected values must come from an independent source such as a known literal, a worked example, or the specification.