test-driven-development

Guide developers through the Red-Green-Refactor cycle with failing tests before code.

14|1|Updated Dec 29, 2011
One-click install
npx skills add https://github.com/doitian/dotfiles-public --skill test-driven-development-doitian
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/doitian/dotfiles-public/tree/main/ai/workflows/superpowers/skills/test-driven-development
Command: npx skills add https://github.com/doitian/dotfiles-public --skill test-driven-development-doitian

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing and maintaining software without reliable tests leads to regressions, unclear requirements, and debugging chaos. This skill guides teams to adopt a test-driven development approach that ensures the failing-test-first discipline is practiced before any production code is written.

Core Features & Use Cases

  • Enforces the Red-Green-Refactor cycle to validate behavior incrementally.
  • Improves design and documentation through explicit test cases and naming.
  • Applies to new features, bug fixes, and refactors where risk of regression must be minimized.

Quick Start

Start by writing a failing test that defines the desired behavior, then implement the minimal code to satisfy the test and refactor.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I apply test-driven development to fix bugs without causing regressions?

The Red-Green-Refactor cycle enforces test-driven development by starting with a failing test, writing minimal code to make it pass, and then refactoring. This validates behavior incrementally and ensures reliable tests before production code is written.

When should I use TDD instead of writing tests after the feature is built?

To start a TDD workflow, write a failing test that defines the desired behavior. Then implement the minimal code required to satisfy that test, and finally refactor the code while keeping the test passing.

How do I maintain test scope and prevent regressions during refactoring?

TDD improves software design and documentation by forcing developers to define explicit test cases and use clear test naming. This approach ensures requirements are clear and behavior is validated before minimal production code is written.

What is the Red-Green-Refactor cycle in test-driven development?

The Red-Green-Refactor cycle is a test-driven development workflow where you write a failing test, implement minimal code to pass it, and then refactor. This enforces incremental behavior validation and ensures reliable tests precede production code.

When should I use TDD instead of writing tests after the feature is built?

Use TDD for new features, bug fixes, and refactors where minimizing regression risk is critical. It enforces the failing-test-first discipline, clarifies requirements through explicit test cases, and improves overall software design.

How do I maintain test scope and prevent regressions during refactoring?

Maintain test scope during refactoring by keeping tests focused on behavior rather than implementation details. The TDD workflow requires real tests to validate incremental changes, preventing scope creep and ensuring regressions are caught immediately.