test-driven-development

Enforces red-green-refactor test-first discipline for feature and bugfix implementation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers and AI agents under pressure routinely write implementation code before tests, then rationalize that ordering does not matter, producing unverified code and tests that prove nothing. This Skill enforces a strict test-first discipline so every behavior is proven by a failing test before any production code exists. ## Core Features & Use Cases - Iron Law Enforcement: No production code without a failing test first; code written before the test must be deleted, not adapted or kept as reference. - Red-Green-Refactor Cycle: One minimal failing test per behavior, the simplest passing implementation, then refactoring only with green tests as a safety net, never batching acceptance criteria. - Rationalization Countermeasures: A table of common excuses ("too simple to test", "I'll test after") with rebuttals, plus red flags that force a restart and a verification checklist before claiming completion. - Testing Anti-Patterns Reference: Guidance against testing mock behavior, adding test-only methods to production classes, mocking without understanding dependencies, and incomplete mocks. - Use Case: When fixing a bug, write a failing test that reproduces it first, then implement the minimal fix and confirm the full suite stays green before marking the work complete. ## Quick Start Ask the agent to implement the next feature using strict test-driven development, writing and running a failing test 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 practice test-driven development on a new feature?

Write one minimal failing test for a single behavior, run it to confirm it fails because the feature is missing, then write the simplest code that passes. Refactor only while tests stay green, and repeat one loop per acceptance criterion without batching.

What should I do if I already wrote code before the test?

Delete the implementation entirely and start over from a failing test. Keeping it as reference or adapting it while writing tests is still testing after the fact, which proves nothing about the intended behavior.

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

Write a test that reproduces the bug and watch it fail before touching the fix. This confirms the test targets the real defect, then implement the minimal fix and verify the whole suite passes cleanly.

Why is testing mock behavior considered an anti-pattern?

Asserting on mock elements verifies the mock exists, not that the component works, so the test proves nothing about real behavior. Test the real component, or mock at a lower level while preserving the side effects the test depends on.

When is it acceptable to skip test-driven development?

Exploratory spikes are acceptable, but the exploration code must be thrown away and the real work restarted with TDD. Excuses like "too simple to test" or "I'll test after" are listed rationalizations that indicate you should restart.