test-driven-development

Write failing tests before implementing minimal production code.

4|1|Updated Jun 7, 2025
One-click install
npx skills add https://github.com/alexanderop/MarkVim --skill test-driven-development-alexanderop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/alexanderop/MarkVim/tree/main/.claude/skills/tdd
Command: npx skills add https://github.com/alexanderop/MarkVim --skill test-driven-development-alexanderop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enforces the Test-Driven Development (TDD) methodology, ensuring that every piece of production code is backed by a failing test first. It eliminates the risk of writing untestable code or tests that don't actually verify behavior, leading to higher quality, more maintainable software.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Guides you through the mandatory steps of writing a failing test, implementing minimal code to pass it, and then refactoring.
  • Failing Test Verification: Emphasizes the critical step of watching tests fail correctly, proving they genuinely test the intended behavior.
  • Minimal Implementation: Promotes writing only the necessary code to pass the current test, preventing over-engineering and YAGNI violations.
  • Bug Fix Integration: Instructs on how to integrate TDD into bug-fixing workflows by first writing a failing test that reproduces the bug.
  • Use Case: When starting a new feature, use this skill to guide you through writing the first failing test, then the minimal code to make it pass, ensuring a solid foundation and preventing future regressions.

Quick Start

I need to implement a new user authentication module. Use the test-driven-development skill to guide me through the process, starting with the first failing test.

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 starts by writing a failing test that describes the desired behavior before any production code exists. Write the test, watch it fail to confirm it's testing the right thing, then implement minimal code to pass it. This ensures your code is testable and behavior is verified from the start.

What is the red-green-refactor cycle in TDD?

Red-green-refactor is TDD's core workflow: write a failing test (red), implement minimal code to pass it (green), then improve the code without changing behavior (refactor). This cycle prevents over-engineering, keeps code focused, and maintains test coverage throughout development.

How do I use TDD to fix bugs?

Start by writing a failing test that reproduces the bug's exact behavior. Watch it fail to confirm you've captured the issue, then implement the fix to make the test pass. This prevents regression and documents the bug's root cause in executable form.

Can I apply TDD to refactoring existing code?

Yes. TDD works for refactoring by ensuring tests already cover the code you're changing. Write tests for current behavior first if missing, then refactor with confidence that tests catch any introduced bugs. This makes refactoring safer and more maintainable.

Why is watching tests fail an important step in TDD?

Watching tests fail proves they're actually testing your code's behavior, not passing by accident. A test that never fails means it may not validate anything meaningful. This verification step prevents false confidence and ensures your test suite genuinely guards against regressions.

What's the difference between TDD and writing tests after code?

TDD writes tests first, ensuring code is designed to be testable and behavior is specified upfront. Writing tests after code often misses edge cases and may test implementation details rather than behavior. TDD's test-first approach produces cleaner, more maintainable code and better specifications.