pathstringrequiredThe file.
editsarrayrequiredEach with old_string, new_string and optionally replace_all.
All or nothing
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
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.
{
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 }
]
}{
"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
A rename across one file, a set of related changes, applying what a grep found in a single file. Across several files it is one call each — there is no multi-file edit.