batch_edit
Apply multiple exact edits to one file atomically. Returns partial success details for any failed edits, allowing retry without reapplying all 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). 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.
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. | |
| auto_format | No | Run the formatter after all edits. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | No | ||
| path | No | ||
| failed | No | ||
| params | No | ||
| status | No | ||
| failures | No | ||
| outcomes | No | ||
| succeeded | No | ||
| truncated | No | ||
| diff_state | No | ||
| diff_stats | No | ||
| from_cache | No | ||
| content_hash | No | ||
| diff_omitted | No | ||
| tokens_saved | No |