test-driven-development

Enforces test-driven development by writing failing tests before implementation code.

Updated Jun 11, 2026
One-click install
npx skills add https://github.com/marcocpt/trae_skills --skill test-driven-development-marcocpt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/marcocpt/trae_skills/tree/main/test-driven-development
Command: npx skills add https://github.com/marcocpt/trae_skills --skill test-driven-development-marcocpt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests after implementation produces tests that pass immediately and prove nothing, leaving bugs undetected and code untrustworthy. This Skill enforces a strict red-green-refactor TDD workflow so every piece of production code is backed by a test that was seen to fail first. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Guides the full cycle of writing a failing test, verifying it fails for the right reason, writing minimal code to pass, and refactoring safely. - Anti-Rationalization Rules: Counters common excuses like "I'll add tests later" or "deleting code is wasteful" with strict delete-and-restart rules. - Testing Anti-Pattern Reference: Covers pitfalls such as testing mock behavior, adding test-only methods to production classes, and incomplete mocks. - 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 confirm 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 step by step?

Write one minimal failing test for a single behavior, run it to confirm it fails for the expected reason, then write the simplest code to make it pass. After all tests pass, refactor while keeping tests green, then repeat 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 behavior. Seeing a test fail first confirms it actually exercises the missing functionality and catches real bugs rather than mirroring the implementation.

What should I do if I already wrote code before tests?

Delete the implementation and start over with TDD. Keeping it as reference or adapting it while writing tests leads to biased after-the-fact tests that validate what you built rather than what was required.

When is it acceptable to skip test-driven development?

Only for throwaway prototypes, generated code, or configuration files, and only after confirming with your human partner. Everything else, including bug fixes and refactoring, should follow the TDD cycle without exceptions.

Why does testing mock behavior cause problems?

Asserting on mocked elements verifies the mock works, not the real component, giving false confidence. Test real behavior instead, mock only at the lowest necessary level, and mirror complete real API structures when mocks are unavoidable.