test-driven-development

Implements features and bug fixes using behavior-focused red-green-refactor test-driven development.

Updated May 19, 2026
One-click install
npx skills add https://github.com/davidsunglee/pi-flow --skill test-driven-development-davidsunglee
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/davidsunglee/pi-flow/tree/main/packages/pi-flow-core/skills/test-driven-development
Command: npx skills add https://github.com/davidsunglee/pi-flow --skill test-driven-development-davidsunglee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It prevents untested or over-engineered code by enforcing a disciplined test-first workflow where every behavior change is proven by a failing test before any production code is written. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Guides one behavior at a time through a failing test, minimal implementation, and safe refactoring while green. - Behavior-Focused Testing Rules: Enforces testing through public interfaces, mocking only true external boundaries, and avoiding implementation-coupled tests. - Bug Fix Discipline: Requires a regression test that reproduces the real failure path before any non-trivial bug fix. - Use Case: When asked to add a new API endpoint, the Skill writes one failing test for the observable response, implements the minimal handler, verifies green, then refactors safely. ## Quick Start Use test-driven development to implement this feature, starting with a failing test for the expected behavior.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development on a new feature?▼

Write one minimal failing test for a single behavior, verify it fails for the expected reason, then write the smallest production change that passes it. Refactor only while tests are green, then repeat for the next behavior.

How to write a regression test for a bug fix?▼

Reproduce the bug with the smallest failing test that follows the real failure path, confirm it fails with the observed bug, then fix minimally. Keep the regression test permanently to prevent recurrence.

Should unit tests mock internal modules and classes?▼

No, tests should use real internal collaborators and mock only true boundaries like external APIs, payments, email, time, and randomness. Mocking internal code creates implementation-coupled tests that break during refactoring.

When is it acceptable to skip test-driven development?▼

Exceptions include throwaway prototypes, generated code, pure configuration changes, and docs-only changes, but they require explicit human approval or a documented note. Exploratory code must be discarded and restarted from a failing test.

Why did my new test pass immediately without implementation?▼

A test that passes immediately does not prove new behavior and signals a problem with the test itself. Revert any premature production code, fix the test so it fails for the expected reason, then implement from that failing test.