write_symbol
Safely modify one code symbol at a time: replace, patch, or insert after a function/method/class, using a base version from read_symbol to avoid write conflicts.
Instructions
Guarded write path (one symbol) — vs edit_batch: index-aware with version/lock/undo, for symbol-level refactors. Read first (read_symbol) for base_version. For string params containing double quotes/backslashes, keep JSON escaping consistent across the whole string (escape uniformly or prefer full-width quotes), otherwise client-side parameter parsing fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patch | No | Required when edit_mode=patch | |
| safety | No | Safety knobs | |
| content | Yes | New content (full symbol or body per boundary) | |
| dry_run | No | Validate and produce diff without writing (default false) | |
| locator | Yes | ||
| boundary | No | full (default): replace whole symbol. body: keep signature line, replace the rest. | |
| edit_mode | No | replace_symbol (default) / patch (sub-symbol old_string→new_string) / insert_after_symbol | |
| base_version | Yes | REQUIRED: version from read_symbol. Conflict anchor. | |
| workspace_dir | Yes | REQUIRED: project root (abs). reindex first if new. | |
| preserve_decorators | No | Warn if content drops decorators that exist above the symbol (default true) | |
| allow_unsafe_no_base | No | Bypass base_version requirement (audited). Only for deliberate full-file overwrites. |