patch_file
Apply a targeted edit to an existing project file by replacing the first occurrence of an exact old string with a new string. Use this instead of write_file to modify large files without rewriting the entire file.
Instructions
Apply a targeted edit to an existing project file without rewriting the entire file. Finds the first occurrence of old_string and replaces it with new_string. Use this instead of write_file when modifying large files (e.g. HTML) — you only send the changed portion, not the whole file.
The old_string must match exactly (including whitespace). If it's not found, the tool returns an error. To insert at a specific position, use a nearby string as old_string and include it in new_string with your addition.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID (e.g. proj_a8Kq7fR2xZ) | |
| path | Yes | File path relative to project root | |
| old_string | Yes | Exact string to find and replace | |
| new_string | Yes | Replacement string |