test-driven-development

Enforce test-first implementation with red-green-refactor cycles.

131|4|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/AlphaLab-USTC/OhMyCode --skill test-driven-development-alphalab-ustc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/AlphaLab-USTC/OhMyCode/tree/main/.agents/skills/superpowers/test-driven-development
Command: npx skills add https://github.com/AlphaLab-USTC/OhMyCode --skill test-driven-development-alphalab-ustc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid brittle implementations, hidden regressions, and false confidence by enforcing a test-first workflow before any production code is written.

Core Features & Use Cases

  • Write Failing Tests First: Define the desired behavior before implementation so the test proves the feature is real.
  • Red-Green-Refactor Workflow: Move from failing test, to minimal passing code, to clean refactoring without losing correctness.
  • Bug Fix Regression Protection: Turn bugs into reproducible tests so they stay fixed.
  • Testing Guidance: Apply practical rules for using real behavior, avoiding over-mocking, and keeping tests meaningful.

Quick Start

Use the test-driven-development skill to design a failing test for the feature you want to build, then implement only enough 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 start using test-driven development for feature implementation?

To start test-driven development, design a failing unit test that defines the desired behavior before writing any production code. Implement only enough code to make that test pass, ensuring the feature is verified from the start.

What is the red-green-refactor workflow in unit testing?

The red-green-refactor workflow in unit testing moves from a failing test, to minimal passing code, to clean refactoring. This sequence ensures you validate behavior first, achieve correctness, and then improve code structure without losing test coverage.

How can I prevent regression risk when fixing software bugs?

To prevent regression risk when fixing software bugs, turn the bug into a reproducible failing test first. Implement the fix to make it pass, ensuring the specific behavior is verified and preventing future regressions from reoccurring.

Does test-driven development work for refactoring existing production code?

Yes, test-driven development works for refactoring production code by validating behavior changes through test-first implementation. You enforce a failing test before modifying the code, ensuring the refactoring maintains correctness and reduces hidden regression risk.

Why avoid over-mocking when writing unit tests?

Avoid over-mocking in unit tests because test-heavy mocks create false confidence and brittle implementations. Using real behavior in tests ensures they remain meaningful and accurately validate production code rather than just testing the mocks themselves.