test-driven-development

Enforce failing-test-first development with a RED-GREEN-REFACTOR TDD loop.

Updated Aug 15, 2025
One-click install
npx skills add https://github.com/pekral/pekral.cz --skill test-driven-development-pekral
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/pekral/pekral.cz/tree/main/.claude/skills/test-driven-development
Command: npx skills add https://github.com/pekral/pekral.cz --skill test-driven-development-pekral

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents unverified changes by enforcing failing-test-first development, so you know the new behavior is correct and stable before it reaches production.

Core Features & Use Cases

  • Failing-test-first TDD: Requires an initial RED test and ensures the test fails for the expected reason before adding production code.
  • Tight scope and safety: Guides minimal implementation, focused refactoring, and avoids unrelated scope creep during bug fixes, feature work, and behavior changes.
  • Pre-flight reproducible setup: Uses an issue/context preparation step to seed the database and capture a reproduction record that becomes the test’s arrange block.
  • Post-cycle validation: Calls for coverage verification, running fixers/checkers, and reviewing tests to keep quality high over time.
  • Use Case: Fixing a regression by reproducing it with a targeted test, implementing only the smallest code change to satisfy that test, then validating that existing behavior remains intact.

Quick Start

Use the test-driven-development skill to implement your next feature or bugfix by writing a minimal RED test, confirming it fails for the right reason, adding the smallest GREEN code change, then refactoring only after the cycle passes.

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 failing-test-first TDD workflow for bug fixes?

To enforce failing-test-first TDD for bug fixes, you write a minimal RED test that reproduces the regression, verify it fails for the expected reason, implement the smallest GREEN code change to satisfy it, then refactor and validate coverage.

What is the red-green-refactor cycle and how do I verify each step?

The red-green-refactor cycle is a mandatory TDD loop requiring you to write a failing RED test, verify it fails, write minimal GREEN code to pass it, verify it passes, then safely REFACTOR while repeating this sequence to ensure correct behavior.

How do I prevent scope creep when refactoring existing behavior?

To prevent scope creep when refactoring behavior, you guide minimal implementation by strictly following a TDD loop, making focused refactoring changes only after tests pass, and avoiding unrelated modifications during feature work or bug fixes.

How do I seed test context and arrange blocks for regression tests?

To seed test context for regression tests, you perform a pre-flight issue preparation step to reproduce the issue and capture a reproduction record, which then directly becomes the test's arrange block for validating the fix.

What's the best way to validate code coverage after a TDD cycle?

The best way to validate code coverage after a TDD cycle is to run post-cycle validation, which includes verifying coverage metrics, executing fixers and checkers, and reviewing tests to maintain high quality over time.

Can I use test-driven development for both new features and behavior changes?

Yes, you can use test-driven development for new features, behavior changes, and refactoring, applying the mandatory RED to REFACTOR loop to implement correct behavior with measurable safety before changes reach production.