Chuyển đến nội dung
Skillpedia
Kiểm thử81k · #1700

tdd-repair

Skill này làm gì

Skill này lấy một test đang lỗi và thử sửa mã được test, trong một giới hạn ngân sách, cho đến khi test vượt qua. Skill dành cho lập trình viên có một test lỗi rõ ràng và muốn một bản sửa mang tính chiến thuật.

Khi nào nên dùng

  • ✓Khi một test tích hợp liên tục (CI) bị lỗi sau một commit gần đây.
  • ✓Khi bạn đã viết một test lỗi và muốn sửa mã cho khớp với nó.
  • ✓Khi một test từng chạy tốt bị hỏng và bạn muốn xem bản sửa có đơn giản không.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-testgen/skills/tdd-repair/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Test đăng nhập này bị lỗi sau commit cuối của tôi. Hãy thử sửa mã để test vượt qua mà không thay đổi chính test.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill khởi động một phiên Claude chạy headless có giới hạn, với ít công cụ và mức chi tiêu tối đa. Skill chạy test làm phép kiểm tra, nên kết quả được đánh giá bằng việc test có vượt qua hay không, chứ không bằng ý kiến.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Câu hỏi thường gặp

Nó có thể sửa test không?

Skill được thiết lập để làm test vượt qua mà không sửa đổi nó, và kết quả test là phép kiểm tra.

Có an toàn khi chạy trên mọi mã không?

Không. Nguồn khuyên chỉ chạy trên mã mà bạn có thể khôi phục, trên cây git sạch, vì công cụ shell được phép vẫn có thể thay đổi file.

Nếu không có test lỗi thì sao?

Nguồn khuyên viết một test lỗi trước, vì chế độ không có test chưa được hỗ trợ.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
81k
Vị trí xếp hạng
#1700
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự