Agent skill · software engineering · aiskillstore

py-fastapi-patterns

FastAPI patterns for API design. Use when creating endpoints, handling dependencies, error handling, or working with OpenAPI schemas.

Why this skill is useful

Provides specific FastAPI patterns for dependency injection, response models, and error handling that enhance API design and integration.

What it needs

About 4k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

FastAPI Patterns Problem Statement FastAPI API design directly affects frontend. Bad patterns here cause frontend bugs, poor developer experience, and integration issues. The OpenAPI schema drives frontend code generation. --- Pattern: Dependency Injection Problem: Repetitive code for auth, sessions, and services. Dependency chain: getsession → getcurrentuser → getcurrentactiveuser --- Pattern: Response Models Problem: Inconsistent responses, exposing internal fields, poor OpenAPI docs. Why responsemodel matters: 1. Filters output to only specified fields 2. Generates accurate OpenAPI schema 3. Frontend Orval codegen depends on this --- Pattern: Error Handling Problem: Inconsistent error responses, missing context. HTTP Status Codes: Code Use For ------ --------- 200 Successful GET, PUT, PATCH 201 Successful POST (created) 204 Successful DELETE (no content) 400 Bad request (malformed) 401 Unauthorized (not authenticated) 403 Forbidden (authenticated but not allowed) 404 Not found 422 Validation error 500 Server error --- Pattern: Route Ordering Problem: FastAPI matches first route. Order matters for overlapping paths. Remember: Always define specific routes before generic parameterized routes. --- Pattern: Path and Query Parameters --- Pattern: Request Body Validation --- Pattern: Middleware Problem: Cross-cutting concerns like logging, CORS, timing. --- Pattern: OpenAPI Schema Problem: Schema affects frontend codegen. Keep it clean. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/py-fastapi-patterns

View the source on GitHub

Browse the @skills marketplace