test-driven-development

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

4|1|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/samjhecht/wrangler --skill test-driven-development-samjhecht
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/samjhecht/wrangler/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/samjhecht/wrangler --skill test-driven-development-samjhecht

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing tests after code often leads to incomplete, ineffective tests that don't truly verify behavior, resulting in hidden bugs, regressions, and a lack of confidence in the codebase.

Core Features & Use Cases

  • RED-GREEN-REFACTOR Cycle: Enforces the fundamental TDD workflow: write a failing test, write minimal code to pass, then refactor.
  • Failing Test Mandate: Requires observing a test fail before writing implementation code, proving the test actually verifies the intended behavior.
  • Anti-Pattern Prevention: Explicitly forbids common TDD violations like writing code before tests or testing mocks, ensuring high-quality test suites.
  • Use Case: When implementing any new feature, fixing a bug, or refactoring existing code, this skill ensures a systematic, test-first approach that builds trust and prevents regressions.

Quick Start

I need to implement a new 'retryOperation' function. Guide me through the TDD process.

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 coding to catch bugs early?

Test-driven development (TDD) writes failing tests first, then minimal code to pass them. This ensures tests verify actual behavior, preventing hidden bugs and regressions that plague post-hoc testing approaches.

What is the red-green-refactor workflow in TDD?

Red-green-refactor is TDD's core cycle: write a failing test (red), write minimal code to pass it (green), then refactor for quality. This discipline ensures every line of production code is validated by a test that proved it was necessary.

Why should I require a failing test before writing implementation code?

Observing a test fail before implementation proves the test actually verifies your intended behavior rather than passing by accident. This prevents false confidence and ensures regressions are caught when behavior changes.

Can I apply TDD to bug fixes and refactoring, or only new features?

TDD applies to new features, bug fixes, refactoring, and behavior changes. Write a failing test that reproduces the bug or specifies desired behavior, then implement minimal code to pass it, ensuring the fix is validated and won't regress.

What are common TDD anti-patterns I should avoid?

Avoid writing code before tests, testing implementation details through mocks instead of behavior, and writing tests after code. These patterns defeat TDD's purpose of preventing bugs and building confidence through test-first discipline.

How does TDD improve code quality and prevent regressions?

Test-first development builds a suite of behavior specifications before implementation. Each test validates one requirement, creating a safety net that catches regressions when code changes and prevents bugs from silently emerging.