Tools · Files and code

multi_edit

Changes things

Apply several exact string-replacement edits to ONE file atomically. Edits apply in order to the same file; if any old_text is missing or ambiguous, nothing is written.

When to use: Batch edits to one file: pass path and edits=[{old_text, new_text, replace_all?}]. Order matters; each edit sees the result of the ones before it.

Example

Run for real by scripts/tool-examples.py in a small demo project, with Haiku 5.5 where the tool calls a model. The output is exactly what the tool returned.

The call

tool call
{
  "tool": "multi_edit",
  "arguments": {
    "path": "README.md",
    "edits": [
      {
        "old_text": "# Demo",
        "new_text": "# Pricing service"
      },
      {
        "old_text": "A tiny pricing service",
        "new_text": "Seat-based pricing"
      }
    ]
  }
}

Real output

File patched: <project>/README.md (2 edits applied)
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
-# Demo
+# Pricing service
 
-A tiny pricing service, with tests.
+Seat-based pricing, with tests.

Parameters

NameTypeDescription
path*stringFile to edit.
edits*arrayEdits applied in order. Each: old_text (exact text to find), new_text (replacement), and optional replace_all (default false).

* required

Read, search and edit the project; run commands, code and git.