IPython/Jupyter magic commands for interacting with Claude
Project description
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
- Load the extension:
%load_ext cc_jupyter
- Use Claude to generate and execute code:
%cc Create a list of prime numbers up to 100
- To see available options and usage information:
%cc --help
In IPython
- Start IPython:
ipython
- Load the magic:
%load_ext cc_jupyter
- 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
--helpor--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
- You give Claude a task via
%cc <task> - Claude generates Python code based on your request
- The extension creates a new cell with Claude's Python code
- You review Claude's code and execute it
- 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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_code_jupyter_staging-0.0.1.tar.gz.
File metadata
- Download URL: claude_code_jupyter_staging-0.0.1.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58d4e5486d3d99b1ffd0926c90670258d5ca93e784f0e84f6ea05b9457e788c7
|
|
| MD5 |
30522cda1ef63fe858510fbd7151a034
|
|
| BLAKE2b-256 |
1d5d4e0d15b2960bca0717ec9cbf9c9c9bf5c7add9390ed0ac8e628c32aa1a65
|
File details
Details for the file claude_code_jupyter_staging-0.0.1-py3-none-any.whl.
File metadata
- Download URL: claude_code_jupyter_staging-0.0.1-py3-none-any.whl
- Upload date:
- Size: 32.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cd98acea08bcd68473e8009769b85722272b76278fc5a6ba06fc13607071811
|
|
| MD5 |
f8487508d8fbe26f7278ea27d444db56
|
|
| BLAKE2b-256 |
7408a56bae56457f9798ec16f81e1ccaad713f4f54c430fe3d2787dc1e39796b
|