claude-code - 💡(How to fix) Fix [BUG] NotebookEdit tool writes non-standard Jupyter Notebook format. [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49132Fetched 2026-04-17 08:49:59
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Author
Participants
Timeline (top)
labeled ×4commented ×1

Error Message

Error Messages/Logs

Code Example

{
   "cell_type": "markdown",
   "id": "ec27bf33",
   "source": "### Sample header\nThis is line 1  \nThis is line 2"
  }

---

{
   "cell_type": "markdown",
   "id": "ec27bf33",
   "source": [
    "### Sample header\n",
    "This is line 1  \n",
    "This is line 2"
   ]
  }

---

{
   "cell_type": "markdown",
   "id": "ec27bf33",
   "source": [
    "### Sample header\n",
    "This is line 1  \n",
    "This is line 2"
   ]
  }

---
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

  1. Ask Claude Code to edit a notebook cell.
  2. Commit the changes.
  3. Open the notebook in Jupyter & execute the cell
  4. 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

extent analysis

TL;DR

The most likely fix is to modify Claude Code's NotebookEdit tool to format the cell source as a JSON array instead of a single string.

Guidance

  • Verify that the issue is indeed caused by the formatting difference between Claude Code and Jupyter by checking the notebook file before and after editing with Claude Code.
  • Check the Claude Code documentation or source code to see if there are any configuration options or parameters that can be used to control the output formatting of the NotebookEdit tool.
  • Consider modifying the NotebookEdit tool to use a JSON array for the cell source, as shown in the expected output example.
  • Test the modified NotebookEdit tool to ensure that it produces the correct formatting and does not introduce any other issues.

Example

No code snippet is provided as the issue does not include enough information about the implementation details of the NotebookEdit tool.

Notes

The issue may be specific to the Opus Claude model or the v2.1.110 version of Claude Code, and may not be a regression. Further investigation is needed to determine the root cause and to develop a comprehensive solution.

Recommendation

Apply workaround: Modify the NotebookEdit tool to format the cell source as a JSON array, as this is the expected formatting used by Jupyter and will allow for seamless interaction between Claude Code and Jupyter.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING