notebook
Installation
SKILL.md
Notebook Edit Skill
Modify Jupyter notebook cells using jq and bash.
List Cells
# Show all cells with IDs and types
jq -r '.cells | to_entries[] | "\(.key): [\(.value.cell_type)] id=\(.value.id // "none") | \(.value.source[:1] | .[0] // "" | .[0:80])"' NOTEBOOK.ipynb
Replace a Cell's Source
# Replace cell by index (0-based)
jq --arg src "print(\"hello world\")\n" \
'.cells[0].source = ($src | split("\n") | map(if . == "" then . else . + "\n" end) | .[:-1])' \
NOTEBOOK.ipynb > /tmp/nb_tmp.ipynb && mv /tmp/nb_tmp.ipynb NOTEBOOK.ipynb