code_patch
Preview and apply reversible patches to code, markdown, or config files; create new files or edit text you already read using a read reference or file locator.
Instructions
Edit any text file (code, md, config) — a reversible alternative to Edit/Write: patch text you already read (pass its read_ref), or create:true + content + locator.file_path. dry_run default: preview; false applies.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patch | No | For patch {old_string, new_string}; old_string exact, unique. | |
| create | No | New file: content + locator.file_path. | |
| safety | No | Validation gate: {profile: standard|strict|fast, block_on_validation_error: boolean}. | |
| content | No | For replace_symbol. | |
| dry_run | No | true = preview; false = apply. | |
| locator | No | Anchor {file_path, name}/{symbol_id}. | |
| task_id | Yes | Task id. | |
| boundary | No | replace_symbol: full (default, includes signature) or body (body only). | |
| read_ref | No | Preferred; supplies base_version. | |
| edit_mode | No | patch default; replace_symbol: content. | |
| request_id | No | Idempotency key. | |
| workspace_dir | Yes | Project root (abs). | |
| preserve_decorators | No | replace_symbol: keep decorators (default true). | |
| allow_unsafe_no_base | No | Force write without a prior file-level read (default false; gate). | |
| expected_state_revision | No | Optimistic guard. |