Cline now speaks Jupyter: AI-assisted workflows for data scientists
Cline now offers comprehensive Jupyter Notebook support, giving data scientists the same AI-assisted experience that developers have come to expect – but designed specifically for how notebooks actually work.
Data scientists have always lived in notebooks. The iterative, cell-by-cell workflow of Jupyter is perfectly suited for exploration, experimentation, and visualization. But while AI coding assistants have transformed how developers work with traditional codebases, notebooks have been largely left behind. Most tools treat `.ipynb` files as flat text or struggle with the underlying JSON structure, leading to broken outputs, lost metadata, and frustrating manual cleanup.
That changes today. Cline now offers comprehensive Jupyter Notebook support, giving data scientists the same AI-assisted experience that developers have come to expect – but designed specifically for how notebooks actually work.
What makes this different
The core challenge with notebooks is that they're not just code. A Jupyter notebook is a JSON document containing an array of cells, each with its own type (code, markdown, or raw), source content, metadata, execution count, and outputs. AI tools that treat this as a simple text file inevitably break something.
Cline now extracts full cell context before sending anything to the AI. When you work with a notebook, Cline understands the cell type, the source content as an array of lines, cell metadata and configuration, execution count for code cells, and outputs including data, text, and error traces. This means the AI can reason about your notebook the way you do -- cell by cell, with full awareness of what each cell is and what it's produced.
Under the hood, Cline extracts cell context as structured JSON that looks like this:
{
"cell_type": "code",
"source": [
"import pandas as pd\n",
"df = pd.read_csv('sales_data.csv')\n",
"df.groupby('region').agg({'revenue': 'sum'})"
],
"metadata": {},
"execution_count": 12,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": "<table>...</table>"
}
}
]
}This structured representation is what allows the AI to understand not just the code, but its context within the notebook, its execution state, and its actual output.
Three new commands for notebook workflows
We've added three VS Code commands specifically for working with notebooks. Access them via the Command Palette (`Cmd+Shift+P` on Mac or `Ctrl+Shift+P` on Windows/Linux) -- search for "Jupyter" to see all three commands. You can also bind them to keyboard shortcuts for faster access.
Generate new cells with cline.jupyterGenerateCell
The `cline.jupyterGenerateCell` command creates new notebook cells with AI assistance. Describe what you want and Cline will create a properly structured cell that fits into your notebook. The AI receives context from surrounding cells, so it understands the variables and imports already in scope.
For example, if you're working in a notebook where you've already loaded a pandas DataFrame called `df`, you might run `cline.jupyterGenerateCell` and type: "Create a visualization showing the correlation matrix of numeric columns with a heatmap."
Cline sees your existing imports and the DataFrame schema from prior cell outputs, then generates a cell like:
import seaborn as sns
import matplotlib.pyplot as plt
numeric_cols = df.select_dtypes(include=['number'])
correlation_matrix = numeric_cols.corr()
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', center=0)
plt.title('Correlation Matrix')
plt.tight_layout()
plt.show()The cell is inserted with proper notebook JSON structure, ready to execute.
[VIDEO: Cell generation demo]
Understand any cell with cline.jupyterExplainCell
The `cline.jupyterExplainCell` command provides detailed explanations of what a cell does. This is useful when revisiting old notebooks, onboarding to a teammate's analysis, or understanding complex transformations. Cline extracts the full cell context, including outputs, so explanations can reference actual results.
Consider a cell containing a complex pandas operation like this:
result = (
df.groupby(['customer_id', pd.Grouper(key='date', freq='M')])
.agg({
'amount': ['sum', 'mean', 'count'],
'category': lambda x: x.mode().iloc[0] if len(x.mode()) > 0 else None
})
.pipe(lambda x: x.set_axis(['_'.join(col).strip('_') for col in x.columns], axis=1))
.reset_index()
.merge(customer_segments, on='customer_id', how='left')
)Running `cline.jupyterExplainCell` on this produces an explanation that breaks down each chained operation: the groupby with monthly resampling, the multi-aggregation on amount, the mode calculation for category, the column flattening with pipe, and the final merge with the segments table. Because Cline also sees the output, it can reference the actual resulting columns and row counts in its explanation.
Optimize and refactor with cline.jupyterImproveCell
The `cline.jupyterImproveCell` command enhances existing cells with AI suggestions. Maybe you want to optimize a slow pandas operation, add error handling, or refactor for clarity. Cline will suggest improvements while preserving the cell's position and metadata in the notebook structure.
For example, if you have a cell with a slow loop-based operation:
# Calculate rolling 7-day average for each product
results = []
for product_id in df['product_id'].unique():
product_df = df[df['product_id'] == product_id].copy()
product_df['rolling_avg'] = product_df['sales'].rolling(window=7).mean()
results.append(product_df)
final_df = pd.concat(results)Running `cline.jupyterImproveCell` and asking for optimization produces a vectorized version:
# Calculate rolling 7-day average for each product (vectorized)
df = df.sort_values(['product_id', 'date'])
df['rolling_avg'] = df.groupby('product_id')['sales'].transform(
lambda x: x.rolling(window=7).mean()
)The AI explains that the groupby/transform approach eliminates the explicit loop and concat, reducing memory usage and improving performance by orders of magnitude on large datasets.
How it works under the hood
When you run any of these commands, Cline's notebook integration follows a specific flow. You open a `.ipynb` file and position your cursor in a cell. When you run one of the Jupyter commands, VS Code's notebook API extracts the complete cell context as structured JSON. The command handler packages this context along with your input and any relevant context from surrounding cells. The AI receives special system prompt instructions for working with notebook JSON format, including guidelines on maintaining cell structure and handling different cell types. The AI generates a response that maintains proper JSON structure, and the file is updated with the notebook format fully preserved.
This architecture differs fundamentally from how Cline edits regular code files. With a `.py` file, Cline uses diff-based edits on plain text. With notebooks, Cline operates on the cell JSON structure directly, which means cell boundaries stay intact, execution counts are preserved, cell metadata remains untouched, and outputs stay associated with their source cells. You never have to worry about the AI breaking your notebook.
Built for the data science workflow
We designed this feature specifically for how data scientists actually work. Notebooks are exploratory – you run cells, inspect outputs, iterate, and refine. The cell-level granularity means Cline can assist with exactly the piece you're focused on, without needing to understand or modify the entire notebook.
This opens up new possibilities for mixed workflows. You can use Cline to generate boilerplate data loading cells, explain complex transformations written by colleagues, improve visualization code for publication quality, or refactor messy exploration into clean, documented analysis. Because Cline sees the full cell context including outputs, it can make suggestions grounded in your actual data and results, not just abstract code patterns.
A note on the collaboration
This feature wouldn't exist without Amazon's engineering contribution. Thanks to the Amazon team for dedicating engineering time to make comprehensive notebook support possible for the Cline community.
What's next
This is just the beginning of our notebook support. We're continuing to work on deeper capabilities for data science workflows, and we'll have more to share soon.
Try it out
Update Cline to the latest version, enable Enhanced Notebook Interaction in settings, and open your favorite notebook. We'd love to hear how this fits into your workflow -- share your experience on Discord or Reddit.
For complete setup instructions and command reference, see the Jupyter Notebooks documentation.