Ipynb editor
skills for your agent to work with jupyter notebooks
npx -y skills add BenGardiner/ipynb-agent-skills --skill ipynb-editorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Edits, validates, and formats Jupyter Notebook (.ipynb) files. Use when the user wants to safely modify notebook cells, check cell syntax, or verify execution. Do not use for standard Python (.py) scripts.
SKILL.md
2.9 KB, 670 tokens by cl100k_base, as published. Nobody here has run it
Purpose
Ensure safe, structurally valid edits to Jupyter Notebook (.ipynb) files and verify the syntax and execution of their code cells.
Inputs / Outputs
- Input: Target
.ipynbfile path and the requested code/markdown modifications. - Output: A successfully updated
.ipynbfile with verified JSON structure and validated code cells.
Constraints
- MUST preserve the exact JSON structure of the
.ipynbfile. - MUST ensure every string in a
sourcearray (except possibly the last) ends with a newline\n. Failure to do this causes PythonSyntaxErrororIndentationErrorwhen cells are loaded. - MUST verify that the final output is completely valid JSON before saving.
- MUST check for "double-escaping" (e.g.,
\\nor\") which often occurs when AI agents attempt to nest JSON strings incorrectly. - MUST validate the Python syntax of modified code cells using
scripts/verify_ipynb.py. - MUST NOT modify standard Python (
.py) scripts using this skill.
Workflow
- Read and Parse: Read the
.ipynbfile to analyze its JSON structure, focusing on thecellsarray. - Edit Safely: Apply the required modifications to the
sourcearrays.- Crucial: Ensure each line in the array is a separate string ending in
\n. - Example:
"source": ["import os\n", "print(os.name)\n"]
- Crucial: Ensure each line in the array is a separate string ending in
- Validate Structure: Run
python -m json.tool filename.ipynbto ensure the file is still valid JSON. - Validate Syntax: Run
python scripts/verify_ipynb.py --syntax-only filename.ipynb.- If a
SyntaxErroris reported, check if you missed a\nat the end of a line in thesourcearray. - Check for
\\nor\\"which indicate accidental double-escaping.
- If a
- Audit the resulting Python code e.g. to catch "JSON bleeding"-where JSON formatting (like
\n",) accidentally leaks into code cells and e.g. to verify logical correctness.- Convert to Python: Run
jupyter nbconvert --to python <filename>.ipynb. - Audit Logic: Read the generated
<filename>.pyfile to ensure the code matches the intended logic and is free of stray JSON artifacts. - Cleanup: Delete the temporary
.pyfile after verification.
- Convert to Python: Run
- Verify Execution (If requested/expected): If the notebook is expected to execute cleanly, run
python scripts/verify_ipynb.py --execute filename.ipynb.
Anti-Patterns
- Treating the
.ipynbfile as a standard raw text file instead of a JSON document. - Forgetting to add
\nto individual lines within thesourceJSON array. - Accidentally double-escaping backslashes (e.g.,
\\ninstead of\n). - Skipping syntax validation after modifying a code cell.