python-notebooks-async skill
✓ 検証済みJupyter notebookやセルベースのワークフローにおいて、イベントループの競合を回避しながら、エージェントがasyncioコードを記述・レビューするのを支援します。
- GitHubスター
- 6
- ファイル
- 2
- 最終コミット
- 2026年10月29日
- ライセンス
- CC0-1.0
- 許可されたツール
- —
python-notebooks-async skillは何をしますか
python-notebooks-asyncはAgent Skillsです。 Jupyter notebookやセルベースのワークフローにおいて、イベントループの競合を回避しながら、エージェントがasyncioコードを記述・レビューするのを支援します。.
skillのSKILL.mdから生成された要約。
python-notebooks-async skill について
Jupyter notebookやセルベースのワークフローで作業する開発者は、このSKILLを使用して、イベントループの競合を引き起こすことなく非同期Pythonコードを管理できます。このスキルは、ノートブックカーネルが既にイベントループを所有している環境において、非同期スクリプトの記述、レビュー、または移植を担当するエージェントに対してガイダンスを提供します。これらのパターンに従うことで、エージェントはasyncio.run()の使用時に発生するRuntimeErrorや、タスクがサイレントに完了できなくなるなどの一般的なエラーを回避できます。
エージェントは、セル内でのasyncio.run()の失敗に遭遇した場合や、IPythonカーネル内でgatherやTaskGroupを使用して並行タスクをオーケストレーションする場合に、このスキルをロードする必要があります。このスキルは、トップレベルのawaitの実装、.pyモジュール内での再利用可能なロジックの管理、およびブロッキング呼び出しの代わりにaiohttpやhttpxなどのライブラリを選択することに焦点を当てています。コードの信頼性を確保し、根本的な設計上の問題を隠蔽しないようにするため、nest_asyncioは主要な解決策ではなくフォールバックとして扱います。
エージェントができること
- 1イベントループエラーの修正ノートブックセル内でasyncio.run()を呼び出すことによって発生するRuntimeErrorを解決します。
- 2非同期ノートブックコードのリファクタリングテストを容易にするため、ノートブックセル内のインライン非同期ヘルパー関数を外部のPythonモジュールに移動します。
- 3ブロッキングI/O問題の防止イベントループを停滞させる同期的な呼び出しを特定し、非ブロッキングの代替手段に置き換えます。
skill の SKILL.md から作成されています。すべてのユースケースは、その引用と照合されています。
python-notebooks-async skillのインストール方法
各コマンドはskillフォルダをクライアントのskillsディレクトリにコピーします。読み込むには、クライアントを再起動するか新しいセッションを開始してください。Claude Codeにpython-notebooks-async skillをインストールする
~/.claude/skills/python-notebooks-async/SKILL.md
$ npx degit ahgraber/skills/skills/python-notebooks-async ~/.claude/skills/python-notebooks-asyncClaude Code (project)にpython-notebooks-async skillをインストールする
.claude/skills/python-notebooks-async/SKILL.md
$ npx degit ahgraber/skills/skills/python-notebooks-async .claude/skills/python-notebooks-asyncCodexにpython-notebooks-async skillをインストールする
~/.agents/skills/python-notebooks-async/SKILL.md
$ npx degit ahgraber/skills/skills/python-notebooks-async ~/.agents/skills/python-notebooks-asyncGemini CLIにpython-notebooks-async skillをインストールする
~/.gemini/skills/python-notebooks-async/SKILL.md
$ npx degit ahgraber/skills/skills/python-notebooks-async ~/.gemini/skills/python-notebooks-asyncClaude.aiにpython-notebooks-async skillをインストールする
npx degit ahgraber/skills/skills/python-notebooks-async python-notebooks-async && zip -r python-notebooks-async.zip python-notebooks-async # claude.ai → Customize → Skills → + → Create skill → Upload a skill → python-notebooks-async.zip
自動チェック
実行日 2026年11月16日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。エージェントに実行させる前にスクリプトを読んでください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能ahgraber/skills/skills/python-notebooks-async is public and reachablegithub.com/ahgraber/skills/tree/HEAD/skills/python-notebooks ↗合格
- オープンソースライセンス (OSI)CC0-1.0spdx.org/licenses/CC0-1.0.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit 2026-10-29github.com/ahgraber/skills/commits ↗合格
- スクリプトにダウンロード実行や認証情報の窃取がないNo scripts in the skill folder合格
- SKILL.md に隠れた指示がないNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/ahgraber/skills/blob/HEAD/skills/python-notebooks ↗合格
- 事前許可ツールが限定されているNo pre-approved tools; the agent asks before using onegithub.com/ahgraber/skills/blob/HEAD/skills/python-notebooks ↗合格
- SKILL.md が Agent Skills の形式に従っているValid name and description; says when to use it; 66 linesgithub.com/ahgraber/skills/blob/HEAD/skills/python-notebooks ↗合格
SKILL.md
GitHubで表示Python Notebooks Async
Overview
Notebook kernels own the event loop; async code must cooperate with that ownership rather than fight it.
This skill covers orchestration patterns, top-level await, and compatibility constraints for .ipynb and #%% workflows.
Treat these recommendations as preferred defaults. When project constraints require deviation, call out tradeoffs and compensating controls.
When to Use
asyncio.run()raisesRuntimeErrorinside a notebook cell.- Event-loop conflicts when mixing async libraries in Jupyter.
- Porting async scripts into notebook workflows.
- Orchestrating concurrent tasks (
gather,TaskGroup) in IPython kernels. - Deciding where to place reusable async logic across notebook/module boundaries.
When NOT to Use
- Pure script or service code with no notebook involvement.
- Synchronous notebook workflows with no async needs.
- General asyncio API design outside notebook contexts — the
pythonskill covers concurrency audit defaults.
Invocation Notice
- Tell the user when this skill is running:
python-notebooks-async. Skip the notice when the user asked for the skill by name or slash command; spelling and spacing need not match. A phrase from this skill's own trigger list is not a name — naming the work is not naming the skill.
Quick Reference
- Treat notebook kernels as loop-owned environments; never create a competing loop.
- Use top-level
awaitinstead ofasyncio.run()in notebook cells. - Orchestrate concurrent work with
asyncio.gather()orasyncio.TaskGroup. - Keep reusable async logic in regular
.pymodules, imported into notebooks. - Use
nest_asyncioonly as a constrained compatibility fallback, not a default. - Avoid fire-and-forget tasks — always
awaitor collect results explicitly.
Common Mistakes
- Calling
asyncio.run()in a notebook cell. The kernel already runs a loop;asyncio.run()tries to start a second one and raisesRuntimeError. Useawaitdirectly instead. - Applying
nest_asyncioglobally by default. It patches the loop to allow reentrant calls but masks design problems and can hide subtle concurrency bugs. Reserve it for legacy compatibility. - Defining async helpers inline in cells instead of modules.
Inline definitions are lost on kernel restart and cannot be tested outside the notebook.
Extract to
.pyfiles. - Ignoring returned tasks or coroutines.
Calling an async function without
awaitsilently produces a never-executed coroutine object, with no error until results are missing downstream. - Mixing blocking I/O with async in the same cell.
Synchronous calls like
requests.get()block the event loop, starving concurrent tasks. Useaiohttp,httpx, orasyncio.to_thread().
References
references/notebooks-async.md— event-loop ownership, background-work and fire-and-forget patterns, script/notebook compatibility, blocking-library interop,nest_asynciopolicy
このスキルのファイル
2python-notebooks-async skillに関する質問
Claude Codeにpython-notebooks-async skillをインストールするには
npx degit ahgraber/skills/skills/python-notebooks-async ~/.claude/skills/python-notebooks-asyncを実行してください。Claude Codeは~/.claude/skills(すべてのプロジェクト)または.claude/skills(単一プロジェクト)からskillsを読み込み、説明がタスクに一致する場合にskillを使用します。
python-notebooks-async skillはどのクライアントで使用できますか
Agent Skills形式を読み込むすべてのクライアントで使用できます: Claude Code、Codex、Gemini CLI、claude.ai(ZIPとしてアップロード)。skill内のスクリプトは、クライアントがコード実行を許可した場合にのみ実行されます。
なぜノートブックでasyncio.run()がRuntimeErrorを発生させるのですか?
ノートブックのカーネルは既にイベントループを所有して実行しているため、asyncio.run()を呼び出すと2つ目のループを開始しようとして競合が発生します。代わりにトップレベルのawaitを使用してください。
ノートブックのワークフローでnest_asyncioを使用すべきですか?
nest_asyncioは、設計上の問題や並行処理のバグを隠蔽する可能性があるため、デフォルトとしてではなく、レガシーな理由による限定的な互換性のためのフォールバックとしてのみ使用してください。
ノートブックのセルでイベントループのブロッキングを防ぐにはどうすればよいですか?
requests.get()のような同期的なブロッキングI/Oの使用を避けてください。代わりにaiohttpやhttpxなどの非同期ライブラリを使用するか、同期的な呼び出しをasyncio.to_thread()でラップしてください。