tdd-repair

Repairs source code automatically until a failing test passes using a bounded headless Claude process.

70.1k|8.4k|Updated Jun 2, 2025
One-click install
npx skills add https://github.com/ruvnet/claude-flow --skill tdd-repair
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-repair
Source: https://github.com/ruvnet/claude-flow/tree/main/plugins/ruflo-testgen/skills/tdd-repair
Command: npx skills add https://github.com/ruvnet/claude-flow --skill tdd-repair

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

When a test fails in CI or during local TDD work, someone must manually diagnose and fix the source code. This Skill automates that loop: it spawns a bounded headless claude -p process that edits the source until the failing test passes, without ever modifying the test itself.

Core Features & Use Cases

  • Test-Driven Repair Loop: Runs the failing test, spawns a constrained Claude process (Read/Edit/Bash only), then re-runs the test as the verification gate — no LLM-as-judge needed.
  • Bounded Cost and Capability: Caps spend with --max-budget-usd, restricts tools with --allowedTools Read,Edit,Bash, and requires --confirm before making any changes (dry-run plan otherwise).
  • Structured Receipts: Emits JSON output with per-attempt usage, cost totals, before/after test status, and distinct exit codes for success, failure, config errors, and infrastructure issues.
  • Use Case: A previously-green regression test went red after a commit. Point the Skill at the test file with a $5 budget and Haiku model; get back either a verified fix to review via git diff or a clear "couldn't repair within budget" receipt.

Quick Start

Run the tdd-repair script with --repo, --test, and --test-command pointing at your failing test, adding --confirm to actually apply the repair.

Frequently Asked Questions about tdd-repair

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

FAQPage Schema
How do I automatically fix a failing test with Claude?

Run the tdd-repair script with --repo, --test, and --test-command arguments pointing at your failing test, plus --confirm to apply changes. It spawns a headless claude -p process that edits the source code until the test passes, without modifying the test itself.

How do I limit the cost of automated test repair?

Use the --max-budget-usd flag (default $5) to cap total spend, divided across --max-attempts. You can also choose a cheaper model tier with --model haiku, which typically costs $0.02–$0.20 per attempt for tactical fixes.

Can tdd-repair modify my test files or add dependencies?

No. The prompt hard-constrains the Claude process from modifying the test file or adding new dependencies. It also runs with --allowedTools Read,Edit,Bash, so there is no MCP, network access, or arbitrary file writes.

What happens if the test already passes before repair runs?

The script exits with code 2 (test-already-passes) during pre-flight verification. This catches typos in --test-command and prevents wasting budget repairing a test that is already green.

When should I not use automated test-driven repair?

Avoid it when no failing test exists, when the fix requires architectural or cross-module refactoring, or when working with untrusted code. It is designed for tactical red-to-green fixes, not large-scale redesigns.