tdd

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

1|Updated May 25, 2020
One-click install
npx skills add https://github.com/titaneric/dotfiles --skill tdd-titaneric
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/titaneric/dotfiles/tree/main/dot_agents/skills/tdd
Command: npx skills add https://github.com/titaneric/dotfiles --skill tdd-titaneric

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle, implementation-coupled tests that break on refactors and fail to verify real behavior. This Skill enforces a disciplined red-green TDD loop so every test verifies observable behavior through public interfaces. ## 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 test boundaries (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/bad examples in tests.md and mocking guidance in mocking.md. - Use Case: When adding a checkout feature, ask the assistant to build it test-first; it will confirm the seams, write one failing behavior test, implement the minimal code to pass, and repeat per slice. ## Quick Start Ask the assistant to build the next feature or fix the bug 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?

Start by agreeing on the seams, the public interfaces where tests will live, then write one failing test that describes observable behavior. Implement only enough code to make it pass, then repeat with the next vertical slice instead of writing all tests upfront.

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

Red-green means writing a failing test first, then the minimal code to pass it. This Skill treats refactoring as a separate review-stage activity, not part of the implementation loop, keeping each cycle focused on one behavior.

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, and prefer dependency injection plus SDK-style interfaces to keep mocks simple.

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 behavior through public interfaces so internal restructuring leaves them untouched.

What is a tautological test and why is it bad?

A tautological test computes its 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, worked example, or specification.