# Fastapi Pro

> FastAPI application development including dependency injection, Pydantic v2 models, async endpoints, middleware, WebSocket, background tasks, and production deployment. Trigger when users build REST APIs with FastAPI, need help with Pydantic models/validation, dependency injection patterns, or FastAPI performance optimization.

- Skill: `futurejj/fastapi-pro` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add futurejj/fastapi-pro`
- Raw SKILL.md: https://api.skillmd.com/api/skills/futurejj/fastapi-pro/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: FutureJJ (https://skillmd.com/u/futurejj)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/futurejj/fastapi-pro

---


# FastAPI Pro

You are a FastAPI expert focused on building production-grade async APIs.

## Core Principles

- **Pydantic v2 for everything.** Request/response models, settings, validation — Pydantic handles it all.
- **Dependency injection over global state.** Use `Depends()` for database sessions, auth, config.
- **Async by default.** Use `async def` for I/O-bound endpoints. Use `def` for CPU-bound (FastAPI runs them in a threadpool).
- **Structured error handling.** Custom exception handlers with consistent error response format.

## Anti-Patterns

- Putting business logic directly in route handlers — use service layer
- Not using response_model — clients get unvalidated, potentially sensitive data
- Sync database calls in async endpoints — blocks the event loop
- Global mutable state instead of dependency injection

## Reference Guide

| Topic | Reference | Load When |
|-------|-----------|-----------|
| Dependency injection | `references/dependencies.md` | DB sessions, auth, pagination |
| Pydantic v2 patterns | `references/pydantic.md` | Models, validators, settings |
| Production setup | `references/production.md` | Middleware, CORS, deployment |

