test-driven-development

Enforce the Red-Green-Refactor cycle with failing tests before production code.

1|Updated Nov 3, 2025
One-click install
npx skills add https://github.com/apettey/BattleScope --skill test-driven-development-apettey
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/apettey/BattleScope/tree/main/.claude/skills/test-driven-development
Command: npx skills add https://github.com/apettey/BattleScope --skill test-driven-development-apettey

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the guesswork and fragility in software development by enforcing Test-Driven Development (TDD). It ensures every piece of code is verified by a failing test before implementation, preventing bugs, simplifying refactoring, and building a robust, trustworthy codebase. No more "it works on my machine" or untested edge cases.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Guides you through the iterative process of writing a failing test (Red), writing minimal code to pass it (Green), and then cleaning up your code (Refactor).
  • Mandatory Failure Verification: Crucially, it requires you to witness a test fail for the expected reason before writing any implementation, proving the test's validity and preventing false positives.
  • Bug Prevention & Regression Safety: By building a comprehensive suite of automated tests from the ground up, this Skill helps catch bugs early in the development cycle and ensures that future changes don't inadvertently break existing functionality.

Quick Start

To implement a new feature using TDD, first, describe the desired behavior in a new test file. For example: test('should correctly calculate total amount', () => { expect(calculateTotal(items)).toBe(expectedTotal); }); Then, run this test and ensure it fails as expected before writing any implementation code.

Frequently Asked Questions about test-driven-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is test-driven development and why does it prevent bugs?

Test-driven development writes failing tests before production code, guaranteeing every line is verified. This approach catches bugs early, prevents untested edge cases, and builds a trustworthy codebase from the ground up by enforcing the Red-Green-Refactor cycle.

How do I start using the Red-Green-Refactor cycle?

Write a failing test first that describes desired behavior, run it to confirm it fails for the expected reason, write minimal code to pass it, then refactor. This cycle ensures test validity and prevents false positives while building correct code incrementally.

Can I apply TDD to bug fixes and refactoring, or only new features?

TDD applies across the entire project lifecycle—new features, bug fixes, refactoring, and behavior changes. The Iron Law requires a failing test before any production code change, ensuring regression safety and that modifications don't break existing functionality.

Why is witnessing a test fail before implementation important?

Mandatory failure verification proves your test is valid and catches the expected issue. Without confirming failure first, you risk false positives where tests pass despite being broken, defeating the purpose of test coverage and code correctness guarantees.

How does TDD improve code quality during refactoring?

A comprehensive test suite built through TDD provides a safety net during refactoring. You can confidently clean up code knowing that any regression will be caught immediately, eliminating the fragility of untested changes.