Multi Edit File
Use this bundled skill for manual text-file changes. The gateway resolves all affected paths, validates the full request, applies exact replacements in memory, and only then commits the file operations. If validation fails, no file is written.
Prefer multi_edit_file over shell redirection or ad hoc scripts for normal source/config/docs edits because the gateway can audit affected paths, enforce allowed-directory policy, and return a compact delta.
Input Modes
Legacy single-file edit:
{
"path": "src/example.rs",
"edits": [
{
"old_string": "old text",
"new_string": "new text",
"replace_all": false,
"startLine": 42
}
],
"cwd": "D:/path/to/workspace",
"skillToken": "..."
}
Multi-file exact edits:
{
"files": [
{
"path": "src/a.rs",
"edits": [
{
"old_string": "old",
"new_string": "new"
}
]
},
{
"path": "src/b.rs",
"edits": [
{
"old_string": "enabled: false",
"new_string": "enabled: true"
}
]
}
],
"cwd": "D:/path/to/workspace",
"skillToken": "..."
}
Structured file operations:
{
"operations": [
{
"type": "edit",
"path": "src/a.rs",
"edits": [
{
"old_string": "old",
"new_string": "new"
}
]
},
{
"type": "create",
"path": "src/new.rs",
"content": "pub fn new_file() {}\n"
},
{
"type": "delete",
"path": "src/old.rs"
},
{
"type": "move",
"from": "src/name_old.rs",
"to": "src/name_new.rs"
}
],
"cwd": "D:/path/to/workspace",
"skillToken": "..."
}
Fields
pathplus top-leveleditskeeps compatibility with the original single-file mode.filesis for multiple existing files, each with its ownpathandedits.operationssupportsedit,create,delete, andmove.cwdis required when more than one allowed directory is configured.skillTokenis required for normal calls. The documentation read for this SKILL.md is the only call that does not require it.
Edit fields:
old_stringmust be exact current file text after normalizing CRLF to LF.new_stringis the replacement text.replace_allreplaces every occurrence ofold_stringin the current in-memory state.startLineis optional and 1-based. Use it when the sameold_stringappears more than once and you want the closest match to that line.
Create and move fields:
contentis required forcreate.overwritedefaults to false. When false,createormovefails if the target already exists.fromandtoare required formove.
Rules
- Read relevant current content with
read_filebefore editing unless the exact text is already in context. Use terminal reads only ifread_fileis disabled, unavailable, or unsuitable. - Use exact
old_stringtext copied from the current file, including indentation. Do not include the line-number prefix or tab fromread_fileoutput. - Keep
old_stringas small as practical while still unique. If it is not unique, either setreplace_allor providestartLine. - Do not set
old_stringequal tonew_string. - Do not use an empty
old_string; usecreatefor new files, or include surrounding existing text for insertions. - Do not touch the same path more than once in one call. Put all replacements for one file into a single
editoperation. - Order edits inside one file so a later
old_stringdoes not target text produced by an earliernew_string. - For TS, TSX, JS, and JSX template strings, write
${...}exactly. Do not escape the dollar sign as\${...}unless the target source code truly needs a literal${...}string.
Result And Events
On success, the result includes added, modified, deleted, moved, a compact delta with byte counts and affected path metadata, and a warnings array when the gateway detects likely syntax hazards such as unbalanced delimiters or accidental \${...} in TS/JS files. Warnings do not block the write; inspect and verify them before continuing.
The admin event stream records an editPreview event before policy confirmation and a finished event after completion.