test-driven-development

Enforces red-green-refactor test-driven development workflow before writing production code.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Developers often write production code first and add tests afterward, which produces tests that pass immediately and prove nothing about correctness. This Skill enforces a strict test-first discipline so every feature and bugfix is backed by a test that was watched failing before implementation. ## Core Features & Use Cases - Red-Green-Refactor Enforcement: Guides the full TDD cycle—write a failing test, verify it fails for the right reason, write minimal code to pass, then refactor while staying green. - Rationalization Detection: Lists common excuses for skipping TDD ("too simple to test", "I'll test after") with concrete rebuttals and red flags that trigger a restart. - Testing Anti-Pattern Reference: Covers mock behavior testing, test-only production methods, incomplete mocks, and over-mocking, with gate functions to catch violations. - Use Case: When fixing a bug where empty emails are accepted, write a failing test asserting the rejection error, watch it fail, implement the minimal validation, and confirm all tests pass before refactoring. ## Quick Start Use the test-driven-development skill to implement this feature by writing a failing test first, then the minimal code to make 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 practice test-driven development on a new feature?

Write one minimal failing test describing the desired behavior, run it and confirm it fails because the feature is missing, then write the simplest code to pass. Refactor only after all tests are green, and repeat the cycle for each new behavior.

How do I write a failing test for a bug fix?

Write a test that reproduces the bug by asserting the correct expected behavior, then run it to confirm it fails. Implement the minimal fix, verify the test passes along with all other tests, and the test now prevents regression.

Why should tests be written before implementation code?

Tests written after code pass immediately, which proves nothing—they may test the wrong thing or mirror the implementation. Watching a test fail first proves it actually exercises the missing behavior and catches real bugs.

When is it acceptable to skip test-driven development?

Exceptions are limited to throwaway prototypes, generated code, and configuration files, and only with explicit approval from your human partner. Exploration is allowed, but the exploratory code must be discarded and rewritten test-first.

Why does my test pass when I remove the mock?

This signals you were testing mock behavior rather than real component behavior. Unmock the component and assert on real outputs, or mock at a lower level so the side effects your test depends on still occur.