Overview
Sphinx is designed to work directly with Jupyter notebooks in VS Code. It can create new notebooks, add and edit cells, execute code, and understand your notebook’s current state—all while you remain in control of what gets executed.Getting Started
Open a Notebook
- Open any
.ipynbfile in VS Code - Press
Cmd+T(macOS) orCtrl+T(Windows/Linux) to open Sphinx - Start chatting—Sphinx will work directly in your notebook
Create a New Notebook
You can ask Sphinx to create a notebook even without one open:- Open the Sphinx panel with
Cmd+T/Ctrl+T - Describe your task (e.g., “Analyze the sales data in data/sales.csv”)
- Sphinx will create a new notebook and start working
Cell Operations
Sphinx can perform four primary operations on notebook cells:Add Cell
Sphinx adds new cells when:- Loading data
- Creating visualizations
- Processing or transforming data
- Building models
- Fetching data from URLs or APIs
- Code cells — Python code that gets executed
- Markdown cells — Documentation and explanations
Edit Cell
Sphinx edits existing cells when:- Fixing bugs or errors
- Updating visualizations
- Changing parameters
- Responding to user corrections
When a cell fails and you provide a correction (like a file path or variable name), Sphinx edits the failed cell rather than creating a new one.
- Targeted replacements — Small, precise changes to specific lines
- Complete rewrites — Full cell replacement for major changes
Execute Cell
Sphinx executes cells to:- Run newly added code
- Re-run cells after edits
- Execute cells you explicitly request
Delete Cell
Sphinx deletes cells only when you explicitly request it. It won’t remove cells on its own.What Sphinx Sees
Before each interaction, Sphinx extracts context from your kernel to understand your notebook’s current state:| Context | What Sphinx Learns |
|---|---|
| DataFrames | Names, shapes, column types, and sample rows (first 3 rows) |
| Variables | All variable names and their types |
| Imports | Which modules you’ve imported |
| Packages | Installed packages and versions |
| Environment | Available environment variable names |
| Workspace | Current working directory |
- Reference your existing variables correctly
- Know which packages are available
- Understand your data structures
- Avoid redefining things you’ve already created
Execution Flow
Here’s what happens when you ask Sphinx to do something:Operation Modes
Sphinx has three operation modes that control how much autonomy it has:Safe Mode
Every code cell requires your approval before execution.- Best for: Learning, sensitive environments, understanding what Sphinx does
- You control: Every cell execution
- Sphinx does: Generate code, wait for approval
Agent Mode (Default)
Sphinx executes code automatically unless a guardrail flags it.- Best for: Productive workflows, routine analysis
- You control: Flagged operations (file writes, installs, etc.)
- Sphinx does: Execute most code autonomously
Plan Mode
Sphinx creates a multi-step plan, gets your approval, then executes.- Best for: Complex tasks, when you want to review the approach first
- You control: The overall plan before execution begins
- Sphinx does: Plan, then execute after approval
You can switch modes using the dropdown in the Sphinx chat panel.
Exploratory vs. Progress Cells
Sphinx distinguishes between two types of cells:| Type | Purpose | Example |
|---|---|---|
| Exploratory | Understanding data, checking schema | df.info(), df.describe() |
| Progress | Moving toward the goal | Processing data, building models |
- Decide whether to keep or clean up cells
- Understand what’s essential vs. investigative
- Optionally collapse exploratory cells (see Settings)
Handling Errors
When code fails, Sphinx:- Reads the error — Analyzes the traceback and error message
- Identifies the cause — Determines what went wrong
- Fixes the issue — Edits the failing cell with a correction
- Re-executes — Runs the fixed code
Runtime Management
Long-Running Cells
For cells that take time to execute, Sphinx:- Shows execution time in the cell status
- Can interrupt cells that run longer than expected (if enabled)
- Waits for completion before continuing
Kernel Sessions
Sphinx works with your notebook’s kernel session:- Uses whatever kernel you’ve selected (local, remote, cloud)
- Shares the kernel state with any cells you run manually
- Variables persist across Sphinx interactions and manual executions
Checkpoints
When using Agent Mode, Sphinx automatically creates checkpoints of your notebook before making changes. This lets you:- Restore previous versions if something goes wrong
- Review what changed between checkpoints
- Undo Sphinx’s changes by restoring a checkpoint
Checkpoints can be disabled in VS Code settings if you want to reduce disk usage.
Best Practices
Start with data loading
Begin your session by loading your data. This gives Sphinx context about your dataframes from the start.
Run cells to establish context
If you have existing code, run the cells so Sphinx can see your variables and data structures.
Be specific about what you want
Instead of “analyze this data”, try “create a bar chart showing sales by region, sorted by total sales”.
Provide corrections directly
When something fails, tell Sphinx the fix: “The column is called ‘sale_date’, not ‘date’”.