test-driven-development

Guide test-first development with a RED-GREEN-REFACTOR cycle and verification runs.

1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/eddielueng/hermes-agent-zh --skill test-driven-development-eddielueng
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/eddielueng/hermes-agent-zh/tree/main/skills/software-development/test-driven-development
Command: npx skills add https://github.com/eddielueng/hermes-agent-zh --skill test-driven-development-eddielueng

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test-driven development prevents shipping broken or unverified code by forcing you to define expected behavior in a failing test before writing implementation, reducing regressions and wasted rework.

Core Features & Use Cases

  • RED-GREEN-REFACTOR discipline: Write a failing test first, implement the smallest change to make it pass, then refactor without adding new behavior.
  • Mandatory verification loop: Explicitly run the specific test to confirm failure in RED and success in GREEN, then run the full suite to ensure no regressions.
  • Behavior-focused testing: Prefer real behavior (not fragile implementation details), cover edge cases, and avoid rationalizations like “I’ll test after.”

Use Cases:

  • New features, bug fixes, and refactors where you want reliable correctness and repeatable validation.
  • Subagent development where you need the goal to enforce test-first implementation.
  • Systematic debugging where a bug fix must be proven by a new failing test that reproduces the issue.

Quick Start

Tell the agent: “Implement this change using strict TDD: write the failing test first, verify it fails, write the minimal code to pass, verify it passes, then run pytest tests/ -q.”

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I use test-driven development to prevent regressions in pytest?

Test-driven development prevents regressions by enforcing a RED-GREEN-REFACTOR workflow where you write a failing pytest test first, implement minimal code to pass it, then refactor safely without adding untested behavior. This cycle ensures reliable correctness and repeatable validation for new features and bug fixes.

What is the RED-GREEN-REFACTOR cycle in software testing?

The RED-GREEN-REFACTOR cycle is a test-first workflow where you write a failing test (RED), implement the smallest code change to make it pass (GREEN), and then refactor the implementation without introducing new behavior. It forces explicit verification runs to confirm both failing and passing states before and after code changes.

How to apply strict TDD for systematic debugging and bug fixes?

To apply strict TDD for systematic debugging, you write a new failing test that reproduces the specific bug issue first. Once you verify the test fails, you implement the minimal fix to make it pass, verify success, and run the full test suite to ensure no other regressions were introduced during the fix.

Do I need to run the full test suite every time with test-driven development?

Yes, test-driven development requires a mandatory verification loop where you run the specific test to confirm failure and success, followed by running the full test suite to ensure no regressions. This explicit verification step is required after every minimal code implementation and before any refactoring.

When should I not use test-first development for refactoring?

You should avoid test-first development when refactoring if it involves adding new behavior, as strict TDD dictates refactoring only happens after GREEN without introducing untested behavior. If your refactor introduces new functionality, you must start a new RED phase with a failing test for that specific behavior first.

What's the best way to write tests for real behavior instead of implementation details?

The best way to write behavior-focused tests in TDD is to define expected real behavior in a minimal failing test, avoiding fragile implementation details and edge case rationalizations like testing after implementation. You must write the test first and verify it fails before writing any code to pass it.