test-driven-development

Write failing tests before implementing code using the Red-Green-Refactor workflow.

406|71|Updated Oct 22, 2025
One-click install
npx skills add https://github.com/brobertsaz/claude-os --skill test-driven-development-brobertsaz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/brobertsaz/claude-os/tree/main/templates/skills/test-driven-development
Command: npx skills add https://github.com/brobertsaz/claude-os --skill test-driven-development-brobertsaz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enforces a test-first approach: write a failing test before implementing code, ensuring your changes verify the intended behavior and preventing regression.

Core Features & Use Cases

  • Red-Green-Refactor workflow: write a failing test, confirm it fails, implement just enough code to pass, then refactor.
  • Quality assurance through tests: builds a safety net that guides design decisions and reduces debugging time.
  • Use Case: Start a new feature by outlining its expected behavior in a test; once the test fails, implement the minimal code to satisfy it and iterate.

Quick Start

Add a failing test that specifies the desired behavior for a small feature, run the test to observe the failure, implement the simplest code to make it pass, and then refactor as needed.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I write tests before implementing code?

Test-driven development writes a failing test first that specifies desired behavior, then implements minimal code to pass it. Start by defining what your feature should do in a test, run it to confirm failure, write just enough production code to pass, and refactor. This Red-Green-Refactor cycle ensures behavior aligns with requirements and prevents regression across new features, bug fixes, and refactoring.

Why should I use test-first development instead of testing after?

Test-first development guides design decisions upfront, catches bugs earlier, and builds a safety net that reduces debugging time. Writing tests before implementation ensures your code satisfies requirements from the start and protects against regression as you refactor and add features.

When do I apply the Red-Green-Refactor workflow?

Red-Green-Refactor applies whenever you add features, fix bugs, refactor existing code, or implement behavior changes. Write a failing test that specifies the intended behavior, confirm it fails, implement minimal code to pass, then refactor with confidence that tests catch regressions.

How does test-driven development reduce debugging time?

TDD builds a comprehensive safety net of tests that verify behavior continuously. By writing tests first, you catch misalignments between code and requirements immediately rather than discovering bugs late, and tests serve as executable documentation that guides future changes.

Can I use test-driven development for refactoring existing code?

Yes. Test-driven development applies to refactoring by ensuring your changes preserve existing behavior while improving design. Write tests that capture current behavior, refactor with confidence, and use test failures to catch unintended side effects.