
Fastapi
Stand up a production-style async Python REST API with FastAPI, Pydantic validation, and JWT auth without hitting the usual async, CORS, and 422 traps.
Overview
FastAPI is an agent skill for the Build phase that teaches production-ready patterns for Python REST APIs with Pydantic v2, async SQLAlchemy, JWT auth, testing, and deployment.
Install
npx skills add https://github.com/jezweb/claude-skills --skill fastapiWhat is this skill?
- uv-based project initialization and domain-oriented folder layout for maintainable APIs
- Pydantic v2 schemas with constraints aligned to request/response bodies to prevent 422 mismatches
- SQLAlchemy 2.0 async sessions and non-blocking async patterns (e.g. avoid blocking the event loop)
- JWT authentication with OAuth2PasswordBearer and python-jose-style flows
- pytest with async HTTP client plus Uvicorn/Gunicorn deployment patterns
- Covers seven capability areas: project setup, structure, validation, database, authentication, testing, and deployment
- Documents four known-issue classes with symptom-to-prevention mapping (blocking async, 422, CORS, optional fields)
Adoption & trust: 2k installs on skills.sh; 841 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are building a Python API but keep hitting 422 validation mismatches, CORS failures, async blocking hangs, or auth wiring that does not match FastAPI expectations.
Who is it for?
Solo builders creating or refactoring async FastAPI backends with SQL databases and token-based auth.
Skip if: Teams standardizing on Django-only stacks, non-Python backends, or frontends that need no custom API layer.
When should I use this skill?
User mentions FastAPI, Python API, Pydantic, uvicorn, async Python, JWT, SQLAlchemy async, or errors like 422, CORS policy, Field required, or async blocking.
What do I get? / Deliverables
Your agent applies a consistent FastAPI project layout, schemas, async DB sessions, JWT setup, and test/deploy patterns so the API behaves predictably in dev and production.
- Domain-structured FastAPI app layout
- Pydantic schemas and auth/test patterns
- Deployment-oriented ASGI configuration guidance
Recommended Skills
Journey fit
API structure, persistence, and auth patterns are core backend build work before you ship. The skill targets server-side FastAPI apps (routes, schemas, SQLAlchemy async, OAuth2/JWT)—not frontend or launch distribution.
How it compares
Structured FastAPI backend playbook for agents—not a generic Python snippet dump or an OpenAPI-only generator with no runtime patterns.
Common Questions / FAQ
Who is fastapi for?
Indie and solo developers using Claude Code, Cursor, or similar agents to build or fix Python REST APIs on FastAPI with async data access and JWT.
When should I use fastapi?
During Build when scaffolding routes and Pydantic models, wiring SQLAlchemy async, fixing 422/CORS/async-blocking issues, or adding OAuth2/JWT before you move to Ship testing.
Is fastapi safe to install?
Treat it like any third-party skill: review the Security Audits panel on this Prism page and inspect the repo before letting an agent run install or shell commands from bundled examples.
SKILL.md
READMESKILL.md - Fastapi
{ "name": "fastapi", "description": "Optional[str] # Still required!", "version": "1.0.0", "author": { "name": "Jeremy Dawes", "email": "jeremy@jezweb.net" }, "license": "MIT", "repository": "https://github.com/jezweb/claude-skills", "keywords": [] } # FastAPI Skill **Status**: Production Ready **Last Updated**: December 2025 ## Auto-Trigger Keywords ### Primary - FastAPI - Python API - Pydantic - uvicorn ### Secondary - async Python - SQLAlchemy async - Python REST API - JWT Python - python-jose - ASGI - Starlette ### Error-Based - "422 Unprocessable Entity" - "CORS policy" - "Field required" - "validation error" - "async blocking" ## What This Skill Does Provides production-tested patterns for building Python APIs with FastAPI: - **Project Setup**: uv-based project initialization - **Structure**: Domain-based organization for maintainability - **Validation**: Pydantic v2 schemas with proper constraints - **Database**: SQLAlchemy 2.0 async with proper session handling - **Authentication**: JWT with OAuth2PasswordBearer - **Testing**: pytest with async client - **Deployment**: Uvicorn/Gunicorn patterns ## Known Issues Prevented | Issue | Symptom | Prevention | |-------|---------|------------| | Blocking async | All requests hang | Use `asyncio.sleep()` not `time.sleep()` | | 422 errors | Validation failures | Proper Pydantic schema matching | | CORS blocked | Browser errors | CORSMiddleware configuration | | Optional fields required | "Field required" error | Use `str \| None = None` pattern | | Circular imports | Import errors | Domain-based structure | ## When to Use - Creating new Python APIs - Setting up FastAPI projects from scratch - Implementing JWT authentication - Configuring async SQLAlchemy - Debugging validation or CORS errors ## When NOT to Use - Simple scripts (overkill) - Flask projects (use flask skill instead) - Synchronous-only requirements - Django projects ## Version Info | Package | Version | |---------|---------| | FastAPI | 0.123.2 | | Pydantic | 2.11.7 | | SQLAlchemy | 2.0.30 | | Uvicorn | 0.35.0 | | python-jose | 3.3.0 | ## Quick Start ```bash uv init my-api && cd my-api uv add fastapi[standard] sqlalchemy[asyncio] aiosqlite uv run fastapi dev src/main.py ``` ## Resources - `SKILL.md` - Full documentation - `templates/` - Ready-to-use project files --- name: fastapi description: | Build Python APIs with FastAPI, Pydantic v2, and SQLAlchemy 2.0 async. Covers project structure, JWT auth, validation, and database integration with uv package manager. Prevents 7 documented errors. Use when: creating Python APIs, implementing JWT auth, or troubleshooting 422 validation, CORS, async blocking, form data, background tasks, or OpenAPI schema errors. user-invocable: true --- # FastAPI Skill Production-tested patterns for FastAPI with Pydantic v2, SQLAlchemy 2.0 async, and JWT authentication. **Latest Versions** (verified January 2026): - FastAPI: 0.128.0 - Pydantic: 2.11.7 - SQLAlchemy: 2.0.30 - Uvicorn: 0.35.0 - python-jose: 3.3.0 **Requirements**: - Python 3.9+ (Python 3.8 support dropped in FastAPI 0.125.0) - Pydantic v2.7.0+ (Pydantic v1 support completely removed in FastAPI 0.128.0) --- ## Quick Start ### Project Setup with uv ```bash # Create project uv init my-api cd my-api # Add dependencies uv add fastapi[standard] sqlalchemy[asyncio] aiosqlite python-jose[cryptography] passlib[bcrypt] # Run development server uv run fastapi dev src/main.py ``` ### Minimal Working Example ```python # src/main.py from fastapi import FastAPI from pydantic import BaseModel app = FastAPI(title="My API") class Item(BaseModel): name: str price: float @app.get("/") async def root(): return {"message": "Hello World"} @app.post("/items") async def create_item(item: Item): return item ``` Run: `uv run fastapi dev src/main.py` Docs available at: `http://127.0.0.1:8000/docs` --- ## Project Structure (Domain-Based) For maintainable projects, org