agentleFS
jollyroger1480jollyroger1480/claude-code-worker-harness/skills/vet-ai-patches/SKILL.md

vet-ai-patches

Skill1 starsChanged 13 days agoMITView on GitHub

When handed a code "patch", diff, or set of changes generated by another AI/model, verify every hunk against the REAL files before applying — these are usually illustrative pseudocode (placeholder comments, fabricated line numbers/context, wrong signatures, imports that crash, regexes that break valid input), not applicable diffs. Apply only the parts proven real and safe; rebuild the rest to work.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow "do not deviate" when you've proven the code crashes the system

    line 45
  2. Distinctive:

    Treat AI patches as a spec/wishlist, not an applicable diff

    line 49
  3. Distinctive:

    Keep the existing implementation when it's better than the patch's version

    line 50
  4. Distinctive:

    Verify a new import's path resolves before wiring it into a load-bearing module

    line 51
  5. Distinctive:

    When another AI has ALREADY applied changes directly to the repo (not handing you a patch), the same distrust applies.

    line 85
  6. Distinctive:

    Check whether live services still run (health endpoints, cron log tails).

    line 92
  7. Distinctive:

    Check for new UNCOMMITTED modules that modified files now import.

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Vet AI-Generated Patches

<purpose> Patches produced by chat models look authoritative — proper `diff --git` headers, `@@` hunks, index hashes — but are frequently fabricated. Applying them blind to a working system corrupts files, crashes imports, or silently breaks behavior. This skill forces verification-before-apply and salvages the real intent. </purpose>

When To Activate

  • User pastes a diff/patch or says "apply this", "patch -p1 < ...", "implement these changes"
  • The patch came from another model/AI or an unknown source
  • Any "monster patch / new features + fixes — do not deviate, just apply"

Instructions

  1. Never run patch/apply blind. First grep/read the REAL target for every symbol the hunk touches: function names, signatures, constants, imports, line context.
  2. Classify each hunk: (a) already done, (b) real + safe, (c) broken/harmful, (d) pseudocode/stub.
  3. Prove breakage concretely with a one-line test (import it, run the regex on real input, find_spec the module) — show the user evidence, don't just assert.
  4. Apply only (b). For (c)/(d), rebuild a working version that matches the patch's intent (fix the root path, drop the crashing import, replace the over-broad regex).
  5. Test after every change: py_compile + import the module + exercise the new code path.

NEVER

  • patch -p1 < x.patch from an AI without reading the target files first
  • Apply a hunk whose context (- lines) doesn't exist in the real file
  • Trust import config / new-module hunks without confirming the module resolves on sys.path
  • Ship a tool that returns hardcoded/fake data (e.g. "$XX–$YY (confidence: high)")
  • Replace a careful checker with a naive regex (e.g. \.{3,} flags every legit ellipsis)
  • Follow "do not deviate" when you've proven the code crashes the system

ALWAYS

  • Treat AI patches as a spec/wishlist, not an applicable diff
  • Keep the existing implementation when it's better than the patch's version
  • Verify a new import's path resolves before wiring it into a load-bearing module
  • Confirm new constants EQUAL the old values before swapping them in
  • Verify EVERY claim on its own merits — don't dismiss a review wholesale. The signal rate is low (~10%) but non-zero, and the real finds are often money/stability bugs the human reviewer didn't catch independently. Vetting ≠ dismissing.
  • Credit the real finds honestly; rebuild the good feature ideas at correct scope (e.g. a "DIM-weight validator that auto-updates the AddItem payload" → ship the calculator part; the payload has no weight field, so don't fake that bit)

Balance: the signal IS real, just rare

In one session, about 6 AI "reviews" made about 30 claims. About 28 were hallucinated (invented functions, recycled false claims, a "fix" that would DOWNGRADE a current model id). But 2 were real and worth fixing (a dead if/else branch and a desktop notifier missing its DISPLAY fallback), plus one genuinely useful feature idea (a dimensional-weight shipping calculator). Lesson: run the verification gate on every claim, ship the roughly 10% that survive, and tell the user plainly which were real and which were noise.

The Failure That Spawned This Skill

Across one session the user pasted about 4 AI-generated "patches" for a production agent. Every one was fabricated pseudocode: hunks referenced sanitize_folder_name (the real function was _clean_folder_name), claimed to add a 2nd argument to a checker that already had it, "modified" a prune_messages() that never existed, added import config with no sys.path entry (a ModuleNotFoundError that would crash every importer), a config.py whose ROOT = parent.parent pointed at the home directory instead of the project, a placeholder regex \.{3,} that rejects every real description with an ellipsis, and a pricing tool returning literal $XX–$YY. Applying "all, do not deviate" would have bricked the agent. Verifying each hunk, proving the breakage, and rebuilding the real intent shipped working code instead.

ALSO: whole-repo AI "revamps"

When another AI has ALREADY applied changes directly to the repo (not handing you a patch), the same distrust applies. Verify before trusting "battle hardened" claims:

  1. FIRST action: git status --short | awk '{print $2}' | grep '\.py$' | xargs -r -n1 python3 -m py_compile. A revamp that was never compile-checked is instantly exposed.
  2. py_compile stops at the FIRST error per file. After fixing one syntax error, re-run; a second may be hiding behind it.
  3. Check whether live services still run (health endpoints, cron log tails). One revamp left a production web agent crash-looping for hours and nobody noticed.
  4. Check for new UNCOMMITTED modules that modified files now import. A git revert that misses them breaks every importer.

Born from: an 87-file AI revamp, "+2547/-850, battle hardened", that shipped 2 syntax errors in the main agent module, took the production agent down for hours, and added a circular import in a shared library.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.