test-driven-development

Write failing tests before code using the RED-GREEN-REFACTOR cycle.

2|Updated Oct 28, 2022
One-click install
npx skills add https://github.com/jmanuelrosa/dotfiles --skill test-driven-development-jmanuelrosa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/jmanuelrosa/dotfiles/tree/main/roles/ai/files/claude/skills/tdd
Command: npx skills add https://github.com/jmanuelrosa/dotfiles --skill test-driven-development-jmanuelrosa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test-driven development (TDD) provides a disciplined workflow that prevents defect-prone code by forcing a failing test before implementation, ensuring changes align with desired behavior and reducing regression risk.

Core Features & Use Cases

  • Red-Green-Refactor cycle: write a failing test, implement minimal code to pass, then improve the implementation without changing behavior.
  • Prove-It pattern for bug fixes: reproduce the bug with a test before implementing a fix.
  • Clear testing best practices: focus on behavior over internals, isolate tests, descriptive names, and small, focused assertions.
  • Use cases: when adding new logic, fixing bugs, modifying behavior, handling edge cases, or validating critical user flows.

Quick Start

Start by writing a failing test that captures the desired behavior, then implement the minimal code to make it pass, and finally refactor for clarity and robustness.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I start test-driven development when adding new features or fixing bugs?

Start test-driven development by writing a failing test that captures the desired behavior, then implement the minimal code to make it pass, and finally refactor for clarity without changing behavior. This enforces the RED-GREEN-REFACTOR cycle.

What is the best way to reproduce a bug before implementing a fix?

Use the Prove-It pattern to reproduce the bug by writing a failing test before implementing the fix. This ensures the bug is accurately captured and prevents future regressions when modifying behavior.

How does the RED-GREEN-REFACTOR cycle work in test-driven development?

The RED-GREEN-REFACTOR cycle works by first writing a failing test for desired behavior, then implementing minimal code to pass the test, and finally improving the implementation for robustness without altering behavior.

Can I apply test-driven development across any technology stack?

Yes, test-driven development is applicable across any stack when adding new logic, fixing bugs, modifying behavior, handling edge cases, or validating critical user flows. It focuses on behavior over internal implementation details.

What testing best practices should I follow when isolating test assertions?

Follow behavior-focused testing best practices by using descriptive test names, isolating tests, and keeping assertions small and focused. This ensures clear validation of specific software behavior without testing internal implementation details.

Why does test-driven development help prevent defect-prone code and reduce regression risk?

Test-driven development prevents defect-prone code by forcing a failing test before implementation, ensuring changes align with desired behavior. This disciplined workflow reduces regression risk across all software modifications.