tdd

Guides test-driven development using the red-green-refactor loop with vertical slices.

1|Updated May 4, 2026
One-click install
npx skills add https://github.com/wesbragagt/nixos-config --skill tdd-wesbragagt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/wesbragagt/nixos-config/tree/main/home/skills/tdd
Command: npx skills add https://github.com/wesbragagt/nixos-config --skill tdd-wesbragagt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after code, or writing all tests before implementation, produces brittle tests coupled to implementation details that break during refactors and fail to verify real behavior. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Enforces one test at a time with minimal implementation, using tracer bullets to prove the path end-to-end before iterating. - Behavior-Focused Testing: Guides writing integration-style tests through public interfaces that survive internal refactors, with clear examples of good and bad tests. - Design Guidance: Includes references on deep modules, interface design for testability, mocking at system boundaries, and post-cycle refactoring candidates. - Use Case: When building a new checkout feature, use this Skill to plan which behaviors to test, write one failing test, implement minimal code to pass, and repeat until the feature is complete. ## Quick Start Ask the AI to build a feature using test-driven development with the red-green-refactor loop, one behavior at a time.

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 red-green-refactor?

Write one failing test for a single behavior (red), write the minimal code to make it pass (green), then refactor while tests stay green. Repeat this cycle per behavior rather than writing all tests upfront.

What is the difference between good and bad tests in TDD?

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

When should I use mocks in unit tests?

Mock only at system boundaries such as external APIs, time, randomness, and sometimes databases or file systems. Never mock your own classes or internal collaborators, and prefer dependency injection to make boundaries mockable.

Why should I avoid writing all tests before implementation?

Writing all tests first (horizontal slicing) produces tests of imagined behavior coupled to data shapes and signatures. Vertical slices with one test then one implementation let each test respond to what you learned from the previous cycle.

When is it safe to refactor during TDD?

Refactor only after all tests pass, never while red. Look for duplication, long methods, shallow modules, feature envy, and primitive obsession, running tests after each refactor step.