test-driven-development

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

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills --skill test-driven-development-lgj-jonathan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills/tree/main/superpowers/skills/test-driven-development
Command: npx skills add https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills --skill test-driven-development-lgj-jonathan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code written before tests often ships with unverified behavior, hidden bugs, and no regression safety net. This Skill enforces strict test-driven development so every line of production code is backed by a test that was watched fail first. ## 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") and explains why each one fails, with red flags that trigger starting over. - Testing Anti-Pattern Reference: Covers pitfalls like testing mock behavior, adding test-only methods to production classes, incomplete mocks, and mocking without understanding dependencies. - 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 it passes, and refactor—guaranteeing the fix is proven and regression-protected. ## 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 step by step?

Follow the red-green-refactor cycle: write one minimal failing test, run it and confirm it fails for the expected reason, write the simplest code to make it pass, verify all tests pass, then refactor while keeping tests green. Repeat for each new behavior.

Why should I write tests 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 tests the intended behavior and forces edge-case discovery before coding.

When is it acceptable to skip TDD?

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

What should I do if my test passes immediately?

An immediately passing test means you are testing existing behavior, not new functionality. Fix the test so it targets the missing feature, run it again, and confirm it fails for the expected reason before writing any implementation code.

Why is testing mock behavior considered an anti-pattern?

Asserting on mock elements verifies the mock exists, not that the component works. Test real behavior instead—either unmock the component or assert on outcomes the real code produces, and mock only after understanding the dependency's side effects.

How do I handle bug fixes with TDD?

Write a failing test that reproduces the bug first, then follow the normal TDD cycle to fix it. The test proves the fix works and permanently prevents the bug from regressing.