test-driven-development

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

Updated Aug 5, 2026
One-click install
npx skills add https://github.com/ahsanghalib/ai-workflow --skill test-driven-development-ahsanghalib
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/ahsanghalib/ai-workflow/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/ahsanghalib/ai-workflow --skill test-driven-development-ahsanghalib

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing code behavior without a disciplined test loop leads to regressions, untested edge cases, and unverifiable claims of correctness. This Skill enforces a structured red-green-refactor workflow so every behavior change is proven by a failing-then-passing test. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Add one focused failing test, implement the smallest change to pass it, then refactor while keeping tests green. - Applicability Judgment: Identifies when TDD does not apply, such as documentation-only changes, generated files, exploratory spikes, or work without a runnable test seam, and requires an alternative verification plan. - Evidence-Based Completion: Records red, green, and refactor evidence in a structured TDD record and integrates with verification-before-completion checks. - Use Case: When adding a new validation rule to an API handler, write a failing test for the expected rejection behavior, implement the minimal validation logic, then refactor while re-running the targeted test. ## Quick Start Use the test-driven-development skill to add a failing test for the new behavior, then implement the smallest change that makes it pass.

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 code change?▼

Test-driven development follows red-green-refactor: write one focused failing test for the behavior, implement the smallest change that makes it pass, then refactor while keeping the test green. Run the narrowest test command at each step and record the evidence.

When should I not use TDD?▼

Skip the failing-test-first loop for documentation-only changes, configuration-only changes, generated files, time-boxed exploratory spikes, and work with no runnable test loop. State the exception explicitly and provide an alternative verification plan instead of skipping coverage.

What should I do if my new test passes unexpectedly?▼

An unexpectedly passing test means the assertion is too weak or the behavior already exists. Strengthen the assertion or reassess the behavior before changing production code, and never write the implementation first and retrofit a passing test.

When is mocking appropriate in TDD?▼

Mock only boundaries that are expensive, non-deterministic, externally owned, or unsafe to exercise. Prefer real collaborators when practical, and verify the mock does not replace the behavior under test.

How do I verify a behavior change is complete?▼

Mark behavior verified only when the chosen test demonstrated its intended failure and then passes after the final implementation change. Run targeted and broader checks, review the final diff, and explicitly report any untested paths.