test-driven-development

Enforce Test-Driven Development with failing tests before implementation.

68|6|Updated Apr 16, 2020
One-click install
npx skills add https://github.com/zenobi-us/dotfiles --skill test-driven-development-zenobi-us
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/zenobi-us/dotfiles/tree/main/devtools/files/opencode/skills/test-driven-development
Command: npx skills add https://github.com/zenobi-us/dotfiles --skill test-driven-development-zenobi-us

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing code without tests often leads to bugs, regressions, and difficulty refactoring, slowing down development and increasing technical debt. This Skill ensures your code is verified from the start.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Systematically guides you through writing failing tests, minimal code to pass, and refactoring.
  • Behavior Verification: Ensures tests actually verify desired behavior by requiring them to fail first.
  • Bug Prevention: Catches bugs before they're committed and prevents regressions, building trust in your codebase.
  • Use Case: You're about to implement a new user authentication feature. Use this Skill to guide you through writing a failing test first, then the minimal code to pass it, ensuring your feature is robust and bug-free from the start.

Quick Start

Use the test-driven-development skill to implement a function that validates email addresses, starting with a failing test for an invalid email.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How does test-driven development prevent bugs before they reach production?

Test-driven development prevents bugs by requiring you to write failing tests first, then implement minimal code to pass them. This Red-Green-Refactor cycle ensures behavior is verified before production code exists, catching defects early and building confidence in your codebase.

What's the Red-Green-Refactor cycle and how do I use it?

Red-Green-Refactor is a three-step cycle: write a failing test (Red), implement minimal code to pass it (Green), then improve the code without breaking tests (Refactor). This systematic approach ensures each feature is tested and verified before moving forward.

Can I use test-driven development for refactoring existing code?

Yes. Test-driven development applies to refactoring by ensuring tests fail first to verify desired behavior, then refactoring with confidence that tests catch regressions. This prevents bugs during code improvements and builds trust in legacy codebases.

When should I write tests before implementing code rather than after?

Write tests first when implementing new features, bug fixes, or behavior changes. Test-first development guarantees correct behavior from the start, prevents regressions, and reduces technical debt by catching issues before they're committed.

How do I verify that my tests actually check the right behavior?

Require tests to fail first before implementing code. This verification step confirms tests detect incorrect behavior and aren't passing accidentally, ensuring your test suite genuinely validates the feature you're building.