backend-fastapi-python skill
✓ 検証済みFastAPI、SQLModel、および async SQLAlchemy を使用し、サービス、認証、エラーハンドリングに関する特定のパターンを用いた Python バックエンドの開発を行います。
- GitHubスター
- 126
- ファイル
- 12
- 最終コミット
- 2026年5月16日
- ライセンス
- MIT
- 許可されたツール
- —
backend-fastapi-python skillは何をしますか
FastAPI、SQLModel、および async SQLAlchemy を使用し、サービス、認証、エラーハンドリングに関する特定のパターンを用いた Python バックエンドの開発を行います。
skillのSKILL.mdから生成された要約。
backend-fastapi-python skill について
FastAPI、SQLModel、および async SQLAlchemy を使用した Python バックエンドの構築が、この SKILL の主な機能です。開発者はこれを使用して、API エンドポイントの構築、ステートレスなサービス関数の記述、および Pydantic や SQLModel スキーマの定義を行います。具体的には、get_current_user や is_superuser のような認証依存関係のチェーンの設定、async SQLAlchemy セッションの管理、Alembic マイグレーションの処理など、バックエンドのアーキテクチャに関するタスク向けに設計されています。
Python API コード、リクエスト/レスポンス設計、またはこのコードベース内のバックエンドパターンに関連するタスクが発生する場合、エージェントはこの SKILL をロードする必要があります。この SKILL は、ApiResponse[T] ラッパーの使用や、エラーコードのための AppException の実装など、プロジェクト固有の規約に関するガイダンスを提供します。また、selectinload による N+1 クエリの回避、バックグラウンドタスクの管理、Pydantic V2 バリデータの正しい使用方法といった技術的な制約への対応を支援します。フロントエンド開発、Docker、CI/CD、または一般的なインフラストラクチャについては対象外です。
エージェントができること
- 1セキュアな API エンドポイントの実装ロールベースのアクセス制御のために依存性の注入(dependency injection)を使用する FastAPI ルートを作成します。
- 2データベーススキーマとマイグレーションの管理ORM モデルを定義し、Alembic マイグレーションを実行してデータベース構造を更新します。
- 3ステートレスなサービスレイヤーの開発async セッションを使用してデータベースとやり取りするサービス関数を記述します。
- 4API レスポンスの問題のデバッグ特定のフィールドが API レスポンスに含まれない理由や、422 エラーが発生する原因のトラブルシューティングを行います。
skill の SKILL.md から作成されています。すべてのユースケースは、その引用と照合されています。
backend-fastapi-python skillのインストール方法
各コマンドはskillフォルダをクライアントのskillsディレクトリにコピーします。読み込むには、クライアントを再起動するか新しいセッションを開始してください。Claude Codeにbackend-fastapi-python skillをインストールする
~/.claude/skills/backend-fastapi-python/SKILL.md
$ npx degit avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python ~/.claude/skills/backend-fastapi-pythonClaude Code (project)にbackend-fastapi-python skillをインストールする
.claude/skills/backend-fastapi-python/SKILL.md
$ npx degit avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python .claude/skills/backend-fastapi-pythonCodexにbackend-fastapi-python skillをインストールする
~/.agents/skills/backend-fastapi-python/SKILL.md
$ npx degit avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python ~/.agents/skills/backend-fastapi-pythonGemini CLIにbackend-fastapi-python skillをインストールする
~/.gemini/skills/backend-fastapi-python/SKILL.md
$ npx degit avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python ~/.gemini/skills/backend-fastapi-pythonClaude.aiにbackend-fastapi-python skillをインストールする
npx degit avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python backend-fastapi-python && zip -r backend-fastapi-python.zip backend-fastapi-python # claude.ai → Customize → Skills → + → Create skill → Upload a skill → backend-fastapi-python.zip
自動チェック
実行日 2026年11月16日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。エージェントに実行させる前にスクリプトを読んでください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python is public and reachablegithub.com/avibebuilder/claude-prime/tree/HEAD/.claude/start ↗合格
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit 2026-05-16github.com/avibebuilder/claude-prime/commits ↗合格
- スクリプトにダウンロード実行や認証情報の窃取がないNo scripts in the skill folder合格
- SKILL.md に隠れた指示がないNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/avibebuilder/claude-prime/blob/HEAD/.claude/start ↗合格
- 事前許可ツールが限定されているNo pre-approved tools; the agent asks before using onegithub.com/avibebuilder/claude-prime/blob/HEAD/.claude/start ↗合格
- SKILL.md が Agent Skills の形式に従っているValid name and description; says when to use it; 47 linesgithub.com/avibebuilder/claude-prime/blob/HEAD/.claude/start ↗合格
SKILL.md
GitHubで表示Backend FastAPI Python
Project-specific conventions for FastAPI with SQLModel, pydantic-settings, and async SQLAlchemy.
Architecture Decisions
- Services are stateless functions — Not classes. First param is
db: AsyncSession. - Generic response wrapper — Always use
ApiResponse[T]for consistency. - Dependencies chain —
get_current_user->require_auth->require_admin. - Module-scoped config — Each module can have its own
{module}_config.py. - Error codes for frontend —
AppException(status, message, error_code).
Gotchas
- SQLModel
Relationship()fields are NOT included in API responses by default. You must explicitly add them tomodel_configor use a separate response schema with those fields. AsyncSession.refresh()does not load relationships. After commit, re-query with.options(selectinload(...))if you need related objects.- Pydantic V2 uses
model_validatornotvalidator. The@validatordecorator is V1 and will break silently or raise deprecation warnings. Depends()in FastAPI creates a NEW instance per request — don't store state in dependency return values expecting it to persist.- Background tasks (
BackgroundTasks) run AFTER the response is sent. If they fail, the client already got a 200. Use proper task queues (Celery, ARQ) for anything that must not silently fail. - Alembic
--autogeneratemisses: table renames (generates drop+create), index changes on existing columns, andEnumtype modifications in PostgreSQL. Always review generated migrations. async defendpoints block the event loop if you call sync I/O inside them. Userun_in_executorfor sync libraries or define the endpoint asdef(FastAPI runs sync endpoints in a threadpool).HTTPExceptionfrom FastAPI andHTTPExceptionfrom Starlette are different classes. Importing the wrong one causes middleware to miss exception handlers.- SQLAlchemy's
lazy="selectin"on relationships causes N+1 queries in async sessions. Use explicitselectinload()in queries instead. Optional[str] = Nonein query params makes the field optional.str = Nonealso works but loses type information — prefer the explicitOptionalform.- When using
response_model, FastAPI filters OUT any fields not in the model. If your response is missing data, check that the response model includes all fields, not just the ORM model.
References
| When you need... | Read |
|---|---|
| Directory layout | file-structure.md |
| Settings and env vars | configuration.md |
| Database sessions and connections | database.md |
| ORM models | models.md |
| Request/response schemas | schemas.md |
| Router and endpoint patterns | routing.md |
| Service layer patterns | services.md |
| Dependency injection | dependencies.md |
| Middleware setup | middleware.md |
| Error handling | error-handling.md |
| Auth flow example | auth.md |
このスキルのファイル
12backend-fastapi-python skillに関する質問
Claude Codeにbackend-fastapi-python skillをインストールするには
npx degit avibebuilder/claude-prime/.claude/starter-skills/backend-fastapi-python ~/.claude/skills/backend-fastapi-pythonを実行してください。Claude Codeは~/.claude/skills(すべてのプロジェクト)または.claude/skills(単一プロジェクト)からskillsを読み込み、説明がタスクに一致する場合にskillを使用します。
backend-fastapi-python skillはどのクライアントで使用できますか
Agent Skills形式を読み込むすべてのクライアントで使用できます: Claude Code、Codex、Gemini CLI、claude.ai(ZIPとしてアップロード)。skill内のスクリプトは、クライアントがコード実行を許可した場合にのみ実行されます。
このプロジェクトにおけるサービス関数の構造はどのようにすべきですか?
サービスはクラスではなくステートレスな関数として実装してください。また、第一引数は常に AsyncSession とします。
API レスポンスに SQLModel のリレーションシップ・フィールドが含まれていない場合はどうすればよいですか?
SQLModel の Relationship フィールドはデフォルトでは含まれません。model_config に明示的に追加するか、別のレスポンス用スキーマを使用する必要があります。
サイレントに失敗してはいけないバックグラウンドタスクはどのように扱えばよいですか?
BackgroundTasks はレスポンス送信後に実行されるため、失敗が許されない重要なタスクには Celery や ARQ などの適切なタスクキューを使用してください。
AsyncSession.refresh() の後にリレーション先のオブジェクトをロードする正しい方法は何ですか?
refresh() ではリレーションシップがロードされないため、.options(selectinload(...)) を使用してオブジェクトを再クエリし、関連データを取得する必要があります。