Skip to content
Chat & Slash Commands

Chat & Slash Commands

The Lab sidebar includes a chat panel powered by Jupyter AI. Use it to ask questions about your code, get explanations, generate notebooks, and run specialized slash commands.

Opening the Chat

Click the chat bubble icon in the left panel, or use the keyboard shortcut to open the AI chat sidebar.

Slash Commands

CommandWhat it does
/learn <path>Index files or directories so the AI can answer questions about them
/ask <question>Query the indexed content
/generate <description>Generate a new notebook from a natural language description
/fixDiagnose and fix the error in the selected cell
/docGenerate docstrings for the selected code
/refactorSuggest refactors for the selected code
/explainExplain what the selected code does
/testGenerate unit tests for the selected code
/visualizeGenerate a visualization for the selected data
/analyzeAnalyze the selected data or results
/dataAsk a question about your connected datasources
/clearReset the conversation history

/learn — Index Your Codebase

Index a directory so the AI can answer questions about your project:

/learn ./src
/learn ./data/schema.sql

After indexing, ask questions with /ask:

/ask How does the authentication middleware work?
/ask What tables does the orders module use?

The index persists for the session. Re-run /learn after adding new files.

/generate — Create Notebooks

Generate a complete notebook from a description:

/generate Analyze customer churn using the CRM database. Include cohort analysis and a retention funnel.

The AI will scaffold cells with code, markdown explanations, and suggested visualizations.

/fix — Fix Errors

After a cell raises an exception:

  1. Select the error cell
  2. Type /fix in the chat

The AI reads the traceback and proposes a corrected version of the cell.

/doc, /explain, /refactor, /test

All of these work on the selected cell or selected code:

/doc          # Add docstrings
/explain      # Plain-English explanation
/refactor     # Suggest improvements
/test         # Generate pytest unit tests

Model Selection

The chat uses whatever model is selected in the model dropdown at the top of the chat sidebar. Change it to switch between providers (Claude, GPT-4o, Gemini, etc.) mid-conversation.

To use a specific model for a single magic command:

%%ai anthropic:claude-3-5-sonnet-20241022
Your prompt here

See AI Magic for full %%ai documentation.