Jupyter Notebook Refactoring

VerifiedSafe

Analyzes Jupyter Notebook (.ipynb) files as JSON to identify and batch replace specific import statements or code blocks. Helps when renaming modules, updating function calls, or standardizing code patterns across multiple notebooks in a directory.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCursorWindsurfCodex
#jupyter#notebook#refactoring#batch-replace#code-analysis

Recommended for

Automated summary

Programmatically analyzes and performs batch replacement of import patterns or code blocks within Jupyter Notebook (.ipynb) files.

Strengths

  • Enables precise regex-based search and replacement across multiple notebooks
  • Preserves notebook JSON structure and cell source format
  • Automates repetitive refactoring tasks that would be error-prone manually

Limitations

  • Requires careful regex to avoid unintended changes
  • Not suitable for semantic transformations (e.g., renaming variables beyond simple strings)
  • May need manual review after batch replacement to ensure correctness
When to use it

Use this skill when you need to update import statements, deprecated functions, or code patterns across a large number of Jupyter notebooks.

When not to use it

Avoid this skill for one-off edits in a single notebook or when the transformation requires understanding of runtime state or data dependencies.

Security analysis

Safe
Quality score85/100

The skill performs local file manipulations on Jupyter notebooks using Python and does not execute arbitrary shell commands, exfiltrate data, or disable security features. It uses standard JSON parsing and writing, with no destructive patterns.

No concerns found

How this analysis is made

Examples

Replace import statement in all notebooks
Replace all occurrences of 'from gwexpy.noise import asd' with 'from gwexpy.noise import asd_updated' in every .ipynb file under the current directory.
Rename function call across multiple notebooks
In all Jupyter notebooks in the 'experiments' folder, replace 'old_function(' with 'new_function(' in all code cells.
Change plotting library import
Replace 'import matplotlib.pyplot as plt' with 'import seaborn as sns' in all code cells of notebooks in the 'reports' subdirectory.

name: refactor_nb description: Jupyter Notebook (.ipynb) 内のコード要素を一括置換・リファクタリングする

refactor_notebooks Skill

This skill is for programmatically analyzing Jupyter Notebook (.ipynb) files and performing batch replacement or modification of specific import patterns or code blocks.

Instructions

  1. Analyze Notebook Structure:

    • Load .ipynb files as JSON using Python and iterate through the cells list.
    • Verify if the cell_type of each cell is code.
  2. Filter and Match:

    • Join the source field (list format) into a string and use regular expressions or keyword matching to identify target cells.
    • Target specific import statements (e.g., from gwexpy.noise import asd), function calls, or targeted comments.
  3. Implement Transformation:

    • Create a transformation script to rewrite the source list of the cells in memory.
    • The updated source must be in list format (each element as a string ending with a newline).
  4. Write and Verify:

    • Save the file using json.dump, maintaining an indent of 1 (a gwexpy convention) and specifying ensure_ascii=False.
    • Verify that the resulting notebook is valid JSON and that the intended changes have been applied using view_file or similar.

Usage Guidelines

  • When modifying multiple notebooks across a directory, create a loop script that collects .ipynb files using glob or similar.
  • For complex refactoring, adopt a workflow of saving the logic as a temporary .py script, executing it via run_command, and then deleting the script.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/jupyter-notebook-refactoring-mmio71rm/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/jupyter-notebook-refactoring-mmio71rm' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/jupyter-notebook-refactoring-mmio71rm/download' --output '.skill-downloads/jupyter-notebook-refactoring-mmio71rm/SKILL.md.part' && mv '.skill-downloads/jupyter-notebook-refactoring-mmio71rm/SKILL.md.part' '.skill-downloads/jupyter-notebook-refactoring-mmio71rm/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/jupyter-notebook-refactoring-mmio71rm/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills