test-driven-development

Enforce a failing test before implementing minimal code changes.

4|Updated Dec 7, 2020
One-click install
npx skills add https://github.com/charly3pins/dotfiles --skill test-driven-development-charly3pins
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/charly3pins/dotfiles/tree/main/.config/opencode/skills/test-driven-development
Command: npx skills add https://github.com/charly3pins/dotfiles --skill test-driven-development-charly3pins

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing tests after code often leads to tests that don't truly verify behavior, miss edge cases, or provide false confidence, resulting in fragile software and more bugs.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Enforces the core TDD loop: write a failing test, then minimal code to pass, then refactor.
  • Iron Law Enforcement: Prevents writing any production code without a failing test first, guaranteeing test validity.
  • Rationalization Counters: Addresses common excuses for skipping TDD, ensuring strict adherence to the methodology.
  • Use Case: When starting a new feature or fixing a bug, use this skill to ensure every line of production code is backed by a test that was seen to fail first, guaranteeing test validity and preventing regressions.

Quick Start

I need to implement a new feature. Guide me through the Test-Driven Development process, starting with writing a failing 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 start with test-driven development to prevent bugs?

Test-driven development prevents bugs by writing a failing test before any production code. The red-green-refactor cycle enforces writing tests first, observing them fail, then implementing minimal code to pass, ensuring every line is backed by a valid test.

What's the difference between writing tests first versus after implementation?

Writing tests first guarantees test validity and catches edge cases, while writing tests after code often produces tests that miss behavior gaps and provide false confidence. TDD's iron law requires a failing test before any production code, eliminating this risk.

How do I apply test-driven development to a new feature?

Start by writing a failing test that defines the feature's expected behavior. Observe the test fail, then write minimal production code to pass it. Finally, refactor the code while keeping tests passing. This cycle ensures feature correctness and prevents regressions.

Can I use test-driven development for bug fixes?

Yes, TDD works for bug fixes by first writing a failing test that reproduces the bug, then implementing the minimal fix to pass the test. This guarantees the bug is fixed and prevents regression.

What's required before starting the test-driven development process?

You need a testing framework for your language and a clear understanding of the feature or bug behavior you're implementing. TDD requires no special setup—just the discipline to write failing tests before production code.