tdd

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

Updated Jan 19, 2023
One-click install
npx skills add https://github.com/inkfin/dotfiles --skill tdd-inkfin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/inkfin/dotfiles/tree/main/dot_agents/skills/exact_tdd
Command: npx skills add https://github.com/inkfin/dotfiles --skill tdd-inkfin

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 interface boundaries, confirmed with the user before any test is written. - Anti-Pattern Detection: Identifies implementation-coupled, tautological, and horizontally sliced tests, with reference guides on good test design and mocking at system boundaries. - Use Case: When adding a checkout feature, confirm the public seams first, then write one failing test like "user can checkout with valid cart", implement just enough code to pass, and repeat for the next slice. ## Quick Start Ask the assistant to build the next feature using test-driven development, starting by agreeing on the seams to test and writing the first failing 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 public seams to test, then write one failing test that describes observable behavior through the public interface. Implement only enough code to make it pass, then repeat with the next vertical slice.

What is a seam in test-driven development?

A seam is the public boundary where you observe behavior without reaching inside the code. Tests live at seams, never against internals, so they survive refactors that change implementation but not behavior.

When should I use mocks in unit tests?

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

Why do my tests break every time I refactor code?

Tests break during 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 behavior through public interfaces instead.

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 like a known literal or worked example.