patch_file
Replace a specific string or code block in a file without rewriting the whole file. Uses a unique match and creates an automatic backup before applying the change.
Instructions
Replace a specific string or block of code within a file without rewriting the whole file. The old_string must appear exactly once in the file. A backup is created automatically before the change is applied.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes | Path to the file, relative to project root or absolute | |
| new_string | Yes | The string to replace it with | |
| old_string | Yes | The exact string to find and replace. Must be unique in the file — include extra surrounding lines if needed to make it unique. |