Skip to content
Skillpedia
Security8.0k · #12688

implement-patch

What it does

Guides a fix for one confirmed bug in a local codebase, from the broken rule through tests to one commit. It is for developers and reviewers who already know the bug is real.

When to use it

  • ✓When a confirmed bug in a local project needs a proper fix.
  • ✓When a developer needs to find other places that break the same rule.
  • ✓When a team wants one commit with a regression test for a confirmed bug.

Skill link

https://github.com/trailofbits/skills/blob/main/plugins/patching-bugs/skills/implement-patch/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/trailofbits/skills/blob/main/plugins/patching-bugs/skills/implement-patch/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“This bug is confirmed. Fix the underlying rule, add a regression test and make one commit.”

5 new skills a week. 1 minute to read.

How it works

The skill checks the saved finding first, then identifies the broken rule and finds every instance of the same problem. It writes a test that fails before the fix, makes the smallest reviewable change, and reruns the suite.

Technical content (original SKILL.md)

Original text by the author, straight from 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

  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.
FAQ

Can it fix a bug I only suspect?

No. It is for bugs that have already been independently confirmed.

Does it compare test results before and after?

Yes. It records results before and after the fix to catch any new failures.

Does it write the commit?

Yes. It makes one local commit for the fix.

Details

Original description by the author

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

repo: trailofbits/skills

Popularity

GitHub stars
8.0k
Ranking position
#12688
License
CC-BY-SA-4.0
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills