Notebook.Refactor To Utils
БесплатноБез исполняемых скриптовНе проверенMove or add notebook code to a *_utils.py library file
от gpsaggese★ 158 звёзд на GitHubОб этом скилле
Goal
You are an expert Python developer
I will pass you a Python file paired with a Jupyter notebook using jupytext in
py:percentformatI can also pass a description
<DESCRIPTION>of new code to add- With
<DESCRIPTION>follow Scenario 2, otherwise follow Scenario 1
- With
Plan Only (--only_plan)
- With
--only_plan, follow.claude/skills/skill.rules.mdsection "Create Only a Plan with--only_plan" - Write the plan to
notebook.refactor_to_utils.<INPUT_REF>.md, then stop without executing the skill
Constraints
Follow
.claude/skills/coding.rules.mdfor all codeImportant Notes
- Always sync before editing:
uvx jupytext --sync notebook.py - Always sync after editing:
uvx jupytext --sync notebook.py
- Always sync before editing:
Scenarios
- This skill handles two complementary scenarios:
Scenario 1: Moving Existing Functions to Utils
- Extract functions from an existing notebook and move them to utils
Scenario 2: Adding New Code to Utils
- Add new functions or code to the utils file that corresponds to the notebook
Workflow
Identify or Create the Utils File
- Find or create the library file for the notebook, named after it with underscores
- E.g.,
Lesson94-Information_Theory.ipynb->Lesson94_Information_Theory_utils.py - E.g.,
tutorial_advanced.ipynb->tutorial_advanced_utils.py
- E.g.,
Organize Code Structure in Utils File
Mirror the notebook's flow, with section separators for each notebook section
- Example:
# ############################################################################# # Cell 1: Visual Bin - Population of Marbles # ############################################################################# def cell1_draw_bin_with_marbles_interactive(...): ... def _cell1_helper_function(...): ... # ############################################################################# # Cell 2: Entropy Calculations # ############################################################################# def cell2_calculate_entropy(...): ...
- Example:
Put each function in the part of the utils file that matches its notebook section
Group related functions together
Use private functions (prefix
_) for helpers not called from the notebook
Move or Add Functions
For Moving Functions (Scenario 1):
Follow these steps:
- Copy all functions from the notebook to the utils file, without changing code
- Remove the functions from the notebook
- Update the notebook cells to call the utils functions
For Adding Functions (Scenario 2):
Follow these steps:
- Implement new code directly in the utils file
- Create caller code in the notebook that imports and uses the functions
- Add the code in the matching section of the utils file
Update Notebook to Call Utils
Replace function implementations with imports and calls
Pattern:
import notebook_name_utils as utils # In code cells: utils.function_name(...)Keep each code cell minimal:
# Display results of Cell 2 analysis. utils.cell2_calculate_entropy()
Code Reuse
- Reuse code already in the
*_utils.pyfile and in thehelpersdirectory - Avoid duplication across utils functions. Extract common patterns into helpers
Sync with Jupytext
- After all modifications, sync both files, following
# Code Architecture and Responsibility->## Utilities vs. Notebook Responsibilitiesin.claude/skills/notebook.rules.md:> uvx jupytext --sync <path/to/notebook.py>
Conventions
- Always follow
.claude/skills/notebook.rules.md
Verification
-
--only_plan(check only this item): the plan is innotebook.refactor_to_utils.<INPUT_REF>.mdin the current dir, has theGenerated byline, and nothing was executed - Confirm no function moved to
*_utils.pychanged behavior - Confirm every notebook cell that held inline code now calls its utils function
- Confirm the
.ipynband paired.pyfile are in sync via Jupytext
Установить Notebook.Refactor To Utils в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Notebook.Refactor To Utils?
Move or add notebook code to a *_utils.py library file
Как установить скилл Notebook.Refactor To Utils?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Notebook.Refactor To Utils запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic