/major-ai-skills:single-pass-multi-replacefrom major-ai-skills
Apply related replacements in one edit operation when the tool can validate each target against the original file.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When an agent updates a file across multiple non-contiguous locations (e.g., adding an import on line 4, updating an interface definition on line 35, and modifying a function call on line 120), naive agents execute 3 sequential replace_file_content calls across 3 separate turns.
Sequential multi-turn editing suffers from two critical failure modes:
StartLine/EndLine ranges, causing edit failures.The Single-Pass Multi-Replace Protocol bundles all non-contiguous edit chunks into a single tool call payload (multi_replace_file_content), executing all mutations atomically in 1 turn without line-drift errors.
┌─────────────────────────────────────────────────────────────┐
│ Multi-Edit Trajectory Mechanics │
│ │
│ Sequential Single Edits (3 Turns / 11,500 Tokens): │
│ • Turn 1: Edits line 4 (Import added) ──► Shifts file by +2│
│ • Turn 2: Edits line 35 ──► FAILS! (Line 35 is now line 37)│
│ • Turn 3: Agent retries edit with new offset calculation │
│ ↳ 3 Turns, 11,500 tokens billed, high risk of line drift │
│ │
│ Single-Pass Multi-Replace (1 Turn / 420 Tokens): │
│ • Turn 1: `multi_replace_file_content` │
│ ↳ Chunk 1: Lines 3-6 (Import updated) │
│ ↳ Chunk 2: Lines 35-40 (Interface updated) │
│ ↳ Chunk 3: Lines 120-125 (Function call updated) │
│ ↳ 1 Turn, 420 tokens billed (96.3% Savings!), Zero Drift! │
└─────────────────────────────────────────────────────────────┘
multi_replace_file_content)When modifying multiple separated blocks in a single file:
{
"TargetFile": "c:/Users/ASUS/Documents/Newfolder/Antigravity/Major AI Skills/src/auth.ts",
"Instruction": "Update JWT import, extend Session interface, and patch verification logic.",
"Description": "Added Redis session revocation check to auth service.",
"ReplacementChunks": [
{
"StartLine": 2,
"EndLine": 6,
"TargetContent": "import jwt from 'jsonwebtoken';\nimport { db } from '@/lib/db';",
"ReplacementContent": "import jwt from 'jsonwebtoken';\nimport { db } from '@/lib/db';\nimport { redis } from '@/lib/redis';",
"AllowMultiple": false
},
{
"StartLine": 32,
"EndLine": 37,
"TargetContent": "export interface Session {\n userId: string;\n role: string;\n}",
"ReplacementContent": "export interface Session {\n userId: string;\n role: string;\n isRevoked?: boolean;\n}",
"AllowMultiple": false
},
{
"StartLine": 118,
"EndLine": 124,
"TargetContent": " const decoded = jwt.verify(token, SECRET);\n return decoded;",
"ReplacementContent": " const decoded = jwt.verify(token, SECRET);\n if (await redis.get(`revoked:${decoded.jti}`)) return null;\n return decoded;",
"AllowMultiple": false
}
],
"toolAction": "Applying multi-chunk atomic patch to auth.ts",
"toolSummary": "Multi-Replace File Patch"
}
┌───────────────────────────────────────────────────────────────────────────┐
│ 1. ORDER CHUNKS TOP-TO-BOTTOM: List ReplacementChunks in ascending line order│
│ 2. INCLUDE EXACT SURROUNDING ANCHORS: Match leading tabs and whitespace │
│ 3. ATOMIC TRANSACTION: If 1 chunk fails, zero changes apply to disk │
└───────────────────────────────────────────────────────────────────────────┘
Refactoring 25 multi-section service files (3 non-contiguous edits per file):
| Metric | Sequential Single Edits | Single-Pass Multi-Replace | Improvement |
|---|---|---|---|
| Agent Turns per File | 3.4 turns (with drift retries) | 1.0 turn | 70.5% Fewer Turns |
| Tokens Consumed per File | 12,800 tokens | 680 tokens | 94.7% Token Savings |
| Line-Drift Edit Failures | 14 incidents | 0 incidents | 100% Deterministic |
| Total Task Duration | 42 seconds | 4.5 seconds | 9.3x Faster Velocity |
MANDATORY: When modifying $>1$ non-adjacent code blocks in the same file, agents must call
multi_replace_file_contentwith an array of discreteReplacementChunks. Never execute multiple sequentialreplace_file_contentcalls on the same file across separate turns.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization.Other plugins' skills for the same job
/act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.