tdd

Guide test-driven development with a red-green-refactor loop and integration-style tests.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/CinnamonfirJ/task-hub-webapp --skill tdd-cinnamonfirj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/CinnamonfirJ/task-hub-webapp/tree/main/skills/tdd
Command: npx skills add https://github.com/CinnamonfirJ/task-hub-webapp --skill tdd-cinnamonfirj

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TDD helps you develop features and fix bugs by ensuring each change is backed by tests that verify the system’s behavior through public interfaces, reducing regressions and fragile code.

Core Features & Use Cases

  • Red-Green-Refactor loop: Use an iterative workflow where you write a failing test (red), implement the minimum to make it pass (green), then improve structure (refactor).
  • Behavior-first, integration-style testing: Write tests that describe what the system does (observable outcomes) rather than how it does it (implementation details).
  • Vertical slicing via tracer bullets: Build one behavior end-to-end at a time to avoid bulk “horizontal slicing” that leads to low-quality tests.
  • Refactor candidates after GREEN: Improve design by extracting duplication, deepening modules, and strengthening interfaces without breaking behavior.
  • Mocking guidelines: Mock only system boundaries (e.g., external APIs, databases, time/randomness, filesystem) to keep tests meaningful.

Example use case: you’re adding a checkout feature and want an integration-style test that proves a user can checkout with a valid cart without tying the test to internal function calls.

Quick Start

Tell the AI: “Help me apply TDD with a red-green-refactor loop to implement the next checkout behavior for my app, writing one integration-style tracer test first and only mocking external boundaries.”

Frequently Asked Questions about tdd

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

FAQPage Schema
How do I use test-driven development to add a new feature without breaking existing behavior?

Test-driven development implements new features safely by guiding you through a red-green-refactor loop, writing a failing behavior-first test, coding the minimum to pass it, and then refactoring. This iterative workflow ensures observable outcomes are verified and regressions are reduced.

What is the best way to write integration-style tests that don't break during refactoring?

Integration-style tests that survive refactoring focus on what the system does through public interfaces rather than internal implementation details. By verifying observable outcomes using vertical tracer bullets, your tests remain meaningful and resilient to internal structural changes.

How do I apply mocking guidelines correctly when using test-driven development?

Mocking guidelines in test-driven development dictate that you mock only system boundaries like external APIs, databases, time, randomness, and filesystems. This approach keeps your integration-style tests meaningful by avoiding fragile mocks tied to internal function calls.

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

You should refactor code only after reaching the GREEN phase, where the minimum implementation has successfully made your failing test pass. This timing ensures you can safely extract duplication, deepen modules, and strengthen interfaces without breaking verified behavior.

Does test-driven development work for fixing bugs as well as building new features?

Test-driven development works for both fixing bugs and building new features by backing each change with integration-style tests. Writing a failing test that reproduces the bug or defines the new behavior ensures reliable regression protection and clear public interfaces.