edit_file
Apply targeted code edits by replacing exact text in files, with atomic all-or-nothing application to prevent partial changes.
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. |