test-driven-development

Write failing tests before production code using the Red-Green-Refactor cycle.

4|1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/NSObjects/specpowers --skill test-driven-development-nsobjects
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/NSObjects/specpowers/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/NSObjects/specpowers --skill test-driven-development-nsobjects

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill forces tests to exist before production code so each change has an observable failure that proves the right behavior is captured.

Core Features & Use Cases

  • Test-first discipline: Always write one minimal failing test per requirement and confirm it fails for the expected reason.
  • Red-Green-Refactor cycle: Run the test suite to witness failure, implement the slightest fix, then refactor while keeping tests green.
  • Use case: When adding a feature or fixing a bug, ask for the testing steps before touching code to avoid regressions and hidden assumptions.

Quick Start

Tell the agent to write the failing test for your requested change, watch it fail, and only then start editing the implementation.

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 how does the red-green-refactor cycle work?

Test-driven development (TDD) is a test-first discipline requiring a minimal failing test before any production code. The red-green-refactor cycle mandates watching the test suite fail, implementing the slightest fix to turn it green, then refactoring while keeping tests passing.

How do I write a failing test before implementing a new feature or bug fix?

To write a failing test for a new feature or bug fix, define the expected behavior first. You must run npm test to confirm it fails for the expected reason, then write the minimal production code needed to make it pass, avoiding regressions and hidden assumptions.

Can I use test-first development for refactoring existing code and behavior changes?

Yes, test-first development applies to refactoring and behavior changes. You write a failing test that exposes the unmet requirement or desired behavior, confirm the failure, implement the fix, and refactor while ensuring the test suite remains green throughout the process.

What's the best way to enforce test-first discipline in my developer workflow?

The best way to enforce test-first discipline is to mandate writing one minimal failing test per requirement before touching code. Ask for the testing steps upfront, watch npm test fail, implement the slightest fix, and keep implementation minimal until all tests pass.

Why do I need to watch the test suite fail before writing production code?

Watching the test suite fail proves the right behavior is captured and exposes unmet requirements. Running npm test to witness failure ensures each change has an observable failure, preventing false positives and confirming the test actually validates the new production code.