TDD Methodology

Enforce red-green-refactor cycles with failing tests before production code.

2|1|Updated Dec 17, 2025
One-click install
npx skills add https://github.com/hculap/better-code --skill tdd-methodology
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TDD Methodology
Source: https://github.com/hculap/better-code/tree/main/plugins/tdd-dev/skills/tdd-methodology
Command: npx skills add https://github.com/hculap/better-code --skill tdd-methodology

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Transform coding behavior into strict Test-Driven Development practice. Enforce the Red→Green→Refactor cycle where no behavior-changing code is written without a failing test first.

Core Features & Use Cases

  • Iron Rules: No production code without a failing test.
  • Phases: RED (failing test), GREEN (passing), REFACTOR (cleanup).
  • Iteration Rhythm: Small increments and rapid cycles.

Quick Start

Enable TDD workflow, write a failing test first, run tests, implement minimal code to pass, and refactor while green.

Frequently Asked Questions about TDD Methodology

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

FAQPage Schema
How do I implement the red-green-refactor cycle in my development workflow?

The red-green-refactor cycle is a TDD pattern where you write a failing test first (red), implement minimal code to pass it (green), then clean up without changing behavior (refactor). This enforces test coverage before any production code exists, reducing bugs and improving design through iterative increments.

What's the best way to enforce test-driven development in my coding practice?

Enforce TDD by making failing tests a prerequisite: write tests first, watch them fail, implement only enough code to pass, then refactor safely. This discipline prevents untested code, ensures specifications are clear upfront, and creates a natural rhythm of small, verifiable increments.

Can I use TDD safely for refactoring existing code?

Yes. TDD supports safe refactoring by requiring passing tests before and after changes. Tests act as a safety net—refactor while green (all tests passing), verify tests still pass, and repeat. This prevents accidental behavior changes and makes refactoring low-risk.

When should I use test-driven development instead of writing tests after code?

Use TDD when you need high confidence in correctness, clear specifications, or maintainable designs. Writing tests first surfaces design gaps early, prevents over-engineering, and ensures every line serves a tested requirement. It's especially valuable for complex features, shared libraries, and safety-critical code.

How do I know when a TDD cycle is complete?

A TDD cycle completes when: the failing test passes (green), code is minimal and focused, and refactoring improves clarity without breaking tests. Move to the next cycle by writing a new failing test. Completion marks readiness to commit and move forward.