test-driven-development

Enforce test-driven development with a RED-GREEN-REFACTOR cycle and mandatory failure verification.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents regressions and incorrect implementations by ensuring every new behavior is proven with a failing test before production code is written.

Core Features & Use Cases

  • Test-first behavior design: Write the smallest test that captures the intended behavior, watch it fail, then implement only what the test requires.
  • Red–Green–Refactor discipline: Keep the workflow tight—RED, mandatory failure verification, minimal GREEN code, mandatory pass verification, then safe refactoring after tests are green.
  • Bug fix as a repeatable proof: Reproduce the bug with a failing regression test and verify it stays fixed without breaking other tests.
  • Cross-cutting guidance during execution planning: Apply this pattern broadly for new features, bug fixes, and behavior changes, with explicit exemptions when appropriate.

Quick Start

Use the test-driven-development skill to write a failing regression test first, confirm the failure is expected, then add the minimum production code to make the test pass while keeping other tests green.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How does test-driven development prevent regressions when writing new features?

Test-driven development prevents regressions by requiring a failing test before production code is written, ensuring every new behavior is proven correct and existing tests stay green throughout the workflow.

How do I apply the red-green-refactor cycle for unit testing?

To apply the red-green-refactor cycle, write a failing test (RED), verify it fails for the right reason, write minimal production code to pass (GREEN), verify clean output, then safely refactor while tests remain green.

What is the best way to fix bugs using regression testing?

The best way to fix bugs using regression testing is to first reproduce the bug with a failing test, then implement the fix to make it pass, verifying the regression stays fixed without breaking other tests.

When should I use a test-first workflow for behavior changes?

Use a test-first workflow for behavior changes when correctness must be demonstrated and regressions prevented, applying it broadly to new features and bug fixes, with explicit exemptions when appropriate.

Why must I verify that a failing unit test fails for the right reason?

You must verify a failing unit test fails for the right reason to ensure the RED phase accurately captures the intended behavior, preventing false positives when writing minimal production code in the GREEN phase.