tdd

Guides test-driven development using the red-green-refactor loop with behavior-focused integration tests.

Updated May 22, 2026
One-click install
npx skills add https://github.com/viniciuscs84/sdd-toolkit --skill tdd-viniciuscs84
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/viniciuscs84/sdd-toolkit/tree/main/skills/tdd
Command: npx skills add https://github.com/viniciuscs84/sdd-toolkit --skill tdd-viniciuscs84

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after code, or writing all tests before implementation, produces brittle tests coupled to internal structure that break on every refactor. This Skill enforces a disciplined test-driven development workflow where tests verify observable behavior through public interfaces, so they survive refactors and act as living specifications. ## Core Features & Use Cases - Red-Green-Refactor Loop: Implements vertical slicing with tracer bullets—one failing test, minimal code to pass, then repeat—instead of horizontal batch testing. - Behavior-Focused Test Design: Provides guidelines and examples for writing integration-style tests through public APIs, with clear rules on when to mock (system boundaries only) and how to design testable interfaces. - Refactoring Guidance: Includes checklists for post-cycle refactoring such as extracting duplication, deepening modules, and applying SOLID principles. - Use Case: When building a new checkout feature, use this Skill to plan which behaviors to test, write one failing test at a time, implement minimal code per cycle, and refactor safely once all tests pass. ## Quick Start Use the tdd skill to build the new shopping cart feature test-first, 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 per behavior rather than writing all tests upfront, so each test responds to what you learned from the previous cycle.

What is the difference between good and bad unit tests?

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, so they break whenever implementation changes even though behavior stays the same.

When should I use mocks in testing?

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; instead use dependency injection and SDK-style interfaces to make boundaries easy to stub.

Why do my tests break every time I refactor code?

Tests break on refactor when they are coupled to implementation details like private methods, internal mocks, or direct database verification. Rewrite them to assert behavior through the public interface, such as verifying a created user is retrievable via getUser rather than querying the database.

Should I write all tests before writing any implementation code?

No. Writing all tests first is horizontal slicing and produces tests of imagined behavior tied to data shapes. Use vertical slices instead: alternate one test with one implementation so each test reflects real, just-written behavior.