Skip to main content

Jupyter magic for Claude Code — %cc brings agentic AI into your notebook cells

Project description

jupyter-cc

Jupyter magic for Claude Code -- %cc brings agentic AI into your notebook cells.

jupyter-cc integrates Claude Code directly into Jupyter notebooks as IPython magic commands. Instead of switching between a sidebar or terminal and your notebook, you stay in the notebook: type %cc with a prompt, and Claude reads your variables, executes tools, and creates new code cells for you to review and run.

Built on the Claude Agent SDK with an in-process MCP server, jupyter-cc gives Claude the same agentic capabilities it has in Claude Code CLI -- file editing, shell commands, web search -- plus the ability to create notebook cells.

jupyter-cc demo: asking Claude to create a scatter plot, showing the streaming response with insights and the generated code cell below

Example Session

# Cell 1: Load the extension
%load_ext jupyter_cc

# Cell 2: Ask Claude to analyze data
%cc Load the sales.csv file and show summary statistics

# Cell 3: Claude creates a code cell for you to review and run
# ... (auto-generated by Claude)

# Cell 4: Follow up in the same conversation
%cc Now plot monthly revenue trends with a 3-month moving average

Installation

Prerequisites

  1. Python 3.13+ -- check with python --version
  2. Claude Code CLI -- install from Claude Code docs, verify with claude --version
  3. Authentication -- one of:
    • Claude Pro/Max subscription
    • Anthropic API key
  4. Jupyter (for notebook usage) or IPython (for terminal usage):
    pip install jupyter
    # or
    pip install ipython
    

Install

pip install jupyter-cc

With uv:

uv pip install jupyter-cc

Quick Start

After installation:

# In a Jupyter notebook or IPython session:
%load_ext jupyter_cc
%cc Hello! What can you help me with?

Uninstall

pip uninstall jupyter-cc

Development (for contributors)

If you want to contribute to jupyter-cc, clone the repo and install in development mode:

git clone https://github.com/vinceyyy/jupyter-cc.git
cd jupyter-cc
uv sync

Usage

%load_ext jupyter_cc

Magic Commands

Command Alias Description
%cc <prompt> Continue conversation with Claude (one-line)
%%cc Continue conversation with Claude (multi-line)
%cc_new <prompt> %ccn Start a fresh conversation (no history)
%cc_cur <prompt> %ccc Like %cc, but replaces the prompt cell in-place

Use %%cc (cell magic with double %) when your prompt spans multiple lines or ends with ? (to avoid IPython's help system).

Options

Option Description
--model <name> Model to use (default: sonnet)
--max-cells <num> Max cells Claude can create per turn (default: 3)
--import <file> Include a file in the initial conversation context
--add-dir <dir> Add a directory to Claude's accessible paths
--mcp-config <file> Path to .mcp.json with additional MCP server configs
--cells-to-load <num> Number of recent cells to load into a new conversation
--clean Replace prompt cells with Claude's code cells
--no-clean Keep prompt cells (default)
--verbose, -v Show detailed tool call arguments
--help, -h Show usage information

Skills and Context

The Claude Agent SDK automatically reads configuration from your project and user directories. No extra setup is needed -- just place files in the right locations.

Project-level (checked into your repo):

  • .claude/CLAUDE.md -- project instructions, coding conventions, architecture notes
  • .claude/settings.local.json -- tool permissions (auto-created on first load)
  • .claude/skills/ -- project-specific skill files (*.md)

User-level (your personal config):

  • ~/.claude/CLAUDE.md -- global instructions applied to all projects
  • ~/.claude/skills/ -- personal skills available everywhere

To add a skill, create a Markdown file in .claude/skills/ or ~/.claude/skills/. To customize Claude's behavior for a project, edit .claude/CLAUDE.md in your project root.

For a detailed breakdown of what Claude sees when you run %cc -- variables, cell history, images, system prompt, and more -- see What CC Sees.

Project Structure

src/jupyter_cc/
├── __init__.py      # Extension entry point, permissions setup
├── magics.py        # %cc, %cc_new, %cc_cur magic commands, MCP server
├── client.py        # SDK client lifecycle, streaming, interrupt handling
├── config.py        # CLI options (--model, --add-dir, --import, etc.)
├── prompt.py        # System prompt construction
├── integration.py   # Cell creation, queue management, env detection
├── history.py       # IPython cell history tracking
├── variables.py     # Session variable change detection
├── capture.py       # Image extraction from cell outputs
├── watcher.py       # "Run All" detection via timing heuristics
├── constants.py     # Help text, tool names
└── py.typed         # PEP 561 type marker

Development

uv sync                        # Install dependencies
uv run ruff check src/ --fix   # Lint (auto-fix)
uv run ruff format src/        # Format
uv run pyright src/            # Type check
uv run pytest                  # Run tests
uv build                       # Build wheel/sdist

Acknowledgements

jupyter-cc is adapted from:

Released under the MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_cc-0.2.0.tar.gz (31.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_cc-0.2.0-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_cc-0.2.0.tar.gz.

File metadata

  • Download URL: jupyter_cc-0.2.0.tar.gz
  • Upload date:
  • Size: 31.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for jupyter_cc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 593e9f33ebb7d8ee12438ef1384fcbbf764c8c6c3a325124797662d054d71da4
MD5 a129bee96cfbf1f4a5e8819f55882dac
BLAKE2b-256 73ff9fcdd1c42757a516d06fbd0d1abf63d29f8e672ded9aab7456cd64f431bd

See more details on using hashes here.

File details

Details for the file jupyter_cc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: jupyter_cc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for jupyter_cc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d3e340daacadc018c7c536eb2b38e9004f4d5cba0cd0048ad50ac50eccfecfc
MD5 b8dc188198cf8d2ceddb141544124500
BLAKE2b-256 684fdae9580befe094540a351083598091b7bace0256847f5bb33a6ede251f88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page