Skip to content

Add NotebookEdit tool for Jupyter notebooks #22

Description

@aakashrajput

What

Claude Code has a dedicated NotebookEdit tool for editing .ipynb cells directly (add/edit/delete a specific cell by index, preserving notebook JSON structure, outputs, and metadata) instead of forcing the model to hand-edit raw notebook JSON through edit_file. KlaatCode has no notebook-aware tool today — editing a .ipynb currently means the model manipulating the raw JSON via edit_file/write_file, which is fragile (easy to corrupt cell structure, execution counts, output arrays).

Where to start

  • New tool notebook_edit (src/tools/index.ts, following the existing tool-registration pattern): operations insert_cell / edit_cell / delete_cell, addressed by cell index, cell_type: "code" | "markdown".
  • Parse/serialize with the standard nbformat JSON structure — preserve everything the tool isn't explicitly asked to change (outputs, execution_count, metadata) except when editing a cell's source clears its outputs, matching normal notebook-editing semantics.
  • Route through the same sandbox/write-allowlist and permission-prompt flow as other write tools; diff preview can show the affected cell's before/after source.
  • Read-side: a notebook_read or extending read_file's existing handling to summarize a notebook (cell count, types, first line of each) rather than dumping raw JSON, so the model doesn't need the whole file to decide which cell to touch.

Acceptance criteria

  • Model can add/edit/delete a specific cell in a real .ipynb file without corrupting the surrounding notebook structure.
  • A few unit tests round-tripping a small fixture notebook through insert/edit/delete.

Why it matters

Niche but bounded — data-science/ML users editing notebooks currently get a worse, riskier experience than plain source files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions