← ClaudeAtlas

surgical-patchlisted

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.
iansteitz1-eng/aria-skills · ★ 0 · Data & Documents · score 72
Install: claude install-skill iansteitz1-eng/aria-skills
# 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`): ```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