with one click
fastapi-expert
// Expert level FastAPI implementation focused on performance, clean architecture, and Python-UV integration.
// Expert level FastAPI implementation focused on performance, clean architecture, and Python-UV integration.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | fastapi-expert |
| version | 2.3.0 |
| description | Expert level FastAPI implementation focused on performance, clean architecture, and Python-UV integration. |
| category | development-python |
"Fast, easy to learn, fast to code, ready for production." - This skill ensures your FastAPI code actually lives up to that promise.
This skill operates WITHIN the SDD framework. Before starting any technical execution:
0. Mode Check: Verify the current operational mode (.hub-mode) and apply the token-distiller skill guidelines.
.specs/project/STATE.md, .specs/project/MEMORY.md, and .specs/project/LEARNINGS.md.spec.md file exist with clear requirements and Acceptance Criteria (ACs)? (BDD mandatory for Medium+).plan.md file define the architecture, schemas, and include Mermaid diagrams?contract.md file established with validation sensors?.specs/project/tasks.md (or feature-specific) detailed and atomized?Provide a decision and implementation framework for high-performance APIs, ensuring the correct use of Dependency Injection, Strict Typing (Annotated), and native integration with the python-uv ecosystem.
Define the project structure (Clean Architecture).
Define data contracts using Pydantic V2.
RootModel. Prefer TypeAdapter or structured models.Field(description=...) for automatic documentation.Map dependencies and security (JWT).
Annotated[Type, Depends(func)].Write endpoints and exception handlers.
async def only for truly asynchronous I/O operations.Performance audit and documentation.
async def.Implement unit and integration tests.
from typing import Annotated
from fastapi import Depends, Path
# DO THIS
async def read_item(item_id: Annotated[int, Path(title="The ID of the item")]):
...
# NOT THIS
async def read_item(item_id: int = Path(...)):
...
Always initialize and manage dependencies via python-uv:
uv add fastapi pydantic-settings
uv run fastapi dev main.py
OAuth2PasswordBearer and scopes for access control.... (Ellipsis) in Pydantic models or mandatory parameters.Execution of this skill should result in APIs that follow this recommended file structure:
| Artifact | Location | Description |
|---|---|---|
| Entrypoint | src/main.py | FastAPI initialization and router inclusion. |
| Schemas | src/schemas/ | Pydantic V2 models for request/response. |
| Endpoints | src/api/ | Routers organized by domain (tags). |
| Dependencies | src/dependencies.py | Injectable dependency factory. |
| Config | src/config.py | Environment management via pydantic-settings. |
| Migrations | migrations/ | Database evolution scripts (Alembic). |
For a deep dive into each topic, consult the specialized guides:
| Guide | Topic |
|---|---|
| Architecture | Repositories, Services, and Lifespan. |
| API Design | REST Patterns, Status Codes, and Naming. |
| Security | JWT, OAuth2, and Password Hashing. |
| Error Handling | Domain Exceptions and Global Handlers. |
| Performance | Async vs Sync and Pydantic Rust core. |
| Testing | Pytest, AsyncClient, and Integration Tests. |
| Migrations | Async Alembic and database versioning. |
version: "2.3.0"
feature_id: "HUB-ALIGNMENT"
phase: "VERIFY"
status: "COMPLETED"
last_update: "2026-05-06T13:16:19.359394Z"
evidence_checksum: "8e52f6a"