Edits existing Jupyter notebooks using cell anchors and backups while preserving metadata and JSON structure.
- GitHub stars
- 6
- Files
- 3
- Last commit
- Oct 31, 2026
- License
- MIT
- Allowed tools
- —
What does the method-notebook-edit skill do?
method-notebook-edit edits existing Jupyter notebooks using cell anchors and backups while preserving metadata and JSON structure.
Summary generated from the skill's SKILL.md.
About the method-notebook-edit skill
Patching existing Jupyter notebooks without corrupting their JSON structure or metadata is the primary function of this skill. It is designed for developers and researchers who need to update, extend, or amend existing .ipynb files rather than generating new ones from scratch. By using specific cell anchors located in the metadata tags, the tool ensures that changes are inserted into precise locations without reordering or rewriting the entire file.
An agent should load this skill when a user requests a specific modification, such as inserting a sensitivity analysis or a figure-generation cell. The process relies on the notebook being modified through a command-line interface that accepts a notebook path, an anchor tag, and source files for code or markdown. To maintain safety, the tool creates a backup file with a .bak extension before any changes are applied. It also validates the notebook schema using nbformat if available to prevent structural drift.
What an agent can do with it
- 1Insert analytical cells into notebooksA developer can add a new sensitivity analysis or a Table 1 note into an existing notebook using a specific anchor tag.
- 2Update notebooks while preserving metadataModify an existing notebook to include new code and explanatory markdown while ensuring the original JSON structure and execution history remain intact.
- 3Safely patch files with backupsPerform targeted edits on a notebook while automatically creating a backup to prevent data loss.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the method-notebook-edit skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the method-notebook-edit skill in Plugin
/plugin marketplace add sajor2000/methodsmith /plugin install methodsmith@methodsmith
Install the method-notebook-edit skill in Claude Code
~/.claude/skills/method-notebook-edit/SKILL.md
$ npx degit sajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit ~/.claude/skills/method-notebook-editInstall the method-notebook-edit skill in Claude Code (project)
.claude/skills/method-notebook-edit/SKILL.md
$ npx degit sajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit .claude/skills/method-notebook-editInstall the method-notebook-edit skill in Codex
~/.agents/skills/method-notebook-edit/SKILL.md
$ npx degit sajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit ~/.agents/skills/method-notebook-editInstall the method-notebook-edit skill in Gemini CLI
~/.gemini/skills/method-notebook-edit/SKILL.md
$ npx degit sajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit ~/.gemini/skills/method-notebook-editInstall the method-notebook-edit skill in Claude.ai
npx degit sajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit method-notebook-edit && zip -r method-notebook-edit.zip method-notebook-edit # claude.ai → Customize → Skills → + → Create skill → Upload a skill → method-notebook-edit.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachablesajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit is public and reachablegithub.com/sajor2000/methodsmith/tree/HEAD/plugins/methodsmi ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-10-31github.com/sajor2000/methodsmith/commits ↗Pass
- No download-and-run or credential theft in scripts1 script read; no download-and-run, remote eval, base64 execution or credential uploadPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/sajor2000/methodsmith/blob/HEAD/plugins/methodsmi ↗Pass
- Pre-approved tools are scopedNo pre-approved tools; the agent asks before using onegithub.com/sajor2000/methodsmith/blob/HEAD/plugins/methodsmi ↗Pass
- SKILL.md follows the Agent Skills formatValid name and description; says when to use it; 63 linesgithub.com/sajor2000/methodsmith/blob/HEAD/plugins/methodsmi ↗Pass
SKILL.md
View on GitHubGuarded Notebook Editing
Run the script from the user's project root.
$SKILL_DIRanchors the script path;--notebook,--source, and--markdown-sourceresolve against--project-root(default: the current directory) and must stay project-relative.
Skill Value
- Problem it solves: Notebook edits can silently reorder cells, corrupt metadata, or break outputs when treated as plain text.
- Use when: The user asks to update, patch, or extend an existing notebook rather than generate a new one.
- Output: A backed-up notebook edit plus an anchor/change summary and validation notes.
- Ask only if: Only when target notebook, edit anchor, or desired insertion point is unclear.
- Do not do: Do not rewrite whole notebooks or discard metadata without explicit scope.
- Interaction: Check repo/config/chat evidence first. Ask one decision-changing question at a time; use the current harness's blocking question UI when available, otherwise present numbered choices and wait.
Existing notebooks are fragile because cell order, metadata, outputs, and JSON structure can drift silently. This skill edits them only through explicit anchors and always leaves a backup.
When This Skill Activates
- The user asks to modify an existing
.ipynbrather than generate a new script, Quarto file, or marimo notebook. - A SAP amendment, sensitivity analysis, Table 1 note, or figure-generation cell must be inserted into a notebook that already exists.
- A reviewer asks for a small notebook change and preserving execution history matters.
Workflow
- Prefer text-native formats for new work. If the user is starting fresh, route to the
method-workskill scaffolding instead of creating a new.ipynb. - Inspect the notebook structure and identify a unique anchor tag in
cell.metadata.tags. - Load the
method-notebook-standardsskill before adding or materially changing executable cells. Put the explanatory Markdown and new code body in small project files, then run:
SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
python3 "$SKILL_DIR/scripts/notebook_edit.py" --notebook analysis/notebook.ipynb --tag sap-5-1 --markdown-source analysis/notebook-edits/new-cell.md --source analysis/notebook-edits/new-cell.py --cell-type code
- Review the generated backup, modified notebook diff, and
.edit-report.mdfile. - Run the notebook top-to-bottom with the project's normal runner if available. If no runner exists, surface that as a verification gap.
When an edit adds or changes code that reads, creates, transforms, validates, or renders analytical data or output, use the declared restricted data root for file-backed data (or the registered verified data connection). Synthetic, mock, sample, and fake-study data are allowed only when the user explicitly requests a clearly labeled test or demonstration; do not produce a synthetic study result. If the real source or QA provenance is unavailable, do not run the notebook and do not persist output. Record the real source location or registered extract ID/hash and validation evidence with each persisted study result. An explicitly requested synthetic test/demo may persist only as a clearly labeled non-study artifact with synthetic fixture or generator provenance, never in a study-output location.
Guarantees
- The script refuses absolute paths and paths outside the project root.
- The script requires exactly one matching anchor tag.
- The original notebook is copied to
<notebook>.bakbefore writing. - A code-cell insertion requires
--markdown-source; the tool inserts the explanatory Markdown directly before the code cell. - If
nbformatis installed, the script validates the notebook schema before and after editing. If it is missing, the script still performs structural JSON checks and prints install guidance.
What This Skill Does Not Do
- Does not rewrite or reorder existing cells.
- Does not execute notebooks inside the edit script; step 5 runs them only through the project's normal runner.
- Does not edit notebooks without a unique metadata tag anchor.
- Does not hide manual review;
.ipynbdiffs must be inspected before treating the change as complete.
References
@./references/notebook-edit-policy.md
Files in this skill
3method-notebook-edit skill questions
How do I install the method-notebook-edit skill in Claude Code?
Run npx degit sajor2000/methodsmith/plugins/methodsmith/skills/method-notebook-edit ~/.claude/skills/method-notebook-edit. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the method-notebook-edit skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
How does the tool ensure the original notebook is not lost during editing?
The tool creates a backup of the original notebook by copying it to a file with a .bak extension before any writes occur.
Can this skill be used to rewrite an entire notebook?
No, the skill is designed for patching and does not rewrite or reorder existing cells.
What is required to insert a new code cell?
A code-cell insertion requires a markdown source file, which the tool uses to insert explanatory Markdown directly before the code cell.