test-driven-development

Write failing tests before production code using a red-green-refactor cycle.

130|8|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/sandgardenhq/sgai --skill test-driven-development-sandgardenhq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/sandgardenhq/sgai/tree/main/cmd/sgai/skel/.sgai/skills/test-driven-development
Command: npx skills add https://github.com/sandgardenhq/sgai --skill test-driven-development-sandgardenhq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Development often proceeds without automated verification, leading to bugs, regressions, and unclear behavior. This Skill enforces a disciplined approach that requires a failing test before any production code, ensuring that every change is validated against explicit expectations.

Core Features & Use Cases

  • Red‑Green‑Refactor Cycle: Structured process that guides you from a failing test to minimal implementation and clean refactoring.
  • Universal Applicability: Suitable for new features, bug fixes, refactoring tasks, and behavior changes across any codebase.
  • Quality Assurance: Guarantees that tests are meaningful, run before code, and serve as living documentation for future maintenance.

Quick Start

Ask the AI to start a test‑driven development session for the feature you are about to implement.

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 software feature?

Test-driven development is a software development technique where you write failing unit tests before production code to verify intended behavior. It enforces a disciplined red-green-refactor cycle, ensuring every change is validated against explicit expectations and preventing regressions.

Can I use the red-green-refactor cycle when refactoring existing code?

Yes, the red-green-refactor cycle is universally applicable for refactoring existing code, bug fixes, and behavior changes. You write a failing test to capture the desired new behavior, implement minimal code to pass it, and then safely refactor while maintaining continuous test validation.

What is the best way to ensure unit tests serve as living documentation?

The best way to make unit tests serve as living documentation is to write them first with comprehensive assertions before the production code exists. This test-driven approach guarantees tests are meaningful, explicitly define expected behavior, and remain accurate for future maintenance.

Do I need to write a failing test before fixing a bug?

Yes, you need to write a failing test before fixing a bug to explicitly define the incorrect behavior and ensure your fix resolves it. This test-driven approach validates the bug fix against strict expectations and prevents future regressions by maintaining continuous test coverage.

Why does writing tests first improve code quality compared to testing after implementation?

Writing tests first improves code quality by requiring minimal production code to pass comprehensive assertions, which prevents over-engineering. This disciplined approach ensures every behavior change is validated upfront, eliminating untested code paths and reducing bugs.