Short answer: Claude Code edits a Jupyter notebook one cell at a time, by the cell's id: it can replace, insert or delete a cell. When it replaces a code cell, that cell's saved output and execution count are cleared, so re-run the cell, and the cells that depend on it, to get results back. In VS Code, the Claude Code extension works next to the notebook, and you see each proposed change before it lands.
Notebooks mix code, output and notes in one file, which makes them hard to edit as plain text. Claude Code has a tool made for them, and knowing how it behaves avoids the classic mistake: trusting an output that came from code that no longer exists.
How does Claude Code change a notebook?
- overwrite one cell's source
- a code cell loses its saved output
Permission rules use the same path format as file edits: a rule like Edit(notebooks/**) covers notebook edits in that folder.
What is a safe notebook workflow?
- 1Savesave the notebook, so Claude reads the current version
- 2Ask"Refactor the cleaning cells into one function; keep the outputs' meaning"
- 3Reviewread each proposed cell change in VS Code
- 4Re-runrestart the kernel and run all, top to bottom
- 5Comparekey numbers match the old run
Restart and run all matters: after cell edits, the kernel may still hold variables from old code, and a notebook that only works in a running kernel will fail for the next person.
What does it not do?
- Execute cells. Re-running is up to you, in VS Code or Jupyter.
- Edit a notebook that is not valid UTF-8. The edit is refused and nothing is written.
- Keep old outputs on a replaced cell. Commit before a big refactor if you need them.
Where can you check this?
- Claude Code docs: Tools reference, NotebookEdit, cell edits, cleared outputs and permission rules
- Claude Code docs: Use Claude Code in VS Code
Where do you start?
For a first task that produces a script instead of a notebook, see profile a CSV with Claude Code. For the bigger picture, read Claude Code for data analysts.