[BUG] NotebookEdit tool writes non-standard Jupyter Notebook format.
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When Claude Code uses NotebookEdit tool to edit a notebook cell, it changes the source formatting from JSON array to single string.
e.g. here is what Claude Code produces:
{
"cell_type": "markdown",
"id": "ec27bf33",
"source": "### Sample header\nThis is line 1 \nThis is line 2"
}
While the above is valid, the Jupyter interface on clicking Save or executing cell turns it into:
{
"cell_type": "markdown",
"id": "ec27bf33",
"source": [
"### Sample header\n",
"This is line 1 \n",
"This is line 2"
]
}
Issue
Claude Code's notebook formatting makes it difficult to use it interactively with Jupyter as any edit by Claude Code changes the entire notebook cell contents causing massive noisy diffs.
What Should Happen?
Claude's NotebookEdit tool should simply follow standard notebook formatting where cell source lines are JSON array. e.g.
{
"cell_type": "markdown",
"id": "ec27bf33",
"source": [
"### Sample header\n",
"This is line 1 \n",
"This is line 2"
]
}
This should be a straightforward change to NotebookEdit tool.
Error Messages/Logs
Steps to Reproduce
- Ask Claude Code to edit a notebook cell.
- Commit the changes.
- Open the notebook in Jupyter & execute the cell
- Look at git diff, the notebook file is changed even though content is untouched.
Above issue makes it impossible to use Claude's NotebookEdit capability alongside standard Jupyter.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.1.110
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗