test-driven-development

Enforces test-first development using the red-green-refactor cycle for features and bugfixes.

Updated Nov 1, 2024
One-click install
npx skills add https://github.com/mlorentedev/dotfiles --skill test-driven-development-mlorentedev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/mlorentedev/dotfiles/tree/main/harness/skills/test-driven-development
Command: npx skills add https://github.com/mlorentedev/dotfiles --skill test-driven-development-mlorentedev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code written before tests often ships unverified, and tests written after implementation pass immediately without proving they catch real bugs. This Skill enforces a strict test-first discipline so every behavior change is backed by a test that was watched failing before implementation. ## Core Features & Use Cases - Red-Green-Refactor Enforcement: Guides the full cycle of writing a failing test, verifying it fails for the right reason, writing minimal code to pass, and refactoring while staying green. - Anti-Rationalization Guardrails: Provides explicit rebuttals to common excuses like "I'll test after" or "deleting code is wasteful", plus red flags that signal when to delete code and start over. - Testing Anti-Pattern Reference: Ships a companion reference covering mock-behavior testing, test-only production methods, incomplete mocks, and over-mocking, with gate functions to catch each. - Use Case: When fixing a bug where empty emails are accepted, write a failing test asserting the rejection, watch it fail, implement the minimal validation, verify green, then refactor. ## Quick Start Ask the AI to implement your next feature or bugfix using strict test-driven development with a failing test written and verified 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 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 stay green, then repeat for the next behavior.

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

Write a test that reproduces the bug, such as asserting that an empty email is rejected, and run it to confirm it fails. Implement the minimal fix, verify the test passes and no other tests break, then refactor if needed.

What is the difference between tests written before and after code?

Tests written after code pass immediately, which proves nothing about whether they catch real bugs. Tests written first are watched failing, proving they actually test the intended behavior rather than the existing implementation.

When is it acceptable to skip test-driven development?

The Skill lists throwaway prototypes, generated code, and configuration files as possible exceptions, but only with explicit approval from your human partner. Rationalizing a skip "just this once" is treated as a red flag.

Why should I avoid asserting on mock elements in tests?

Asserting on mocks verifies the mock exists rather than testing real component behavior. The companion anti-patterns reference recommends testing the real component or unmocking it, and mocking only at the lowest level after understanding dependencies.