name: "jupyter-notebook"
description: "Use when the user asks to create, scaffold, or edit Jupyter notebooks (.ipynb) for experiments, explorations, or tutorials; prefer the bundled templates and run the helper script new_notebook.py to generate a clean starting notebook."
Jupyter Notebook Skill
Create clean, reproducible Jupyter notebooks for two primary modes:
- Experiments and exploratory analysis
- Tutorials and teaching-oriented walkthroughs
Prefer the bundled templates and the helper script for consistent structure and fewer JSON mistakes.
Multi-agent collaboration
- Default to using subagents when they are likely to improve speed, quality, confidence, or keep the main context clean.
- Use subagents to widen coverage, dig deeper on one thread, get a fresh second opinion, or keep the main thread clean while side work runs.
- Split work into clear packets with owners, inputs, acceptance checks, and a synthesis step when parallelizing.
- Keep the main agent focused on synthesis, unblockers, and the next critical-path step; let subagents handle bounded side work that can run in parallel.
- Use single-agent execution only when scope is small or coordination overhead outweighs gains.
Proactive autonomy and knowledge compounding
- Be proactive: immediately take the next highest-value in-scope action when it is clear.
- Default to autonomous execution: do not pause for confirmation between normal in-scope steps.
- Request user input only when absolutely necessary: ambiguous requirements, material risk tradeoffs, missing required data/access, or destructive/irreversible actions outside policy.
- If blocked by command/tool/env failures, attempt high-confidence fallbacks autonomously before escalating (for example
rg->find/grep,python->python3, alternate repo-native scripts). - When the workflow uses
plan/, ensure required plan directories exist before reading/writing them (create when edits are allowed; otherwise use an in-memory fallback and call it out). - Treat transient external failures (network/SSH/remote APIs/timeouts) as retryable by default: run bounded retries with backoff and capture failure evidence before concluding blocked.
- On repeated invocations for the same objective, resume from prior findings/artifacts and prioritize net-new progress over rerunning identical work unless verification requires reruns.
- Drive work to complete outcomes with verification, not partial handoffs.
- Treat iterative execution as the default for non-trivial work; run adaptive loop passes. Example loops (adapt as needed, not rigid): issue-resolution
investigate -> plan -> fix -> verify -> battletest -> organise-docs -> git-commit -> re-review; cleanupscan -> prioritize -> clean -> verify -> re-scan; docsaudit -> update -> verify -> re-audit. - Keep looping until actual completion criteria are met: no actionable in-scope items remain, verification is green, and confidence is high.
- Run
organise-docsfrequently during execution to capture durable decisions and learnings, not only at the end. - Create small checkpoint commits frequently with
git-commitwhen changes are commit-eligible, checks are green, and repo policy permits commits. - Never squash commits; always use merge commits when integrating branches.
- Prefer simplification over added complexity: aggressively remove bloat, redundancy, and over-engineering while preserving correctness.
- When you touch code, leave the touched area in a better state than you found it: clearer, simpler, tidier, and at least as performant unless the task requires an explicit trade-off.
- Use simple, plain English in user messages, docs, notes, reports, code comments, and other explanatory writing. Avoid jargon, fancy wording, and complex phrasing. When a technical term is needed for correctness, explain it in simple words the first time. Default to short user-facing responses. Think about what the user most wants to know, and lead with that. Do not dump every detail by default. Always include important changes, blockers, verification gaps, and any important assumptions, nuances, principles, or decisions that shaped the work. Add more detail only when the user asks for it or when uncertainty or risk makes it necessary.
- Compound knowledge continuously: keep
docs/accurate and up to date, and promote durable learnings and decisions from work into docs.
Long-task checkpoint cadence
- For any non-trivial task (including long efforts), run recurring checkpoint cycles instead of waiting for a single end-of-task wrap-up.
- At each meaningful milestone with commit-eligible changes, and at least once per major phase, invoke
git-committo create a small logical checkpoint commit once relevant checks are green and repo policy permits commits. - At the same cadence, invoke
organise-docswhenever durable learnings/decisions appear, and prune staleplan/scratch artifacts. - If either checkpoint is blocked (for example failing checks or low-confidence documentation), resolve or record the blocker immediately and retry before expanding scope.
Terminal state contract (must follow)
The skill is complete only when all of the following are true:
- Objective completion: the user-requested outcome is achieved, or explicitly marked
blockedwith concrete blocker evidence. - Workflow completion: every required workflow step is resolved as
done,blocked, ornot-applicable, with brief evidence or rationale. - Step-level terminal completion: each numbered subtask must have explicit completion evidence (artifact, command output, or written rationale) before advancing.
- Verification completion: required checks/validations for this skill are executed, or any unavailable checks are explicitly called out with impact.
- Findings completion (where applicable): report only evidence-backed findings; if no high-confidence critical findings are present, explicitly state that.
- Loop completion: no actionable in-scope next step remains under the current objective.
Stop only after this terminal contract is satisfied; otherwise continue iterating.
Terminal state examples (adapt to skill)
done: requested outcome is delivered and required checks are completed (for example expected artifact/report produced and required validation command(s) passed).blocked: progress cannot continue after bounded retries because of a concrete dependency or access issue; blocker evidence and exact unblock action are reported.not-applicable: an optional step is explicitly skipped with reason (for example no remote configured, so push step is markednot-applicable).
When to use
- Create a new
.ipynbnotebook from scratch. - Convert rough notes or scripts into a structured notebook.
- Refactor an existing notebook to be more reproducible and skimmable.
- Build experiments or tutorials that will be read or re-run by other people.
Decision tree
- If the request is exploratory, analytical, or hypothesis-driven, choose
experiment. - If the request is instructional, step-by-step, or audience-specific, choose
tutorial. - If editing an existing notebook, treat it as a refactor: preserve intent and improve structure.
Skill path (set once)
export CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
export JUPYTER_NOTEBOOK_CLI="$CODEX_HOME/skills/jupyter-notebook/scripts/new_notebook.py"
User-scoped skills install under $CODEX_HOME/skills (default: ~/.codex/skills).
Workflow
-
Lock the intent. Identify the notebook kind:
experimentortutorial. Capture the objective, audience, and what "done" looks like. -
Scaffold from the template. Use the helper script to avoid hand-authoring raw notebook JSON.
uv run --python 3.12 python "$JUPYTER_NOTEBOOK_CLI" \
--kind experiment \
--title "Compare prompt variants" \
--out output/jupyter-notebook/compare-prompt-variants.ipynb
uv run --python 3.12 python "$JUPYTER_NOTEBOOK_CLI" \
--kind tutorial \
--title "Intro to embeddings" \
--out output/jupyter-notebook/intro-to-embeddings.ipynb
-
Fill the notebook with small, runnable steps. Keep each code cell focused on one step. Add short markdown cells that explain the purpose and expected result. Avoid large, noisy outputs when a short summary works.
-
Apply the right pattern. For experiments, follow
references/experiment-patterns.md. For tutorials, followreferences/tutorial-patterns.md. -
Edit safely when working with existing notebooks. Preserve the notebook structure; avoid reordering cells unless it improves the top-to-bottom story. Prefer targeted edits over full rewrites. If you must edit raw JSON, review
references/notebook-structure.mdfirst. -
Validate the result. Run the notebook top-to-bottom when the environment allows. If execution is not possible, say so explicitly and call out how to validate locally. Use the final pass checklist in
references/quality-checklist.md.
Templates and helper script
- Templates live in
assets/experiment-template.ipynbandassets/tutorial-template.ipynb. - The helper script loads a template, updates the title cell, and writes a notebook.
Script path:
$JUPYTER_NOTEBOOK_CLI(installed default:$CODEX_HOME/skills/jupyter-notebook/scripts/new_notebook.py)
Temp and output conventions
- Use
tmp/jupyter-notebook/for intermediate files; delete when done. - Write final artifacts under
output/jupyter-notebook/when working in this repo. - Use stable, descriptive filenames (for example,
ablation-temperature.ipynb).
Dependencies (install only when needed)
Prefer uv for dependency management.
Optional Python packages for local notebook execution:
uv pip install jupyterlab ipykernel
The bundled scaffold script uses only the Python standard library and does not require extra dependencies.
Environment
No required environment variables.
Reference map
references/experiment-patterns.md: experiment structure and heuristics.references/tutorial-patterns.md: tutorial structure and teaching flow.references/notebook-structure.md: notebook JSON shape and safe editing rules.references/quality-checklist.md: final validation checklist.