tdd

Guides test-driven development using a red-green loop with behavior-focused tests.

3|Updated Oct 28, 2020
One-click install
npx skills add https://github.com/k0d3x8its/dotfiles --skill tdd-k0d3x8its
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/k0d3x8its/dotfiles/tree/main/claude/.claude/skills/tdd
Command: npx skills add https://github.com/k0d3x8its/dotfiles --skill tdd-k0d3x8its

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation often produces brittle tests coupled to internal details that break during refactoring. This Skill enforces a disciplined test-first workflow where each test verifies observable behavior through public interfaces, producing a stable test suite that survives internal changes. ## Core Features & Use Cases - Red-Green Incremental Loop: Write one failing test, then the minimal code to pass it, repeating vertically instead of writing all tests upfront. - Interface Design for Testability: Apply dependency injection, return-value patterns, I/O separation, and seams so code is naturally easy to test. - Mocking and Refactoring Guidelines: Mock only at system boundaries (APIs, time, file system) and follow a smell-to-fix refactoring table after tests pass. - Use Case: When building a new checkout feature, ask the AI to drive development test-first: it will design the public interface, write one failing behavior test, implement the minimal passing code, and iterate until all behaviors are covered. ## Quick Start Use the tdd skill to build the new shopping cart feature test-first with a 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 with a red-green loop?▼

Write one failing test for a single behavior (red), then write the minimal code to make it pass (green), and repeat for each remaining behavior. Avoid writing all tests upfront, since vertical one-test-at-a-time cycles keep tests responsive to real behavior.

What makes a good test versus a bad test in TDD?▼

Good tests verify observable behavior through public interfaces and survive internal refactors. Bad tests mock internal collaborators, assert on call counts, or test private methods, so they break whenever implementation changes without behavior changing.

When should I mock dependencies in unit tests?▼

Mock only at system boundaries such as external APIs, time, randomness, and the file system. Never mock your own modules or internal collaborators; prefer a real in-memory database like SQLite over mocking the database layer.

Does this TDD approach work with languages other than Python?▼

Yes, the patterns apply universally even though examples use Python and pytest. The same red-green loop, interface design, and mocking rules adapt to Go's testing package, Node's vitest, or any test runner.

Why do my tests break every time I refactor code?▼

Tests break during refactoring when they are coupled to implementation details like private methods, call order, or internal state. Rewrite them to assert behavior through the public interface so they only fail when actual behavior changes.

When is it safe to refactor during TDD?▼

Refactor only after all tests pass, never while a test is red. Run tests after each individual refactor step, address smells like duplication, long functions, and shallow modules, and keep the public API surface unchanged.