test-driven-development

Enforce the RED-GREEN-REFACTOR cycle with failing tests before production code.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/kivilaid/plugin-marketplace --skill test-driven-development-kivilaid
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/kivilaid/plugin-marketplace/tree/main/plugins/test-driven-development
Command: npx skills add https://github.com/kivilaid/plugin-marketplace --skill test-driven-development-kivilaid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enforces the Test-Driven Development (TDD) methodology, preventing common pitfalls like writing tests after code, which often leads to incomplete or ineffective test coverage. It ensures every piece of production code is backed by a failing-then-passing test, drastically reducing bugs and improving code quality.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Guides you through writing a failing test, writing minimal code to pass it, and then refactoring.
  • Iron Law Enforcement: Strictly prevents writing production code without a preceding failing test, ensuring true TDD adherence.
  • Bug Prevention & Regression Safety: Catches bugs early and prevents regressions by ensuring tests verify actual behavior.
  • Use Case: When implementing a new feature, use this Skill to systematically build out the functionality, ensuring each component is thoroughly tested and verified before integration, leading to more stable and maintainable code.

Quick Start

Start with a failing test for new behavior

test('retries failed operations 3 times', async () => { let attempts = 0; const operation = () => { attempts++; if (attempts < 3) throw new Error('fail'); return 'success'; }; const result = await retryOperation(operation); expect(result).toBe('success'); expect(attempts).toBe(3); });

Run tests, watch it fail, then write minimal code to 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 write tests before implementing code?▼

Test-driven development requires writing a failing test first, then implementing only the minimal code to pass it. Start by defining expected behavior in your test—what inputs produce what outputs—run it to confirm failure, then write production code until the test passes. This red-green-refactor cycle ensures every line is backed by a test.

What's the best way to catch bugs early in development?▼

Writing tests before code catches bugs at their source. TDD forces you to specify behavior upfront and verify it continuously, preventing regressions and incomplete edge-case handling. Each feature gains a safety net of tests that detect breakage before deployment.

Can I use test-driven development for bug fixes and refactoring?▼

Yes. TDD applies to bug fixes—write a test that reproduces the bug, watch it fail, then fix the code—and refactoring, where tests verify behavior stays unchanged while you improve structure. The same red-green-refactor cycle prevents introducing new bugs during maintenance.

Why should I write tests before production code?▼

Writing tests after code often misses edge cases and leaves gaps in coverage. TDD enforces the discipline that no production code exists without a preceding failing test, eliminating untested paths, improving design through test-first thinking, and reducing technical debt from day one.

Does test-driven development work for unit, integration, and regression testing?▼

TDD spans all three. Write unit tests for individual functions, integration tests for component interactions, and regression tests to prevent old bugs resurfacing. The red-green-refactor cycle applies equally across all test scopes and scenarios.