tdd

Apply red-green-refactor cycles to verify behavior through public interfaces.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/drshailesh88/build_playbook --skill tdd-drshailesh88
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/drshailesh88/build_playbook/tree/main/vendor/mattpocock-skills/tdd
Command: npx skills add https://github.com/drshailesh88/build_playbook --skill tdd-drshailesh88

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

TDD helps you build reliable software by forcing you to define expected behavior with tests before writing most implementation, reducing fragile changes and behavior regressions.

Core Features & Use Cases

  • Behavior-focused integration tests: Create tests that verify outcomes through public interfaces rather than internal implementation details.
  • Red-green-refactor workflow: Use a tight loop where you write a failing test, make the smallest change to pass, and then refactor safely.
  • Vertical slicing with tracer bullets: Prefer one test at a time tied to the next minimal implementation step to avoid “horizontal slicing” that leads to weak tests.
  • Mocking guidance at boundaries: Mock only system boundaries (external APIs, databases, time/randomness, filesystem) to keep tests meaningful.

Quick Start

Ask the AI to help you implement a feature using a red-green-refactor TDD loop by writing one integration-style test for the first required behavior, then producing the minimal code to make that test pass before moving to the next behavior.

Frequently Asked Questions about tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is test-driven development and how does the red-green-refactor loop work?

Test-driven development verifies software behavior through public interfaces by writing a failing test, making the smallest code change to pass it, then refactoring safely. This red-green-refactor loop reduces fragile changes and regressions.

How do I write integration tests that verify behavior through public interfaces?

Write integration tests that verify outcomes through public interfaces rather than internal implementation details. This behavior-focused approach keeps tests meaningful and resilient during refactoring without breaking the test suite.

What is vertical slicing in test-driven development and why avoid horizontal slicing?

Vertical slicing ties one test at a time to the next minimal implementation step, creating clear tracer bullets. It avoids horizontal slicing, which groups tests by layer and leads to weak tests that fail to verify end-to-end behavior.

When should I mock boundaries during integration testing?

Mock only system boundaries such as external APIs, databases, time, randomness, and filesystems during integration testing. Mocking internal components or domain logic reduces test meaningfulness and couples tests to implementation details.

Can I use test-driven development for bug fixes and regression testing?

Test-driven development applies to bug fixes and regression testing by defining expected behavior with a failing test before implementing the fix. This ensures the regression is captured and verified through the red-green-refactor cycle.

When should I refactor code during the test-driven development cycle?

Refactor code during the green phase of the test-driven development cycle after tests pass. Refactoring while tests are green ensures behavior remains verified through public interfaces, allowing safe code improvements without introducing regressions.