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.

範本與輔助腳本

Script path:

暫存與輸出慣例

相依套件(僅在需要時安裝)

Prefer uv for dependency management.

Optional Python packages for local notebook execution:

uv pip install jupyterlab ipykernel

隨附的骨架腳本僅使用 Python 標準函式庫,不需要額外相依套件。

環境

沒有必須的環境變數。

參考地圖


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

免責聲明:

本文件已使用 AI 翻譯服務 Co-op Translator(https://github.com/Azure/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.