test-driven-development

Implements code changes using the red-green-refactor test-driven development loop.

1|Updated Sep 4, 2026
One-click install
npx skills add https://github.com/SanHsien/agent-skills --skill test-driven-development-sanhsien
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/SanHsien/agent-skills/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/SanHsien/agent-skills --skill test-driven-development-sanhsien

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code changes made without tests ship unverified behavior, and bug fixes without reproduction tests leave regressions unguarded. This Skill enforces a disciplined workflow where every behavior change is proven by a failing-then-passing test before it is considered done. ## Core Features & Use Cases - Red-Green-Refactor Loop: Write a failing test first, implement the minimal code to pass it, then refactor with tests staying green. - Prove-It Pattern for Bug Fixes: Reproduce any reported bug with a failing test before attempting a fix, guaranteeing the fix actually works. - Stack Discovery: Detects the repository's own test framework and commands (npm, Gradle, pytest, Cargo, Go) instead of assuming defaults. - Test Quality Guidance: Covers the test pyramid, DAMP over DRY, state-based assertions, and preferring real implementations over mocks. - Use Case: A bug report says completing a task doesn't set its timestamp. The Skill guides the agent to write a failing reproduction test, implement the fix, confirm the test passes, and run the full suite for regressions. ## Quick Start Ask the agent to implement a new feature or fix a bug using test-driven development, writing a failing test first and proving the fix with a passing test.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development when fixing a bug?

Write a test that reproduces the bug first and confirm it fails, then implement the fix and confirm the test passes. This Prove-It Pattern guarantees the fix works and guards against future regressions.

What is the red-green-refactor cycle in TDD?

Red means writing a failing test for the desired behavior, green means writing the minimal code to make it pass, and refactor means cleaning up the implementation while keeping tests green. The cycle repeats for each new behavior.

Should I use mocks or real implementations in unit tests?

Prefer real implementations first, then fakes, stubs, and finally mocks as a last resort. Reserve mocks for dependencies that are slow, non-deterministic, or have uncontrollable side effects like external APIs or email sending.

When should I not write tests for a change?

Skip tests only for pure configuration changes, documentation updates, or static content with no behavioral impact. Any change to logic, behavior, or edge case handling warrants a corresponding test.

Why do my tests break every time I refactor code?

Tests that verify internal method calls or implementation details break during refactoring even when behavior is unchanged. Assert on inputs and outputs (state-based testing) instead of interaction sequences.