test-driven-development

Enforces red-green-refactor TDD workflow requiring failing tests before writing production code.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/MaiconGambini/opencode-harness-guide --skill test-driven-development-maicongambini
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/MaiconGambini/opencode-harness-guide/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/MaiconGambini/opencode-harness-guide --skill test-driven-development-maicongambini

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It prevents untested production code by enforcing a strict test-first discipline, eliminating the false confidence of tests written after implementation that pass immediately and prove nothing. ## Core Features & Use Cases - Red-Green-Refactor Cycle: Guides writing a failing test, verifying it fails for the right reason, writing minimal code to pass, then refactoring while staying green. - Rationalization Detection: Lists common excuses for skipping TDD ("too simple to test", "I'll test after") with counterarguments and red flags that trigger a restart. - Testing Anti-Patterns Reference: Covers testing mock behavior, test-only methods in production classes, incomplete mocks, and mocking without understanding dependencies. - Use Case: When fixing a bug where empty emails are accepted, write a failing test asserting the rejection, watch it fail, implement the minimal validation, and verify all tests pass before refactoring. ## Quick Start Use the test-driven-development skill to implement this feature by writing a failing test first, then the minimal code to make it pass.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development on a new feature?

Write one minimal failing test describing the desired behavior, run it to confirm it fails for the right reason, then write the simplest code to make it pass. Refactor only while tests stay green, then repeat the cycle for the next behavior.

Why should tests be written before implementation code?

Tests written after code pass immediately, which proves nothing about whether they test the right thing. Watching a test fail first confirms it actually exercises the missing behavior and catches real bugs rather than mirroring the implementation.

What should I do if I already wrote code before the test?

Delete the code and start over with a failing test. Keeping it as reference or adapting it while writing tests biases the tests toward the implementation, which is testing-after in disguise.

When is it acceptable to skip TDD?

Only for throwaway prototypes, generated code, or configuration files, and only after asking your human partner. Rationalizations like "too simple to test" or "I'll test after" are red flags that mean you should restart with TDD.

Why does my test pass when I remove the mock?

You are likely testing mock behavior instead of real behavior, a common anti-pattern. Assert on real component behavior, mock only at the level of slow or external operations, and mirror complete API response structures in your mocks.