agentleFS
iansteitz1-engiansteitz1-eng/aria-skills/surgical-patch/SKILL.md

surgical-patch

Skill0 starsChanged 2 months agoApache-2.0View on GitHub

Drift-safe editor for a hot, shared, possibly-remote file (e.g. prod main.py that's AHEAD of your local checkout). Applies a data-driven list of exact-match edits with three guarantees — idempotent (sentinel no-op), exact (every anchor must match a precise count or it aborts writing nothing), and reversible (timestamped backup + verify-or-rollback). Works locally or over ssh. Use when Ian says "patch the live file", "surgically edit main.py", "apply this change to prod without clobbering", "the server file is ahead of mine", or before any edit to a shared file multiple lanes touch.

  • Reads credentials

14 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ponytail, ponytail-review and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    ponytail

    Forces the laziest solution that actually works, simplest, shortest, most minimal. Channels a senior dev who has seen everything: question whether the task needs to exist at all (YAGNI), reach for the standard library before custom code, native platform features before dependencies, one line before fifty. Supports intensity levels: lite, full (default), ultra. Use on ANY coding task: writing, adding, refactoring, fixing, reviewing, or designing code, and choosing libraries or dependencies. Also use whenever the user says "ponytail", "be lazy", "lazy mode", "simplest solution", "minimal solution", "yagni", "do less", or "shortest path", or complains about over-engineering, bloat, boilerplate, or unnecessary dependencies. Do NOT use for non-coding requests (general knowledge, prose, translation, summaries, recipes).

    Also in 5 projects that use this

  • GoogleSkill

    ponytail-review

    Code review focused exclusively on over-engineering. Finds what to delete: reinvented standard library, unneeded dependencies, speculative abstractions, dead flexibility. One line per finding: location, what to cut, what replaces it. Use when the user says "review for over-engineering", "what can we delete", "is this over-engineered", "simplify review", or invokes /ponytail-review. Complements correctness-focused review, this one only hunts complexity.

    Also in 3 projects that use this

  • AWSSkill

    wait-what

    Stop. That last message did not land: re-pitch it.

    Also in 4 projects that use this

  • AWSSkill

    wizard

    Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.

    Also in 3 projects that use this

  • AnasX7Skill

    design-taste-frontend

    Anti-slop frontend skill for landing pages, portfolios, and redesigns. The agent reads the brief, infers the right design direction, and ships interfaces that do not look templated. Real design systems when applicable, audit-first on redesigns, strict pre-flight check.

    Also in 3 projects that use this

  • CloudflareSkill

    receiving-code-review

    Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation

    Also in 3 projects that use this

  • +4 more from google

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 1

    Distinctive

    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:

    Read the live file every run — do not cache it.

    line 66

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “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

Surgical Patch — drift-safe live-file editor

The safe way to change a file that you can't just rsync over, because the live copy is ahead of your local one (other lanes' uncommitted edits live in it).

Why it exists. On 2026-06-03 the prod main.py was ~750 lines ahead of the Mac checkout. A wholesale rsync would have wiped other lanes' work. The fix: fetch the live file, build a minimal delta, and apply it with assertions + backup. This skill is that pattern, made repeatable. Pairs with [[safe-restart]] (guard the restart) and [[aria-deploy]] (do the restart). Enforces the drift rule in [[project_local_first_doctrine_2026_06_02]].

The loop

  1. Find the live anchors. ssh <host> "grep -n '<marker>' <path>" / sed -n the region. Build edits against the LIVE text, never your stale local.
  2. Author an edits spec (edits.json):
    {
      "sentinel": "runner_provenance",
      "verify": "python3 -m py_compile {path}",
      "edits": [
        {"old": "<exact live block>", "new": "<replacement>", "count": 1}
      ]
    }
    • sentinel (optional) — a string unique to the patched state; if already present the run is a NO-OP (idempotent re-runs after a partial deploy).
    • verify (optional) — shell run after writing; {path} is substituted; a nonzero exit rolls back to the backup. For Python on the server use python3 -m py_compile {path} or a full python3 -c "import main".
    • each edit old must match exactly count times (default 1) or the whole run aborts with nothing written.
  3. Dry-run to confirm anchors: add --dry-run.
  4. Apply.
    python3 ~/.claude/skills/surgical-patch/surgical_patch.py \
        --edits edits.json --path /srv/myapp/main.py --host <your-server>
  5. Then /safe-restart (fleet clear?) → /aria-deploy (restart) → /deploy-verify (did my change go live?).

Guarantees & exit codes

  • Idempotent — sentinel present → exit 0, no change.
  • Exact / all-or-nothing — any anchor whose match count ≠ expected aborts the entire run before writing (exit 2). You never get a half-applied file from a drifted anchor.
  • Reversible — original copied to <dir>/.deploy_bak/<ts>/<file> before write; verify failure auto-rolls-back (exit 3).
  • 0 applied/no-op · 1 error · 2 anchor assertion failed · 3 verify failed (rolled back).

Notes

  • Remote writes stream over stdin (ssh host "cat > path") — no arg-length or shell-quoting limits on large files.
  • verify on --host sources the service env file (--env-file, or SURGICAL_PATCH_ENV_FILE; default /opt/aria/.env) first so imports resolve like the running service.
  • It edits ONE file per run by design (clear backups, clear rollback). For a multi-file change, run it once per file; each gets its own backup.
  • Read the live file every run — do not cache it; another lane may have moved on.

License

Apache 2.0

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.