test-driven-development

Guides red-green-refactor test-driven development for behavior-affecting code changes.

7|Updated May 13, 2026
One-click install
npx skills add https://github.com/DawnMoon1542/agents-skills --skill test-driven-development-dawnmoon1542
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/DawnMoon1542/agents-skills/tree/main/workflow/test-driven-development
Command: npx skills add https://github.com/DawnMoon1542/agents-skills --skill test-driven-development-dawnmoon1542

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code changes with real behavioral impact often ship without tests that actually verify the target behavior, leading to regressions, mock-only tests, and false confidence. This Skill enforces a disciplined red-green-refactor workflow so every feature, bug fix, or behavioral refactor is backed by a minimal, meaningful verification. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Write a minimal failing test that distinguishes current from target behavior, implement the smallest change to pass it, then refactor while keeping tests green. - Bug Fix Regression Tests: Reproduce bugs with a failing test first, confirm it fails for the right reason, then apply the minimal fix and verify the regression suite passes. - Testing Anti-Pattern Detection: A bundled reference identifies mock-behavior assertions, test-only production methods, uninformed mocking, and incomplete mock data structures. - Use Case: When fixing a duplicate-server detection bug, write a failing regression test that adds the same server twice, confirm it fails because of the bug, apply the minimal fix, and verify the test passes without mocking away the configuration writes the test depends on. ## Quick Start Ask the AI to implement your next feature or bug fix using test-driven development with a failing test written before any production code.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I apply test-driven development to a bug fix?

Write a failing regression test that reproduces the bug, confirm it fails because of that specific bug, then apply the minimal fix until the test passes. If the test framework does not fit the problem, use a minimal repeatable check to document the reproduction and fix instead.

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

Red-green-refactor means writing a minimal failing test, verifying it fails for the right reason, writing the smallest implementation to make it pass, then cleaning up duplication and naming while keeping the same tests green. Each step validates behavior, not just code structure.

When should I mock dependencies in unit tests?

Mock only when external systems make real usage impractical, and only after understanding which side effects the test depends on. Mock at the lowest level that isolates slow or external operations, and never assert on mock existence instead of real component behavior.

Why do my tests pass but the code still fails in production?

This usually happens when mocks are incomplete or tests verify mock behavior instead of real interactions. Ensure mock data mirrors the full real API response structure and that tests exercise actual code paths rather than only mock call counts.

When is TDD not required for a code change?

Pure documentation, static assets, and generated files do not need behavioral tests; verify file contents or rendered output instead. Low-impact or purely presentational changes can use lighter checks proportional to their actual behavioral impact.