implement-patch
它能做什么
指导对本地代码库中一个已确认缺陷的修复,从被破坏的规则到测试,再到一次提交。适用于已确定缺陷真实存在的开发者和审查人员。
适用场景
- ✓本地项目中已确认的缺陷需要正确修复的时候。
- ✓开发者需要找出其他违反同一规则之处的时候。
- ✓团队希望为已确认缺陷提交一次包含回归测试的提交的时候。
技能链接
https://github.com/trailofbits/skills/blob/main/plugins/patching-bugs/skills/implement-patch/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这个缺陷已经确认。请修复根本的规则,添加回归测试,并提交一次。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能先检查已保存的发现,然后找出被破坏的规则,并找到同一问题的每一处实例。它会编写一个在修复前会失败的测试,做出最小且便于审查的改动,然后重新运行测试套件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
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 requiresfinding.repair_scopewith 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.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.
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.
Record every variant as
fixedornot_fixedwith a reason. Produce exactly one local commit. Never push or open a PR. From the baseline, writefix.patchfor production changes andtests.patchfor test changes inpatch/attempt-N/.Write
patch.jsonwith the two commit SHAs, changed-file and line counts, variants, suite results, and your agent identity. If the attempt produced no commit, recordpatch_commit: nulland return it as failed. Manifest the entire attempt directory, including both patch files and the record, usinguv run --no-project <script> manifest <patch-attempt-dir>. Check it with the record validator.
{
"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. |
常见问题
它能修复我只是怀疑的缺陷吗?
不能。它只适用于已经被独立确认的缺陷。
它会比较修复前后的测试结果吗?
会。它会记录修复前后的结果,以发现任何新的失败。
它会编写提交信息吗?
会。它会为修复做出一次本地提交。
详情
作者的原始描述
Use when a confirmed local bug needs an invariant-level fix, variant search, tests, and one local commit.
repo: trailofbits/skills
热度
- GitHub 星标
- 8.0k
- 排名
- #12688
- 许可证
- CC-BY-SA-4.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
audit-context-building
8.0k帮你的智能体在安全审查之前熟悉一个陌生的代码库,梳理每个函数的假设、保证和依赖关系。
algorand-vulnerability-scanner
8.0k帮你的智能体扫描 TEAL 或 PyTeal 编写的 Algorand 智能合约,检查 11 类常见安全问题,如重新密钥攻击和未校验费用。
audit-prep-assistant
8.0k帮你的智能体为外部安全审查做好代码准备,包括静态分析、测试覆盖、死代码清理和清晰的文档。
cairo-vulnerability-scanner
8.0k帮你的智能体扫描 StarkNet 上的 Cairo 智能合约,检查 6 类严重问题,包括算术溢出、有风险的跨层消息和签名重放。