test-driven-development

Enforce writing failing tests before implementation during development.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many features and bug fixes are implemented without automated tests or with tests added afterwards, which hides defects, impedes refactoring, and reduces confidence in changes. This Skill enforces a strict test-first mindset so developers write failing tests, verify failures, implement minimal passing code, and keep behavior covered by tests.

Core Features & Use Cases

  • Red → Green → Refactor enforcement: Guides developers to write a failing test first, confirm the failure, implement minimal code to pass, and only then refactor.
  • Anti-pattern detection & checklist: Provides reminders and checks to avoid common mistakes like testing mocks instead of behavior or adding test-only production methods.
  • Use Case: Adopt during new feature development, bug fixes, or refactors to produce reliable, well-documented behavior through tests and prevent regressions.

Quick Start

Invoke the skill and instruct the agent to start the TDD cycle by writing a failing test, running tests to confirm failure, implementing the minimal code to pass, and then refactoring.

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 red-green-refactor workflow when writing tests?

To enforce red-green-refactor, write a failing test first, verify the failure reason, implement minimal code to pass, and refactor while keeping tests green. This test-driven development cycle prevents regressions and ensures behavior remains covered.

What is test-driven development and when should I apply it?

Test-driven development is a test-first workflow where you write failing tests before implementation. Apply it during new feature development, bug fixes, refactoring, and behavior changes to produce reliable, well-documented code and prevent hidden defects.

How do I start the TDD cycle for a new feature or bug fix?

Start the TDD cycle by writing a failing test, running tests to confirm the expected failure, implementing the minimal code required to pass, and then refactoring the code while ensuring tests remain green throughout the process.

What common testing anti-patterns should I avoid during test-driven development?

Avoid common test-driven development anti-patterns like testing mocks instead of behavior or adding test-only production methods. Use checklist checks to ensure tests drive implementation and validate actual behavior rather than implementation details.

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

Yes, apply test-driven development during refactoring to ensure behavior changes remain covered by tests. Verify tests fail for expected reasons before changes, require minimal implementation to pass, and keep tests green through the refactor.

Why do my tests fail when writing them before implementation in TDD?

In test-driven development, tests must fail initially because the implementation does not exist yet. Verify the failure is for the expected reason, then write minimal code to pass the test before refactoring.