What problem does it solve?
FastAPI projects can become inconsistent, expose sensitive data, or suffer performance and maintainability issues when patterns and newer framework features are not followed. This Skill provides clear conventions and practical guidance to keep FastAPI codebases idiomatic, secure, and performant as the framework and Pydantic evolve.
Core Features & Use Cases
- Annotated parameter and dependency usage: Prefer Annotated for Path/Query/Header and dependency types to keep signatures explicit and reusable.
- Response modeling and serialization: Recommend return types or response_model usage to filter sensitive fields and enable efficient serialization.
- Router and dependency organization: Encourage router-level configuration, shared dependencies, and appropriate dependency scopes including yield-based cleanup.
- Async vs sync guidance and streaming: Provide rules for when to use async, when to run blocking code safely, and patterns for JSON Lines, SSE, and byte streaming.
- Tooling & libraries: Advise on using tooling like linters and Asyncer, and recommended libraries such as SQLModel and HTTPX.
- Use Case: Refactoring a legacy endpoint to use Annotated parameters, a proper Pydantic response model, router-level dependencies, and streaming where appropriate to prevent data leaks and improve throughput.
Quick Start
Refactor an endpoint to use Annotated request parameters, a Pydantic response model, and router-level dependencies so the API validates inputs, hides internal fields, and follows async/sync best practices.