Batch Edit
batch_editApply many exact edits to one file atomically in a single call, returning precise results for each edit. Supports dry-run and range-based replacements, so you can retry only the failed changes.
Instructions
Apply many exact edits to one file in a single atomic call.
Preferred over repeated edit calls on the same file: one response,
applied atomically, faster on large files. Partial success is allowed —
any failed edits are returned with their reason so you can retry just the
misses (status is edited when all apply, partial when some fail,
no_changes when none do). A dry_run writes nothing and says so: the
status becomes would_edit/would_partial and dry_run: true comes back
with it. For edits across different files, call the tool once per file.
edits is a JSON array; each entry is one of:
[old, new]— exact find/replace.[old, new, start_line, end_line]— find/replace confined to a range.[null, new, start_line, end_line]— replace that line range wholesale.{"old": ..., "new": ..., "start_line": ..., "end_line": ...}— object form.
Prefer line-range entries when you already have line numbers from read.
Pass known_hash and the response carries a claimable content_hash, so
no read is needed afterwards; without it, or with auto_format, you get
file_hash instead.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"edits": "<edits>"
},
"name": "batch_edit"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path to modify (absolute, or relative to root). | |
| edits | Yes | JSON array of edit entries, in any of the forms above. | |
| dry_run | No | Preview without writing. | |
| show_diff | No | Return the full diff even on a deterministic all-success batch. | |
| known_hash | No | The `content_hash` from your last read of this file. Proves you hold the text being edited, so the result can be handed back as a claimable `content_hash`. | |
| auto_format | No | Run the formatter after all edits. |