tdd

Enforce a RED-GREEN-REFACTOR cycle for behavior-changing code.

Updated May 17, 2022
One-click install
npx skills add https://github.com/kanade0404/dotfiles --skill tdd-kanade0404
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/kanade0404/dotfiles/tree/main/.opencode/skills/tdd
Command: npx skills add https://github.com/kanade0404/dotfiles --skill tdd-kanade0404

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents behavior changes from being coded before they are specified by a failing test, reducing regressions and keeping implementation aligned with intended behavior.

Core Features & Use Cases

  • Enforces a strict RED-GREEN-REFACTOR cycle for one behavior at a time.
  • Distinguishes real test failures from setup problems so development does not continue on a false red.
  • Useful for new features, bug fixes, API behavior changes, and review-driven behavioral corrections when you need confidence in observable behavior.

Quick Start

Use the tdd skill to add one behavior by writing a failing test first, then implementing the smallest fix, and finally refactoring while keeping all tests green.

Frequently Asked Questions about tdd

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

FAQPage Schema
How do I use test-first development for bug fixes and new features?▼

Test-first development for bug fixes and new features is enforced by writing a failing test that specifies the intended behavior before any implementation code is written. This ensures the smallest fix is applied only after verifying a genuine test failure.

What is the red-green-refactor cycle in unit testing?▼

The red-green-refactor cycle in unit testing is a strict development loop where you write a failing test, implement the smallest code to make it pass, and then refactor while keeping all tests green. It enforces behavior verification one cycle at a time.

How do I distinguish real test failures from setup problems during test-first development?▼

To distinguish real test failures from setup problems during test-first development, the process rejects false-red setup failures and halts development if the test fails due to environmental issues rather than the intended behavior change.

Can I apply test-first development to API behavior changes and integration workflows?▼

Yes, test-first development applies to API behavior changes and integration workflows by requiring a verified failing test before altering any observable program behavior in both unit and integration workflows.

What is the best way to prevent regressions when changing observable program behavior?▼

The best way to prevent regressions when changing observable program behavior is to preserve existing passing tests while enforcing a strict test-first cycle, ensuring implementation aligns completely with the newly specified behavior.

When should I not use a strict red-green-refactor cycle?▼

A strict red-green-refactor cycle should not be used when a request does not alter observable program behavior in unit or integration workflows, as it is specifically designed to enforce behavior-changing code through verified failing tests.