About implement-patch
A patch-implementation skill for fixing a claim after independent validation. It guides a regression test, an invariant-level change, test comparison, and a recorded local commit without pushing or opening a PR.
Key features
- 01Validate the repair record before editing
- 02Add a baseline-failing regression test
- 03Fix the invariant within the stated scope
- 04Run and compare project test suites
- 05Record variants and create a local commit
Use cases
- 01Implement a validated defect fix
- 02Check that a regression test fails before repair
- 03Document fixed and unfixed variants
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ trailofbits/ skills --skill implement-patchAfter installing, type/implement-patchin Claude Code to confirm it loaded.
Details
From the project READMEImplement 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. |