test-driven-development

Enforce test-first development with failing tests before production code.

Updated Oct 22, 2025
One-click install
npx skills add https://github.com/franroa/chezmoi --skill test-driven-development-franroa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/franroa/chezmoi/tree/main/dot_opencode/superpowers/skills/test-driven-development
Command: npx skills add https://github.com/franroa/chezmoi --skill test-driven-development-franroa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures your code is robust and reliable by forcing you to write tests before implementation. It prevents common pitfalls like writing untestable code, missing edge cases, or creating tests that don't actually verify behavior.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Guides you through the core TDD loop: write a failing test (Red), write minimal code to pass (Green), then clean up (Refactor).
  • Mandatory Failure Verification: Emphasizes that you must see a test fail before writing code, proving the test actually works.
  • Anti-Rationalization: Explicitly counters common excuses for skipping TDD, ensuring consistent application of the methodology.
  • Use Case: When implementing any new feature or fixing a bug, use this Skill to guarantee a solid test suite. For example, before writing a new user authentication function, write a test that expects it to fail, then build the function to make that test pass.

Quick Start

Announce skill usage

I'm using the test-driven-development skill to implement this feature.

The skill will then guide you through the Red-Green-Refactor cycle.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I write tests before writing code?

Test-driven development requires writing a failing test first, then implementing minimal code to pass it. Start by defining what your feature should do in a test, verify it fails, write only the code needed to make it pass, then refactor. This Red-Green-Refactor cycle ensures your tests actually validate behavior and your implementation stays focused.

Why should I see a test fail before writing production code?

A failing test proves your test actually works and will catch real bugs. If a test passes without your code, it's not testing anything. Test-driven development mandates seeing the failure first to guarantee the test is meaningful and will protect against regressions.

What's the best way to prevent untestable code and missed edge cases?

Write tests first to drive your design. When you test before implementation, you naturally write code that's testable and consider edge cases upfront. This approach eliminates common pitfalls like creating functions that can't be easily tested or missing boundary conditions that tests would have caught.

How do I apply test-driven development to bug fixes?

For each bug, write a failing test that reproduces the issue, verify it fails, then implement the minimal fix to pass. This creates a regression test that ensures the bug won't reappear and proves your fix actually solves the problem.

Can I use test-driven development across different project types?

Yes. Test-driven development applies to new features, bug fixes, and refactoring across all project types. The Red-Green-Refactor workflow and the rule of no production code without a failing test first remain consistent regardless of your tech stack or domain.

What are common excuses for skipping test-driven development?

Test-driven development explicitly counters rationalization like "tests slow me down" or "I'll test later." The methodology enforces consistent application by making the test-first rule non-negotiable, ensuring your test suite stays comprehensive and bugs stay caught early.