edit
Modify files via exact replacement, find/replace, or line-range modifications. Supports preview, auto-format, and explicit diff output.
Instructions
Edit one file via exact replacement.
For multiple edits to the same file, use batch_edit (single response,
atomic, faster). For full rewrites, use write.
Modes: find/replace (old_string+new_string), scoped (add start_line/end_line),
or line-range (omit old_string, provide both lines). Keep old_string short
and unique; add line bounds when ambiguous.
Args: path: File path to modify. old_string: Exact text to find. Omit only for line-range replacement. new_string: Replacement text. replace_all: Replace all matches instead of requiring uniqueness. dry_run: Preview without writing. auto_format: Run formatter after editing. show_diff: Return the diff explicitly for successful deterministic edits. start_line: 1-based inclusive start line for scoped or line-range edit. end_line: 1-based inclusive end line for scoped or line-range edit.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| old_string | No | ||
| new_string | No | ||
| replace_all | No | ||
| dry_run | No | ||
| auto_format | No | ||
| show_diff | No | ||
| start_line | No | ||
| end_line | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| truncated | No | ||
| status | No | ||
| path | No | ||
| replaced | No | ||
| line_numbers | No | ||
| diff | No | ||
| diff_state | No | ||
| diff_omitted | No | ||
| tokens_saved | No | ||
| diff_stats | No | ||
| content_hash | No | ||
| from_cache | No | ||
| params | No |