notebook-refactor

notebook-refactor is a skill for Claude Code, Codex from giacomogaglione/claude-awesome-stack. It costs 30 tokens per session (519 once invoked), scanned A, original, MIT.

A guide for turning an exploratory Jupyter notebook into tested Python modules while keeping the notebook as part of the exploration workflow.

In plain words
What is it for?
Use it to extract data processing, model, training, and evaluation code into modules, replace hardcoded settings with parameters, and write small deterministic tests.
Why use it?
It separates reusable production code from experimentation and reduces the risk of moving untested notebook logic into an application.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to extract data processing, model, training, and evaluation code into modules, replace hardcoded settings with parameters, and write small deterministic tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/giacomogaglione/claude-awesome-stack/notebook-refactor
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add giacomogaglione/claude-awesome-stack --skill notebook-refactor
Clone the repo
git clone --depth 1 https://github.com/giacomogaglione/claude-awesome-stack

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for notebook-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/giacomogaglione/claude-awesome-stack/notebook-refactor/github.svg)](https://agentmods.dev/skills/giacomogaglione/claude-awesome-stack/notebook-refactor)
Your own site
<a href="https://agentmods.dev/skills/giacomogaglione/claude-awesome-stack/notebook-refactor"><img src="https://agentmods.dev/badge/skills/giacomogaglione/claude-awesome-stack/notebook-refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for notebook-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/giacomogaglione/claude-awesome-stack/notebook-refactor"><img src="https://agentmods.dev/badge/skills/giacomogaglione/claude-awesome-stack/notebook-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 519 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00030 $0.00519
Opus 5 $0.00015 $0.00260
Sonnet 5 $0.00006 $0.00104
Haiku 4.5 $0.00003 $0.00052

Measured 9d ago against content hash 7586ceba46ec, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

notebook-refactor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

stacks/python-ml/skills/notebook-refactor/SKILL.md · 66 lines

How it starts

The opening of the file, as written. The whole thing — 66 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Notebook Refactoring Skill

Convert Jupyter notebook exploration code into clean, tested Python modules.

Process

1. Analyze the Notebook

Read the notebook and identify:

  • Data loading cells -> src/data/ module
  • Preprocessing/transformation cells -> src/data/ or src/preprocessing/ module
  • Model definition cells -> src/models/ module
  • Training loop cells -> src/training/ module
  • Evaluation/metrics cells -> src/evaluation/ module
  • Visualization cells -> keep in notebook (these are exploratory)
  • Configuration values (magic numbers, paths) -> src/config/ or config file

2. Extract Functions

For each group of cells:

  1. Identify inputs and outputs of the cell block
  2. Extract into a function with:
    • Type-annotated parameters for all inputs
    • A clear return type
    • A docstring explaining what it does and why
  3. Replace hardcoded values with parameters
  4. Remove display(), print() debugging statements
  5. Keep the notebook cell but replace the code with an import + function call

3. Write Tests

For each extracted function, write tests that:

  • Use small, deterministic test fixtures (not the full dataset)
  • Test the function's contract (input types -> output types/shapes)
  • Test edge cases (empty input, single row, missing values)
  • Use np.testing.assert_allclose for numerical outputs
  • Do NOT test exact numerical values from model operations (non-deterministic)

4. Update the Notebook

After extraction, the notebook should:

  • Import from the new modules instead of defining functions inline
  • Still be runnable end-to-end
  • Serve as a high-level walkthrough / documentation of the pipeline
  • Keep exploratory visualizations and analysis inline

5. Refactoring Checklist

Before marking complete:

  • All extracted functions have type hints
  • All extracted functions have tests
  • Notebook still runs end-to-end with imports
  • No hardcoded paths or magic numbers remain
  • No unused imports in extracted modules
  • pyproject.toml or setup.py updated if new packages are needed

Read the full file on GitHub · 66 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 66 lines · 30 tokens per session scan A 7586ceba46ec

Subscribe to this mod's changes

notebook-refactor is a skill published in the GitHub repository giacomogaglione/claude-awesome-stack (2 stars, last pushed 6mo ago), licensed MIT. It adds 30 tokens to every session and 519 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.