Margin includes an AI agent that works alongside you in notebooks. Ask it to analyze data, create visualizations, fix errors, or explain code—and watch it work in real-time.
Press ⌘J (Mac) or Ctrl+J (Windows/Linux) to toggle the AI panel. You can also click the AI icon in the toolbar.
The panel appears on the right side of your notebook. Choose between:
The AI agent has full access to your notebook:
| Capability | Description |
|---|---|
| Read notebook | Sees all cells, outputs, and context |
| Create cells | Adds new code or markdown cells |
| Edit cells | Modifies existing cell content |
| Run cells | Executes code and sees the output |
| Delete cells | Removes cells when appropriate |
| Query datasets | Explores your uploaded data |
When the AI works, you see everything happen live in your notebook—cells appear, code gets written, and executions run with visible output.
"What's the distribution of sales by region?"
The AI will:
"This cell is throwing a KeyError"
The AI will:
"What does this code do?"
The AI explains the selected cell in plain English—without modifying anything.
You're always in charge:
The AI scrolls cells into view as it works, so you can follow along. A visual indicator highlights cells the AI is currently editing or running.
| Shortcut | Action |
|---|---|
| ⌘J / Ctrl+J | Toggle AI panel |
| ⌘⇧J / Ctrl+⇧J | Toggle panel mode (slideover ↔ side) |
| Escape | Stop AI / close panel |
| Enter | Send message |