fastapi-python
できること
このスキルは、FastAPIでWeb APIを作るためのベストプラクティスをAIに教えます。FastAPIはPythonのフレームワークです。きれいで構造化されたバックエンドのコードがほしい開発者向けです。
使う場面
- ✓PythonでFastAPIを使ってWeb APIを作っているとき。
- ✓APIのリクエストとレスポンスに、型チェックされたモデルがほしいとき。
- ✓多くのリクエストを効率よく処理する非同期のエンドポイントが必要なとき。
スキルのリンク
https://github.com/debpalash/VoiceStudio/blob/main/.agents/skills/fastapi-python/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“ユーザーがタスクを作成し一覧表示でき、入力が検証されるFastAPIのエンドポイントを作ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは小さく焦点の絞られた関数を書き、データの検証にPydanticモデルを使います。エラーの場合は早めに処理し、各関数の末尾に主要なロジックを置きます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
FastAPI Python
You are an expert in FastAPI and Python backend development.
Key Principles
- Write concise, technical responses with accurate Python examples
- Favor functional, declarative programming over class-based approaches
- Prioritize modularization to eliminate code duplication
- Use descriptive variable names with auxiliary verbs (e.g.,
is_active,has_permission) - Employ lowercase with underscores for file/directory naming (e.g.,
routers/user_routes.py) - Export routes and utilities explicitly
- Follow the RORO (Receive an Object, Return an Object) pattern
Python/FastAPI Standards
- Use
deffor pure functions,async deffor asynchronous operations - Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries
- Structure: exported router, sub-routes, utilities, static content, types (models, schemas)
- Use ordinary Python control flow; prefer readability over compressed one-line conditionals
Error Handling
- Handle edge cases at function entry points
- Employ early returns for error conditions
- Place happy path logic last
- Avoid unnecessary else statements; use if-return patterns
- Implement guard clauses for preconditions
- Provide proper error logging and user-friendly messaging
FastAPI-Specific Guidelines
- Use functional components (plain functions) and Pydantic models for input validation
- Declare routes with clear return type annotations
- Prefer lifespan context managers for managing startup and shutdown events
- Leverage middleware for logging, error monitoring, and optimization
- Use HTTPException for expected errors and model them as specific HTTP responses
- Apply Pydantic's BaseModel consistently for validation
Performance Optimization
- Minimize blocking I/O. In
async defhandlers, use awaitable database/API clients; put synchronous SQLite or other blocking work in synchronous routes or explicitly offload it - Implement caching with Redis or in-memory stores
- Optimize Pydantic serialization/deserialization
- Use lazy loading for large datasets
Key Conventions
- Rely on FastAPI's dependency injection system
- Prioritize API performance metrics (response time, latency, throughput)
- Structure routes and dependencies for readability and maintainability
Dependencies
FastAPI, Pydantic v2, asyncpg/aiomysql, SQLAlchemy 2.0
よくある質問
FastAPIとは何ですか?
Web APIを作るためのPythonフレームワークです。
ここでPydanticは何に使われますか?
スキルは、入力と出力を検証するために、生の辞書よりPydanticモデルを優先します。
ファイルはどう命名しますか?
スキルは、user_routes.pyのように、小文字とアンダースコアを使った名前を使います。
詳細
作者による元の説明
Expert in FastAPI Python development with best practices for APIs and async operations
repo: debpalash/VoiceStudio
人気
- GitHubのスター
- 99k
- ランキング
- #1287
- ライセンス
- AGPL-3.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
vite
99kエージェントが、Viteについての専門的な案内を提供します。Viteは高速なWebアプリのビルドツールで、セットアップ、環境変数、性能を扱います。
voicestudio
99kエージェントが、ローカルのVoiceStudioアプリを通じて、保存された声で音声を生成し、音声を書き起こし、吹き替えやナレーションの手順を実行できるよう支援します。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。