Chuyển đến nội dung
Skillpedia
Bảo mật8.0k · #12688

implement-patch

Skill này làm gì

Hướng dẫn sửa một lỗi đã được xác nhận trong codebase cục bộ, từ quy tắc bị vi phạm đến test và một commit. Dành cho lập trình viên và người review đã biết lỗi là có thật.

Khi nào nên dùng

  • ✓Khi một lỗi đã xác nhận trong dự án cục bộ cần được sửa đúng cách.
  • ✓Khi lập trình viên cần tìm các nơi khác vi phạm cùng quy tắc.
  • ✓Khi nhóm muốn một commit với test hồi quy cho một lỗi đã xác nhận.

Liên kết skill

https://github.com/trailofbits/skills/blob/main/plugins/patching-bugs/skills/implement-patch/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/trailofbits/skills/blob/main/plugins/patching-bugs/skills/implement-patch/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

“Lỗi này đã được xác nhận. Hãy sửa quy tắc bị vi phạm, thêm test hồi quy và tạo một commit.”

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

Cách hoạt động

Skill kiểm tra phát hiện đã lưu trước, rồi xác định quy tắc bị vi phạm và tìm mọi chỗ có cùng vấn đề. Nó viết một test thất bại trước khi sửa, thực hiện thay đổi nhỏ nhất dễ review, và chạy lại bộ test.

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.

Implement Patch

When to Use

Use after independent validation confirms one claim. Read the record contract. Before target commands, follow its project guidance.

When NOT to Use

Do not use for speculative bug hunting, proof of a completed patch, or a change that cannot be exercised by the local compiler or runtime.

Procedure

  1. Before editing, run uv run --no-project <script> check --before-repair <run-dir> with the record validator. If this check fails, stop and return its errors for an INCONCLUSIVE report. The gate requires finding.repair_scope with a usable case plan and a consistent attempt count. Use the declared scope as the repair brief. Identify the broken invariant and search within its boundary for every instance of the same violation. Read the threat model only to preserve intended behavior; it is not a gate.

  2. Run the project's existing suite and record its results. Write a regression test that fails on the baseline for the named bug and any fixed variant. Observe the failure. Fix the invariant within the repair brief with the smallest reviewable change.

  3. Run the regression test and full existing suite again. Compare before and after failures. Fix new failures or explain a pre-existing one from receipts.

  4. Record every variant as fixed or not_fixed with a reason. Produce exactly one local commit. Never push or open a PR. From the baseline, write fix.patch for production changes and tests.patch for test changes in patch/attempt-N/.

  5. Write patch.json with the two commit SHAs, changed-file and line counts, variants, suite results, and your agent identity. If the attempt produced no commit, record patch_commit: null and return it as failed. Manifest the entire attempt directory, including both patch files and the record, using uv run --no-project <script> manifest <patch-attempt-dir>. Check it with the record validator.

    Patch record schema:

{
  "schema_version": 1,
  "attempt": 1,
  "baseline_commit": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "patch_commit": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
  "files_changed": 2,
  "lines_added": 3,
  "lines_removed": 1,
  "variants": [],
  "suite_before": {"command": "pytest", "passed": 9, "failed": 1, "skipped": 0},
  "suite_after": {"command": "pytest", "passed": 10, "failed": 0, "skipped": 0},
  "agent": "patcher-1"
}

Rationalizations to Reject

Shortcut Required action
Only the reported line matters. Search for the same invariant violation.
Minimal means the fewest lines. Make the smallest reviewable invariant-level fix.
Tests pass after the patch. Show the regression test failed before it.
Câu hỏi thường gặp

Nó có sửa được lỗi tôi chỉ nghi ngờ không?

Không. Skill chỉ dành cho các lỗi đã được xác nhận độc lập.

Nó có so sánh kết quả test trước và sau không?

Có. Nó ghi lại kết quả trước và sau khi sửa để phát hiện mọi lỗi mới.

Nó có viết commit không?

Có. Nó tạo một commit cục bộ cho bản sửa.

Chi tiết

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

Use when a confirmed local bug needs an invariant-level fix, variant search, tests, and one local commit.

repo: trailofbits/skills

Độ phổ biến

Sao GitHub
8.0k
Vị trí xếp hạng
#12688
Giấy phép
CC-BY-SA-4.0
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ự