Skip to content

prairie-guy/notellm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notellm

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 comments

It'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

Example Session

notellm demo

Installation

Prerequisites

  1. Install Claude Code:
npm install -g @anthropic-ai/claude-code
  1. 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.

Install notellm_magic

git clone https://github.com/prairie-guy/notellm.git
cd notellm
./setup.sh

setup.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/.

Uninstall

cd notellm
./uninstall.sh

uninstall.sh removes notellm_magic/ from the same user site-packages location.

Usage

In a Jupyter notebook:

%load_ext notellm_magic

On 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.

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.

Basic Usage

%cc Create a hello world script

Or multi-line:

%%cc
Create a function that calculates fibonacci numbers
Use memoization for efficiency

Magic Commands

Basic:

  • %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)

When to use each form

  • %cc (single %) - Short, one-line instructions
  • %%cc (double %) - Multi-line instructions or detailed prompts

Notes

  • Restart the kernel to stop the Claude session

Project Structure

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

Development

Rebuilding from archive

If you update archive/cc_jupyter/ with a new upstream version:

./build/build_notellm_magic.sh

This copies the archive to notellm_magic/cc_jupyter/ and applies patches.

Patches Applied

  1. Permission error fix (magics.py) - Wraps /root/code check in try/except
  2. Decorative header removal (jupyter_integration.py) - Removes banner comments from generated cells

Attribution

This project is a fork of claude-code-jupyter-staging by Anthropic, released under the MIT License.

See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published