test-driven-development

Enforce a failing test before writing production code in a red-green-refactor cycle.

98|25|Updated Mar 14, 2020
One-click install
npx skills add https://github.com/baotoq/micro-commerce --skill test-driven-development-baotoq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/baotoq/micro-commerce/tree/main/.agents/skills/test-driven-development
Command: npx skills add https://github.com/baotoq/micro-commerce --skill test-driven-development-baotoq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test-driven development helps teams reduce defects by requiring tests before coding, ensuring intended behavior is captured early and reducing debugging time later.

Core Features & Use Cases

  • Test-first discipline: write a failing test that defines expected behavior before implementing code.
  • Red-Green-Refactor cycle: follow the cycle to deliver minimal production code with confidence and maintainability.
  • Applicable across tasks: ideal for new features, bug fixes, or refactors to guard against regressions and guide design decisions.

Quick Start

Write a failing test that expresses the desired outcome, then implement the simplest code to pass it, and finally refactor for clarity.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
What is test-driven development and how does it reduce software defects?

Test-driven development is a discipline where you write a failing test defining expected behavior before implementing production code. It reduces defects by capturing intended behavior early and lowering debugging time across new features, bug fixes, and refactoring tasks.

How do I apply the red-green-refactor cycle when writing unit tests?

The red-green-refactor cycle starts by writing a failing test expressing the desired outcome, then implementing the simplest production code to pass it, and finally refactoring for clarity. This disciplined loop ensures minimal, well-named tests and clean, refactorable code verified by a full suite.

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

Test-first development is ideal for bug fixes and refactoring because it guards against regressions and guides design decisions. By demanding a failing test before modifying production code, it ensures intended behavior is captured and verified by a full test suite throughout the process.

Can I use test-driven development for both new features and code refactoring?

Yes, test-driven development applies across tasks including new features, bug fixes, and refactoring. It enforces a test-first discipline that guards against regressions, guides design decisions, and ensures clean, refactorable production code verified by a full test suite.

What is the best way to write minimal production code using TDD?

The best way to write minimal production code using TDD is to first write a failing test that expresses the desired outcome, implement the simplest code to pass that test, and then refactor for clarity. This ensures minimal, well-named tests and clean code.