test-driven-development

Enforce a failing test before production code using the Red-Green-Refactor workflow.

Updated Jul 8, 2022
One-click install
npx skills add https://github.com/limaon/dotfiles --skill test-driven-development-limaon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/limaon/dotfiles/tree/main/.config/opencode/skills/test-driven-development
Command: npx skills add https://github.com/limaon/dotfiles --skill test-driven-development-limaon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams avoid producing untested production code by enforcing a tests-first workflow. It emphasizes writing a failing test before implementing any feature or bugfix, reducing regressions and clarifying expected behavior.

Core Features & Use Cases

  • Red-Green-Refactor workflow: write a failing test, implement the minimal production code to pass, then refactor without changing behavior.
  • Minimal, real tests: focus on testing real behavior rather than mocks, ensuring meaningful coverage.
  • Regression prevention and documentation: guides teams to capture intent through tests and maintain reliability during refactors.
  • Use case: when starting a new feature or fixing a bug, follow a strict TDD cycle to guarantee correctness.

Quick Start

Write a failing test for the new feature, implement the smallest amount of production code to pass, run the test suite, and refactor while keeping all tests green.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I enforce a test-first development workflow for new features?

The red-green-refactor workflow involves writing a failing test, implementing minimal production code to pass it, and refactoring without changing behavior. This cycle clarifies expected behavior and prevents regressions during software engineering tasks like bug fixes or refactors.

Can I apply test-driven development to refactoring existing code?

Test-driven development applies to refactoring across any tech stack by ensuring you maintain green tests while changing code structure. It captures intent through minimal, real tests to maintain reliability during refactors without altering existing behavior.

Do I need to use mocks when writing unit tests with this test-driven development approach?

This test-driven development approach focuses on testing real behavior rather than relying on mocks. It emphasizes minimal, real tests to ensure meaningful coverage and accurately document expected software behavior during development.

What is the best way to prevent regressions when fixing bugs?

The best way to prevent regressions is writing a failing test that reproduces the bug before implementing the fix. This test-first approach guarantees the bug is resolved and provides ongoing protection against future regressions across any tech stack.

When should I not use test-driven development for software engineering tasks?

Test-driven development is broadly applicable to new features, bug fixes, and refactors across any tech stack. It is uniquely focused on enforcing strict test-first cycles to guarantee correctness, rather than skipping tests for rapid prototyping.