test-driven-development

Guide test-first development through a failing test cycle with Red-Green-Refactor.

6|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/caitengwei/my-skills --skill test-driven-development-caitengwei
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/caitengwei/my-skills/tree/main/superpowers/skills/test-driven-development
Command: npx skills add https://github.com/caitengwei/my-skills --skill test-driven-development-caitengwei

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid shipping unverified code by forcing tests to fail first, so the implementation proves it meets the required behavior rather than accidentally matching your assumptions.

Core Features & Use Cases

  • Test-first workflow: Write a minimal failing test, then implement the smallest code change to make it pass.
  • Red-Green-Refactor discipline: Keep refactoring strictly after the test is green, preventing accidental behavior drift.
  • Verification rigor: Explicitly verify that the failing test fails for the expected reason and that the passing run leaves the test suite healthy.
  • When to apply: Use for new features, bug fixes, refactoring, and behavior changes; avoid exceptions like throwaway prototypes and generated code unless your human partner approves.

Quick Start

Use test-driven-development when you need to implement a feature or bug fix by writing a single failing test that captures the desired behavior, confirming it fails for the right reason, and then writing the minimal code needed to make the test pass before refactoring.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I start test-driven development for a new feature?

Test-driven development begins by writing a minimal failing unit test that captures the desired behavior, confirming it fails for the expected reason, then writing the smallest code change to make it pass before refactoring.

What is the Red-Green-Refactor cycle in unit testing?

The Red-Green-Refactor cycle is a unit testing discipline requiring a RED phase with a minimal failing test, a GREEN phase with the smallest production change to pass it, and a REFACTOR phase that keeps tests green while preventing behavior drift.

Can I use test-first development for bug fixes and refactoring?

Yes, test-first development applies to bug fixes, refactoring, and behavior changes by defining expected behavior as an executable test, ensuring the implementation earns correctness rather than accidentally matching assumptions.

When should I avoid the TDD workflow?

You should avoid the TDD workflow for throwaway prototypes and generated code unless explicitly approved, as the verification rigor of failing tests first adds unnecessary overhead to unverified or temporary exploratory code.

Why verify that a failing test fails for the expected reason?

Verifying that a failing test fails for the expected reason ensures your implementation earns correctness through the test cycle, preventing false positives where code accidentally passes tests without meeting the actual behavior requirements.