test-driven-development

Guide test-driven development with the red-green-refactor cycle for software features.

1|Updated Apr 5, 2026
One-click install
npx skills add https://github.com/mortenbroesby/playground --skill test-driven-development-mortenbroesby
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/mortenbroesby/playground/tree/main/.skills/test-driven-development
Command: npx skills add https://github.com/mortenbroesby/playground --skill test-driven-development-mortenbroesby

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test-driven development provides a disciplined approach where tests drive the implementation, reducing regressions and ensuring code behaves as intended from the start.

Core Features & Use Cases

  • Red-Green-Refactor cycle: write a failing test, implement minimal code, then refactor for clarity.
  • Early failure visibility: ensure broken behavior is detected immediately before coding.
  • Guardrails for design: discourages over-engineering and encourages small, testable units.

Quick Start

Write a failing test for the target behavior, implement the minimal production code to pass, then refactor.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
What is test-driven development and how does it reduce bugs?

Test-driven development is a disciplined approach where you write tests before implementation, ensuring code behaves as intended from the start and reducing regressions. It uses early failure visibility to detect broken behavior immediately before coding.

How do I apply the red-green-refactor cycle to software features?

To apply the red-green-refactor cycle, write a failing test for the target behavior, implement the minimal production code required to pass that test, then refactor the code for clarity without changing its behavior.

When should I use TDD instead of writing tests after implementation?

You should use TDD when you need guardrails for design to discourage over-engineering and encourage small, testable units. It provides a structured workflow where failures drive minimal, testable production code.

Does test-driven development work for legacy codebases or only new projects?

Test-driven development works by writing a failing test for the target behavior and implementing minimal code to pass it. This disciplined approach reduces regressions and ensures intended behavior across both new features and existing team workflows.

Why does writing tests first improve software engineering quality?

Writing tests first improves quality by ensuring broken behavior is detected immediately before coding begins. This approach discourages over-engineering and encourages small, testable units, driving minimal production code and reducing regressions.