Skip to main content

Claude Code Jupyter

IPython/Jupyter magic commands for interacting with Claude. This extension allows Claude to generate code that executes in your current Jupyter notebook or IPython session, sharing all variables and state.

Installation

pip install claude-code-jupyter

For development installation:

git clone https://github.com/anthropics/claude-code-jupyter.git
cd claude-code-jupyter
pip install -e ".[dev]"

Quick Start

In a Jupyter Notebook

  1. Load the extension:
%load_ext cc_jupyter
  1. Use Claude to generate and execute code:
%cc Create a list of prime numbers up to 100
  1. To see available options and usage information:
%cc --help

In IPython

  1. Start IPython:
ipython
  1. Load the magic:
%load_ext cc_jupyter
  1. Use Claude to generate and execute code:
%cc Create a list of prime numbers up to 100

When to use %cc vs %%cc

  • Use %cc (single %) for:

    • Short, one-line instructions
    • Command options like --help or --verbose
    • Continuing without additional instructions
  • Use %%cc (double %) for:

    • Multi-line instructions or detailed prompts
    • Complex requests that need more explanation
    • Any prompt ending with ? (to avoid IPython's help system)

Features

Automatic Code Writing

Claude's code blocks are automatically extracted and written into a new cell that you approve by executing:

import numpy as np
data = np.random.randn(1000)

%%cc
Create a histogram of the data array and calculate its statistics

Continue Conversations

Follow up on previous requests:

%cc Create a pandas DataFrame with sales data

# Claude writes code into a new cell, you review it and execute it

%cc Now add a column for profit margin

Shared State

All variables are shared between you and Claude:

# You create:
x = [1, 2, 3, 4, 5]

# Claude can use:
%cc Square each element in x and store in a new list called x_squared

# Claude writes code into a new cell, you review it and execute it

# You can use:
print(x_squared)  # Claude's variable is available!

How It Works

  1. You give Claude a task via %cc <task>
  2. Claude generates Python code based on your request
  3. The extension creates a new cell with Claude's Python code
  4. You review Claude's code and execute it
  5. You can continue working with Claude via %cc

Examples

Data Analysis

%%cc
Load the iris dataset from sklearn and create a scatter plot matrix

Interactive Development

# Your code
data = load_my_data()

%cc Clean the data by removing NaN values and outliers

# Claude writes code into a new cell, you review it and execute it

%cc Now normalize the numerical columns

# data is now cleaned and normalized in your session

Development

Setup

# Clone the repository
git clone https://github.com/anthropics/claude-code-jupyter.git
cd claude-code-jupyter

# Install in development mode with dev dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Running Tests

pytest

Code Quality

# Run linting
ruff check .

# Run formatting
ruff format .

# Run type checking
pyright

Safety

  • Claude does not execute code by itself. All code is reviewed by a human, who can choose to execute (or not).

Limitations

  • Claude can write code with errors
  • No sandboxing - code runs with same access as rest of notebook

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

This extension is perfect for interactive data analysis, learning, and development where you want Claude to work alongside you in the same environment!

Metadata

Release files for claude-code-jupyter-staging 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-code-jupyter-staging 0.0.1
File Size Uploaded
claude_code_jupyter_staging-0.0.1.tar.gz 30.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-code-jupyter-staging 0.0.1
File Interpreter ABI Platform
claude_code_jupyter_staging-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 63.3 kB

Release files / claude_code_jupyter_staging-0.0.1.tar.gz

Download URL claude_code_jupyter_staging-0.0.1.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
58d4e5486d3d99b1ffd0926c90670258d5ca93e784f0e84f6ea05b9457e788c7
BLAKE2b-256 checksum
How to use checksums
1d5d4e0d15b2960bca0717ec9cbf9c9c9bf5c7add9390ed0ac8e628c32aa1a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / claude_code_jupyter_staging-0.0.1-py3-none-any.whl

Download URL claude_code_jupyter_staging-0.0.1-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cd98acea08bcd68473e8009769b85722272b76278fc5a6ba06fc13607071811
BLAKE2b-256 checksum
How to use checksums
7408a56bae56457f9798ec16f81e1ccaad713f4f54c430fe3d2787dc1e39796b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page