Claude Code works with Jupyter notebooks by reading and editing their saved cells. To use it effectively, separate notebook editing from code execution: review the changes, run the appropriate cells, and verify fresh outputs. This guide shows a VS Code setup and a locally tested Python notebook example.
Does Claude Code work with Jupyter Notebook?
Yes. Claude Code can inspect and modify notebook files with the .ipynb extension. Its NotebookEdit tool supports inserting, replacing and deleting individual cells. This makes it useful for reorganizing exploratory analysis, correcting Python code and improving Markdown explanations.
A saved notebook is a structured file containing cell source and possibly saved results. The kernel is a separate running process that maintains variables and executes code. Editing a notebook does not automatically update those variables. Replacing a code cell with NotebookEdit clears its recorded output and execution count. Rerun the affected cells before interpreting the results.
Set up Claude Code and Jupyter in VS Code
Install the official Anthropic Claude Code extension, Microsoft’s Python extension and Jupyter extension in Visual Studio Code. Open an authorized project folder, create or select a Python environment, and choose the corresponding notebook kernel. See our Claude Code in VS Code guide for installation and sign-in.
Open the notebook and the Claude Code panel side by side. Save the notebook before requesting an edit. Claude Code’s extension documentation specifically warns that its autosave setting does not save a notebook before NotebookEdit. Keep a version-controlled copy of important analyses, and avoid granting access to unrelated data or production credentials.
For a terminal-based workflow, install the separate Claude Code CLI and launch it from the notebook project directory. Notebook files can be edited without a graphical interface, but you still need an appropriate execution environment to run the cells.
Example: edit a small revenue notebook
Create analysis.ipynb with two code cells. The first contains a synthetic set of product quantities and prices. These are illustrative data, not real business records.
quantities = [2, 3, 1]
prices = [10, 4, 12]
In the second cell, calculate total revenue and test the result:
revenue = sum(q * p for q, p in zip(quantities, prices))
assert revenue == 44
print(revenue)
Save and run both cells. Then ask Claude Code to review the notebook. A useful prompt is:
Read analysis.ipynb. Explain how the two cells calculate revenue. Identify any assumptions about the inputs. Propose a Markdown explanation without changing the data or executing code.
If you approve a proposed edit, review the changed cell and ensure the original input data remain intact. In this exercise, each quantity must correspond to a price. Python’s zip truncates to the shorter sequence, so mismatched input lengths should be rejected in a real application. A useful follow-up is to ask for a length check and a regression test before any change is applied.
Run the notebook after editing
Run the edited code cell and any downstream cells that depend on it. For a reproducibility check, restart the kernel and execute the complete notebook in order. This exposes hidden dependencies on variables created during earlier interactive experiments. Inspect numerical results and charts directly rather than assuming a model has seen the latest output.
For repeatable execution outside the editor, Jupyter’s nbconvert can run the notebook and save an executed copy. Install the required packages in the selected environment.
python -m pip install nbconvert ipykernel
jupyter nbconvert --to notebook --execute --output analysis.executed.ipynb analysis.ipynb
The example was tested locally by creating the two-cell notebook, executing this nbconvert command in a temporary directory and inspecting the saved output. Execution returned 44, as expected. Claude Code itself was not executed against an authenticated account; this test verifies the notebook and execution workflow, not the agent’s behavior.
Run only reviewed code and use a trusted kernel. A notebook can execute arbitrary operations with the user’s local permissions, including file changes and network requests.
Why notebook outputs can become misleading
Imagine a cell loads a dataset, a second removes invalid records, and a third calculates a metric. If the filtering code is changed but the second cell is not executed, the metric may still reflect the older dataset. Saved output can also differ from what is currently in memory.
Ask Claude Code to distinguish conclusions based on source code from conclusions based on freshly generated output. Re-execute the relevant steps and compare key results with a known reference. If a chart or lengthy output is omitted from the agent’s available context, inspect it yourself or provide an authorized summary. Our AI evals guide explains repeatable evaluation principles.
Choose a notebook execution workflow
For occasional notebook edits, the built-in file tools plus manual execution are usually sufficient. For automated reproducibility, a separate execution command such as nbconvert runs the saved file in a fresh process and produces a verifiable artifact. If a project needs controlled interaction with a running kernel, evaluate a notebook-specific integration or MCP server that explicitly supports those operations.
Third-party notebook integrations vary in their supported capabilities and permissions. A tool that reads a notebook file is not necessarily capable of inspecting live variables, and a tool that runs a whole notebook does not necessarily attach to your existing kernel. Review the integration’s source, access controls and execution boundary before installing it. Our code interpreter guide explains why generated code execution should be isolated.
The default workflow in this guide requires no extra MCP server. Documentation and community sources were reviewed December 4, 2026; no third-party notebook integration was installed.
If you are comparing tools for generating scripts and notebook code, read our AI Python code generator guide.
Frequently asked questions
Can Claude Code create a notebook? It can work with notebook files through its available file tools. Confirm the resulting file opens and executes in your chosen kernel.
Why did my output disappear after an edit? NotebookEdit clears saved output and execution count when replacing a code cell. Rerun it and its dependent cells.
Can Claude Code run the existing kernel directly? The NotebookEdit tool does not attach to the kernel. Execution requires a separate command, manual notebook operation or explicitly supported integration.
What if the notebook does not refresh in VS Code? Save before edits, check the file on disk and reopen the saved notebook if necessary. Avoid overwriting an agent’s changes with an unsaved editor buffer.
How do I know an analysis is reproducible? Run the notebook from a clean kernel, using the intended dependencies and input data, and independently check the resulting metrics.

