jupyter-notebooks

Jupyter notebook operations: editing cells, reading notebooks, executing, and format conversion. Trigger when working with .ipynb files for: (1) Creating/editing/deleting/reordering cells, (2) Reading notebook content, (3) Executing notebooks with papermill, (4) Converting to HTML/PDF/script formats. Supports Cursor EditNotebook tool, Jupytext workflows, and nbformat.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "jupyter-notebooks" with this command: npx skills add kang-chen/agent-skills/kang-chen-agent-skills-jupyter-notebooks

Jupyter Notebook Operations

Decision Tree

Need to edit a notebook?
├─ In Cursor IDE? → Use EditNotebook tool directly
├─ Structural changes (add/delete/reorder)? → Jupytext workflow
├─ Small edit in single cell? → nbformat micro-edit
├─ Execute and capture outputs? → papermill
└─ Convert format? → nbconvert

EditNotebook Tool (Cursor IDE)

Preferred method in Cursor. Parameters:

ParameterRequiredDescription
target_notebookYesPath to .ipynb
cell_idxYes0-based cell index
is_new_cellYestrue = new cell, false = edit existing
cell_languageYespython, markdown, r, sql, shell, raw, other
old_stringYesText to replace (empty for new cells)
new_stringYesReplacement content

Critical rules:

  • Set is_new_cell correctly
  • Include 3-5 lines context in old_string
  • Cannot delete cells (clear content with new_string="")

Jupytext (Structural Edits)

Setup & Sync

# Pair notebook (one-time)
python -m jupytext --set-formats ipynb,py:percent notebook.ipynb

# Always sync before reading .py
python -m jupytext --sync notebook.ipynb
# Or fallback:
python -m jupytext --to py:percent notebook.ipynb -o notebook.py

Edit .py with percent-format

# %% [markdown]
# # Section Title

# %%
import pandas as pd

# %% tags=["parameters"]
param1 = "default"

Sync back (preserve outputs)

python -m jupytext --to ipynb --update notebook.py -o notebook.ipynb

nbformat (Micro-Edits & Batch)

Edit single cell

import nbformat

nb = nbformat.read("notebook.ipynb", as_version=4)
nb["cells"][3]["source"] = nb["cells"][3]["source"].replace("old", "new", 1)
nbformat.write(nb, "notebook.ipynb")

Add new cell

new_cell = nbformat.v4.new_code_cell(source="print('Hello')")
nb["cells"].insert(5, new_cell)

Delete cell

del nb["cells"][3]

papermill (Execute Notebooks)

# Basic
papermill input.ipynb output.ipynb

# With parameters
papermill input.ipynb output.ipynb -p data_path "/path" -p n_samples 1000
import papermill as pm
pm.execute_notebook("input.ipynb", "output.ipynb", parameters={"n_samples": 1000})

nbconvert (Format Conversion)

FormatCommand
HTMLjupyter nbconvert --to html notebook.ipynb
PDFjupyter nbconvert --to pdf notebook.ipynb
Scriptjupyter nbconvert --to script notebook.ipynb
Markdownjupyter nbconvert --to markdown notebook.ipynb

Execute and convert: jupyter nbconvert --execute --to html notebook.ipynb

Clear outputs: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace notebook.ipynb


Common Issues

IssueSolution
Outputs lost after syncUse --update flag with Jupytext
Kernel not foundjupyter kernelspec list then specify -k python3
Large file sizeClear outputs before git commit
Windows venvUse .\.venv\Scripts\activate

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

skill-creator

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

skill-manager

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

skill-installer

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

skills-sync

No summary provided by upstream source.

Repository SourceNeeds Review