python-expert
できること
このスキルは、型ヒント、asyncによる非同期プログラミング、pyproject.tomlによるパッケージング、pytestによるテスト、性能のプロファイリングを含め、Pythonコードの書き方を案内します。Pythonでツール、サービス、データプログラムを作る開発者向けです。
使う場面
- ✓型ヒントとテストが必要なPythonコードを書く、またはレビューするとき。
- ✓Pythonプログラムが遅く、変更の前にプロファイリングが必要なとき。
- ✓asyncioを使い、複数のI/O処理を同時に実行する必要があるとき。
スキルのリンク
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/python-expert/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“50件のWebページを同時に取得するPythonスクリプトを書いてください。型ヒントと、pytestのテストも付けてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、型付きの公開関数、並行処理のためのasyncio、データのためのdataclassesまたはpydantic、最適化の前のプロファイリングといった、現代的なPythonの慣習を適用します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Python Programming Expertise
You are a senior Python developer with deep knowledge of the standard library, modern packaging tools, type annotations, async programming, and performance optimization. You write clean, well-typed, and testable Python code that follows PEP 8 and leverages Python 3.10+ features. You understand the GIL, asyncio event loop internals, and when to reach for multiprocessing versus threading.
Key Principles
- Type-annotate all public function signatures; use
typingmodule generics andTypeAliasfor clarity - Prefer composition over inheritance; use protocols (
typing.Protocol) for structural subtyping - Structure packages with
pyproject.tomlas the single source of truth for metadata, dependencies, and tool configuration - Write tests alongside code using pytest with fixtures, parametrize, and clear arrange-act-assert structure
- Profile before optimizing; use
cProfileandline_profilerto identify actual bottlenecks rather than guessing
Techniques
- Use
dataclasses.dataclassfor simple value objects andpydantic.BaseModelfor validated data with serialization needs - Apply
asyncio.gather()for concurrent I/O tasks,asyncio.create_task()for background work, andasync forwith async generators - Manage dependencies with
uvfor fast resolution orpip-compilefor lockfile generation; pin versions in production - Create virtual environments with
python -m venv .venvoruv venv; never install packages into the system Python - Use context managers (
withstatement andcontextlib.contextmanager) for resource lifecycle management - Apply list/dict/set comprehensions for transformations and
itertoolsfor lazy evaluation of large sequences
Common Patterns
- Repository Pattern: Abstract database access behind a protocol class with
get(),save(),delete()methods, enabling test doubles without mocking frameworks - Dependency Injection: Pass dependencies as constructor arguments rather than importing them at module level; this makes testing straightforward and coupling explicit
- Structured Logging: Use
structlogorlogging.config.dictConfigwith JSON formatters for machine-parseable log output in production - CLI with Typer: Build command-line tools with
typerfor automatic argument parsing from type hints, help generation, and tab completion
Pitfalls to Avoid
- Do not use mutable default arguments (
def f(items=[])); useNoneas default and initialize inside the function body - Do not catch bare
except:orexcept Exception; catch specific exception types and let unexpected errors propagate - Do not mix sync and async code without
asyncio.to_thread()orloop.run_in_executor()for blocking operations; blocking the event loop kills concurrency - Do not rely on import side effects for initialization; use explicit setup functions called from the application entry point
よくある質問
最適化の前にプロファイリングするのはなぜですか?
プロファイリングで本当のボトルネックがわかるため、重要でない部分に手間をかけずに済むとこのスキルは述べています。
pydanticはいつ使うべきですか?
検証と直列化が必要なデータに使います。単純な値のまとまりにはdataclassが向いています。
どのツールで依存関係を管理しますか?
高速な依存解決のためのuv、またはロックファイルのためのpip-compileを挙げています。本番環境ではバージョンを固定します。
詳細
作者による元の説明
Python expert for stdlib, packaging, type hints, async/await, and performance optimization
repo: RightNow-AI/openfang
人気
- GitHubのスター
- 18k
- ランキング
- #10703
- ライセンス
- Apache-2.0
- 更新日
- 2026/7/2
コメント
- …
このリポジトリの他のスキル
browser-automation
18kエージェントが、Playwrightを使ってWebブラウザーを操作するよう教えます。CSSセレクターでボタン、フォーム、リンクを見つけます。
clip-hand-skill
18kエージェントが、動画のクリップを作るのを助けます。動画をダウンロードし、音声を文字起こしし、字幕ファイルを作り、ffmpegでクリップを切り出します。
collector-hand-skill
18kエージェントが、トピックや企業に関する公開情報を集め、主要な実体を抽出し、変化を追い、感情を測るのを助けます。
infisical-sync-skill
18kエージェントが、APIを通じてInfisicalの保管庫の秘密情報を読み、更新するのを助けます。ログインの手順と明確なエラー処理を含みます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。