patch_cell
Replace a unique substring in a notebook cell by index or cell ID, returning the new revision for chaining edits.
Instructions
Preferred edit tool: replace a unique old substring with new in a cell.
Target the cell by index (0-based) OR cell_id (stable id from list_cells);
pass exactly one. Prefer cell_id when chaining several patches — indices
shift after inserts/deletes/moves, ids don't, so this avoids patching the
wrong cell. old must occur exactly once in the cell; otherwise this errors
and asks for more context. Keeps diffs small. Editing a code cell clears its
outputs. Optionally pass expected_rev (from notebook_rev or a prior write)
to refuse the write if the file changed on disk since. Returns the new rev,
so chained patches can pass it forward without re-reading.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| new | Yes | ||
| old | Yes | ||
| path | Yes | ||
| index | No | ||
| cell_id | No | ||
| expected_rev | No |