Lightweight Jupyter magic extension for Claude Code integration.
Claude Code is my favorite LLM tool, and I wanted to use it directly within Jupyter notebooks. notellm provides the %cc magic command that lets Claude work inside your notebook—executing code, accessing your variables, searching the web, and creating new cells:
%cc Import the penguin dataset from altair. There was a change made in version 6.0. Search for the change. No commentsIt's Claude Code in the notebook cell rather than in the command line. The %cc cells are used to develop and iterate code, then deleted once the code is working.
This differs from sidebar-based approaches where you chat with an LLM outside of the notebook. With notellm, code development happens iteratively from within the notebook cells.
I work in bioinformatics and developed notellm for my own research projects. Hopefully it's useful for other bioinformaticians, data scientists, or anyone wanting to use Claude Code within Jupyter.
notellm is adapted from a development version released by Anthropic. Any issues are my own.
Key features:
- Full agentic Claude Code execution within notebook cells
- Claude has access to your notebook's variables and state
- Web search and file operations without leaving the notebook
- Conversation continuity across cells
- Automatic permissions setup for common operations
See also: Vizard — I developed Vizard as a more constrained, higher-level language for specifying Polars and Altair code. The goal was more reproducible visualizations through a stateful declarative syntax combining CAPITALIZED keywords with natural language. Vizard includes a large CLAUDE.md specification file that guides Claude to generate consistent, predictable code. Example:
%%cc
DATA penguins.csv FILTER species == "Adelie" || PLOT violin Y body_mass_g COLOR sex- Install Claude Code:
npm install -g @anthropic-ai/claude-code- Install Python dependencies (pip only):
pip install trio claude-agent-sdk(tested with trio==0.24.0, claude-agent-sdk==0.1.18)
Note: Use pip for these dependencies. The claude-agent-sdk package is only available on PyPI, not conda-forge.
git clone https://github.com/prairie-guy/notellm.git
cd notellm
./setup.shsetup.sh copies notellm_magic/ to your Python user site-packages directory (determined by python3 -c "import site; print(site.USER_SITE)"), typically ~/.local/lib/python3.x/site-packages/.
cd notellm
./uninstall.shuninstall.sh removes notellm_magic/ from the same user site-packages location.
In a Jupyter notebook:
%load_ext notellm_magicOn load, you'll see a security warning and the Claude Code Magic banner:
================================================================================
WARNING: Claude has permissions for Bash, Read, Write, Edit, WebSearch, WebFetch
Claude can execute shell commands, read/write/edit files, and access the web.
Only use in trusted environments.
Consider removing .claude/settings.local.json when done.
================================================================================
Claude Code Magic loaded!
On first load in a directory, notellm also creates .claude/settings.local.json with default permissions.
The auto-created .claude/settings.local.json grants Claude access to:
- Bash - Run shell commands
- Glob - Find files by pattern
- Grep - Search file contents
- Read - Read files
- Edit - Modify files
- Write - Create files
- WebSearch - Search the web
- WebFetch - Fetch web content
To customize, edit .claude/settings.local.json in your project directory.
%cc Create a hello world scriptOr multi-line:
%%cc
Create a function that calculates fibonacci numbers
Use memoization for efficiencyBasic:
%cc <instructions>- Continue conversation (one-line)%%cc <instructions>- Continue conversation (multi-line)%cc_new(or%ccn) - Start fresh conversation%cc --help- Show all options
Context management:
%cc --import <file>- Add file to conversation context%cc --add-dir <dir>- Add directory to Claude's accessible directories%cc --mcp-config <file>- Set path to MCP server config%cc --cells-to-load <num>- Number of cells to load into new conversation
Output:
%cc --model <name>- Model to use (default: sonnet)%cc --max-cells <num>- Max cells Claude can create per turn (default: 3)
Display:
%cc --clean- Replace prompt cells with Claude's code cells%cc --no-clean- Keep prompt cells (default)
%cc(single %) - Short, one-line instructions%%cc(double %) - Multi-line instructions or detailed prompts
- Restart the kernel to stop the Claude session
notellm/
├── archive/
│ └── cc_jupyter/ # Pristine copy from PyPI
├── notellm_magic/
│ ├── __init__.py # Thin wrapper + permissions setup
│ └── cc_jupyter/ # Patched fork
├── build/
│ └── build_notellm_magic.sh
├── docs/
│ └── demo.ipynb # Demo notebook
├── setup.sh
├── uninstall.sh
├── LICENSE
└── README.md
If you update archive/cc_jupyter/ with a new upstream version:
./build/build_notellm_magic.shThis copies the archive to notellm_magic/cc_jupyter/ and applies patches.
- Permission error fix (
magics.py) - Wraps/root/codecheck in try/except - Decorative header removal (
jupyter_integration.py) - Removes banner comments from generated cells
This project is a fork of claude-code-jupyter-staging by Anthropic, released under the MIT License.
See LICENSE for details.
