Langsung ke konten
Skillpedia
Testing81k Β· #1700

tdd-repair

Fungsinya

Skill ini mengambil tes yang gagal dan melakukan upaya perbaikan kode yang diuji secara terbatas dengan anggaran tertentu sampai tes lolos. Skill ini cocok untuk developer yang memiliki tes gagal yang jelas dan menginginkan perbaikan taktis.

Kapan dipakai

  • βœ“Saat tes integrasi berkelanjutan gagal setelah commit terbaru.
  • βœ“Saat Anda telah menulis tes yang gagal dan ingin kode diperbaiki agar sesuai dengannya.
  • βœ“Saat tes yang sebelumnya lolos menjadi rusak dan Anda ingin melihat apakah perbaikannya sederhana.

Link skill

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-testgen/skills/tdd-repair/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-testgen/skills/tdd-repair/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œTes login ini gagal setelah commit terakhir saya. Coba perbaiki kodenya agar tes lolos tanpa mengubah tesnya.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill memulai sesi Claude headless yang dibatasi dengan alat terbatas dan batas pengeluaran. Skill menjalankan tes sebagai pemeriksaan, sehingga hasilnya dinilai dari apakah tes lolos, bukan dari opini.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Surfaces the Test-Driven Repair loop as a ruflo skill. Use when you have a failing test and want the source-under-test fixed automatically, with the test's pass/fail as the verification gate (no LLM-as-judge).

When to use

  • Failing CI test from a recent commit β€” point this at the test file, get a verified fix (or a clear "couldn't repair within budget" receipt).
  • Local TDD workflow β€” write the failing test first (tdd-workflow skill), then run tdd-repair to drive the green.
  • Regression triage β€” a previously-green test went red; before opening an issue, spend ~$1 to see if the fix is trivial.

When NOT to use

  • No failing test exists. Conformant mode (--no-test-oracle) is scoped for a follow-up ADR β€” needs MCTS over repro generation. For now, write a failing test first.
  • Architectural changes. This skill is for tactical "make red green" fixes. Cross-module refactors that incidentally break tests should be done by a human or a swarm.
  • Untrusted code. The headless claude -p runs with --allowedTools Read,Edit,Bash β€” no MCP, no network, no arbitrary file writes β€” but Bash can still read and write the filesystem and reach the network, so allowing it is not a sandbox. Don't point this at code you wouldn't git checkout . after, and run it on a clean git tree.

Algorithm

Implementation: scripts/tdd-repair/tdd-repair.mjs.

  1. Pre-flight verify β€” run the test command. If it already passes, exit 2 (test-already-passes). Repairing a green test is either a no-op or a --test-command typo.
  2. Spawn claude -p with a focused prompt:
    • Failing test file path (read-only intent)
    • Test command (run only)
    • Hard constraint: do NOT modify the test
    • Hard constraint: do NOT add new dependencies
  3. --allowedTools Read,Edit,Bash restricts capability. --max-budget-usd caps cost per attempt. --permission-mode acceptEdits auto-accepts file edits within the allowed set.
  4. Re-run the test to verify. The test's exit code IS the fitness function β€” no separate sandbox / LLM-as-judge.
  5. If green: emit success: true + per-attempt usage. If red after --max-attempts: emit success: false + receipts. Either way, the workspace is left as claude -p modified it (caller can git diff to review).

Output shape

{
  "success": true,
  "data": {
    "repaired": true,
    "attemptsTaken": 1,
    "mode": "test-driven",
    "before": { "passed": false, "exitCode": 1 },
    "after":  { "passed": true,  "exitCode": 0, "durationMs": 4321 },
    "attempts": [
      { "attempt": 1, "claude": { "ok": true, "durationMs": 38421, "usage": { "cost_usd": 0.0234 } }, "verify": { "passed": true } }
    ],
    "totalCostUsd": 0.0234,
    "budgetUsd": 5.0,
    "budgetExhausted": false,
    "shape": { "repo": "...", "test": "...", "testCommand": "...", "maxAttempts": 1, "model": "haiku" }
  }
}

Exit codes

Code Meaning
0 Test green after repair (success)
1 Test still red after --max-attempts
2 Config error (test file missing, test already passes, --no-test-oracle unsupported, etc.)
3 Claude CLI exited non-zero (infrastructure failure)
99 Reserved for safety tripwire (per ADR-153)

Safety posture

Layer Mechanism
Cost cap --max-budget-usd default $5, divided across --max-attempts. Hard ceiling β€” claude exits when reached.
Capability cap --allowedTools Read,Edit,Bash β€” no MCP tools. Bash can still write files and use the network, so this narrows the tool set, it is not a sandbox.
Scope cap The prompt forbids adding dependencies. The test file is enforced, not just requested: if an attempt changes it, the original bytes are restored and the attempt is scored failed (reason: test-file-modified).
Confirmation gate --confirm REQUIRED β€” without it, returns dry-run plan (mirrors harness-evolve / harness-mint convention).
Hard timeout 15 min total wall-clock; per-attempt budget of timeoutMs / maxAttempts.
Pre-flight Refuses to run if the test already passes (catches --test-command typos).

Inspiration

Modeled on the Test-Driven Repair mode from agent-harness-generator/packages/darwin-mode ADR-175. Key design difference: instead of wrapping metaharness-darwin evolve (population-based search), we drive a

Pertanyaan umum

Bisakah ia mengedit tes?

Skill diatur untuk membuat tes lolos tanpa mengubahnya, dan hasil tes menjadi pemeriksaannya.

Apakah aman dijalankan pada kode apa pun?

Tidak. Sumber menyatakan jalankan hanya pada kode yang bisa Anda pulihkan, di pohon git yang bersih, karena alat shell yang diizinkan masih dapat mengubah file.

Bagaimana jika tidak ada tes yang gagal?

Sumber menyarankan menulis tes yang gagal terlebih dahulu, karena mode tanpa tes belum didukung.

Detail

Deskripsi asli dari pembuat

Test-Driven Repair: given a failing test, spawn a bounded headless `claude -p` (Read/Edit/Bash only, --max-budget-usd capped) that makes the test pass without modifying it. Use when a failing test should drive the fix to the code under test.

repo: ruvnet/ruflo

Popularitas

Bintang GitHub
81k
Peringkat
#1700
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa