跳到主要内容

Jupyter 笔记本整理

收藏0

Jupyter Notebook

创建、整理和改造 Jupyter Notebook,用于实验记录、教程和可复现分析。

让 AI 安装

灵栈官方最新版本 0.1.0更新于 2026-10-16下载 1 次

  • Jupyter
  • Notebook
  • 实验记录
  • 教程
  • Python
  • 可复现

SKILL.md

4.1 KB查看排版效果
1---
2name: "jupyter-notebook"
3description: "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."
4---
5
6
7# Jupyter Notebook Skill
8
9Create clean, reproducible Jupyter notebooks for two primary modes:
10
11- Experiments and exploratory analysis
12- Tutorials and teaching-oriented walkthroughs
13
14Prefer the bundled templates and the helper script for consistent structure and fewer JSON mistakes.
15
16## When to use
17- Create a new `.ipynb` notebook from scratch.
18- Convert rough notes or scripts into a structured notebook.
19- Refactor an existing notebook to be more reproducible and skimmable.
20- Build experiments or tutorials that will be read or re-run by other people.
21
22## Decision tree
23- If the request is exploratory, analytical, or hypothesis-driven, choose `experiment`.
24- If the request is instructional, step-by-step, or audience-specific, choose `tutorial`.
25- If editing an existing notebook, treat it as a refactor: preserve intent and improve structure.
26
27## Skill path (set once)
28
29```bash
30export CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
31export JUPYTER_NOTEBOOK_CLI="$CODEX_HOME/skills/jupyter-notebook/scripts/new_notebook.py"
32```
33
34User-scoped skills install under `$CODEX_HOME/skills` (default: `~/.codex/skills`).
35
36## Workflow
371. Lock the intent.
38Identify the notebook kind: `experiment` or `tutorial`.
39Capture the objective, audience, and what "done" looks like.
40
412. Scaffold from the template.
42Use the helper script to avoid hand-authoring raw notebook JSON.
43
44```bash
45uv run --python 3.12 python "$JUPYTER_NOTEBOOK_CLI" \
46 --kind experiment \
47 --title "Compare prompt variants" \
48 --out output/jupyter-notebook/compare-prompt-variants.ipynb
49```
50
51```bash
52uv run --python 3.12 python "$JUPYTER_NOTEBOOK_CLI" \
53 --kind tutorial \
54 --title "Intro to embeddings" \
55 --out output/jupyter-notebook/intro-to-embeddings.ipynb
56```
57
583. Fill the notebook with small, runnable steps.
59Keep each code cell focused on one step.
60Add short markdown cells that explain the purpose and expected result.
61Avoid large, noisy outputs when a short summary works.
62
634. Apply the right pattern.
64For experiments, follow `references/experiment-patterns.md`.
65For tutorials, follow `references/tutorial-patterns.md`.
66
675. Edit safely when working with existing notebooks.
68Preserve the notebook structure; avoid reordering cells unless it improves the top-to-bottom story.
69Prefer targeted edits over full rewrites.
70If you must edit raw JSON, review `references/notebook-structure.md` first.
71
726. Validate the result.
73Run the notebook top-to-bottom when the environment allows.
74If execution is not possible, say so explicitly and call out how to validate locally.
75Use the final pass checklist in `references/quality-checklist.md`.
76
77## Templates and helper script
78- Templates live in `assets/experiment-template.ipynb` and `assets/tutorial-template.ipynb`.
79- The helper script loads a template, updates the title cell, and writes a notebook.
80
81Script path:
82- `$JUPYTER_NOTEBOOK_CLI` (installed default: `$CODEX_HOME/skills/jupyter-notebook/scripts/new_notebook.py`)
83
84## Temp and output conventions
85- Use `tmp/jupyter-notebook/` for intermediate files; delete when done.
86- Write final artifacts under `output/jupyter-notebook/` when working in this repo.
87- Use stable, descriptive filenames (for example, `ablation-temperature.ipynb`).
88
89## Dependencies (install only when needed)
90Prefer `uv` for dependency management.
91
92Optional Python packages for local notebook execution:
93
94```bash
95uv pip install jupyterlab ipykernel
96```
97
98The bundled scaffold script uses only the Python standard library and does not require extra dependencies.
99
100## Environment
101No required environment variables.
102
103## Reference map
104- `references/experiment-patterns.md`: experiment structure and heuristics.
105- `references/tutorial-patterns.md`: tutorial structure and teaching flow.
106- `references/notebook-structure.md`: notebook JSON shape and safe editing rules.
107- `references/quality-checklist.md`: final validation checklist.

文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。