Jupyter notebook

From microsoft/ai-agents-for-beginners · View interactive version

Jupyter notebook is an AI agent skill from the GitHub repository microsoft/ai-agents-for-beginners. 在用户请求为实验、探索或教程创建、搭建或编辑 Jupyter 笔记本(`.ipynb`)时使用;优先使用捆绑的模板并运行辅助脚本 `new_notebook.py` 来生成一个干净的起始笔记本。

How to use this skill

Skill file

Jupyter Notebook 技能

为两种主要模式创建简洁、可重现的 Jupyter 笔记本:

优先使用捆绑的模板和辅助脚本,以获得一致的结构并减少 JSON 错误。

何时使用

决策树

技能路径(设置一次)

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).

工作流程

  1. 确定意图。

Identify the notebook kind: experiment or tutorial.

Capture the objective, audience, and what "done" looks like.

  1. 从模板搭建脚手架。

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
  1. 用小的、可运行的步骤填充笔记本。

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.

  1. 应用合适的模式。

For experiments, follow references/experiment-patterns.md.

For tutorials, follow references/tutorial-patterns.md.

  1. 在处理现有笔记本时安全编辑。

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.md first.

  1. 验证结果。

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.

模板与辅助脚本

脚本路径:

临时与输出约定

依赖项(仅在需要时安装)

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.

环境

No required environment variables.

参考映射


<!-- CO-OP TRANSLATOR DISCLAIMER START -->

免责声明:

本文件已使用 AI 翻译服务 Co-op Translator 进行翻译。虽然我们努力保证准确性,但自动翻译可能存在错误或不准确之处。应以原文(原始语言版本)为准。对于重要信息,建议采用专业人工翻译。由于使用本翻译而导致的任何误解或误释,我们概不负责。

<!-- CO-OP TRANSLATOR DISCLAIMER END -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.