edit_file
Edit existing files by replacing exact text with new content. Applied atomically, so if any match fails, the original file remains unchanged.
Instructions
Make targeted edits to an existing file by replacing exact text. Each edit's old_string must appear exactly once (include surrounding lines to disambiguate) unless replace_all is set. All edits are applied atomically — if any anchor fails to match, the file is left untouched and you are told why. This is the preferred way to modify code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File to edit, relative to the workspace root. | |
| edits | Yes | Edits applied in order. | |
| workspace | No | Workspace alias. Defaults to the active workspace. |