# multi_edit

Canonical URL: https://developers.iagenify.com/sdk/agent/tools/multi-edit/
Language: en

`multi_edit({ path, edits: [{ old_string, new_string, replace_all? }] })`

Several exact replacements in one file, applied in order, all or nothing. One turn instead of one per change.

Status: category: write · in order · atomic

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `path` | string | required | The file. |
| `edits` | array | required | Each with `old_string`, `new_string` and optionally `replace_all`. |

## All or nothing {#atomic}

If one replacement cannot be made, none of them is written. A file is never left half-changed — which matters when the changes depend on each other, as a rename across a file does.

## In order, and that is visible {#order}

> **Each edit sees the result of the one before**
>
> So an earlier replacement can create — or destroy — the text a later one is looking for. List them in the order they appear in the file and keep their contexts distinct.

```javascript
{
  path: "src/auth.js",
  edits: [
    { old_string: "const TTL = 3600",     new_string: "const TTL = 900" },
    { old_string: "// TODO: rotate",      new_string: "// rotated on refresh" },
    { old_string: "oldName",              new_string: "newName", replace_all: true }
  ]
}
```

## When it is the right tool {#when}

A rename across one file, a set of related changes, applying what a [grep](/sdk/agent/tools/grep) found in a single file. Across several files it is one call each — there is no multi-file edit.

- [edit](/sdk/agent/tools/edit): One replacement.
- [grep](/sdk/agent/tools/grep): Finding the places.
- [Agent tools](/sdk/agent/tools): The 35, by family.

```python
{
    "path": "src/auth.js",
    "edits": [
        {"old_string": "const TTL = 3600", "new_string": "const TTL = 900"},
        {"old_string": "// TODO: rotate", "new_string": "// rotated on refresh"},
        {"old_string": "oldName", "new_string": "newName", "replace_all": True},
    ],
}
```
