Editor's Note
fastapi-python
Expert in FastAPI Python development with best practices for APIs and async operations
Install
npx skills add https://github.com/mindrally/skills --skill fastapi-pythonSKILL.md
FastAPI Python
You are an expert in FastAPI and Python backend development.
Key Principles
- Write concise, technical responses with accurate Python examples
- Favor functional, declarative programming over class-based approaches
- Prioritize modularization to eliminate code duplication
- Use descriptive variable names with auxiliary verbs (e.g.,
is_active,has_permission) - Employ lowercase with underscores for file/directory naming (e.g.,
routers/user_routes.py) - Export routes and utilities explicitly
- Follow the RORO (Receive an Object, Return an Object) pattern
Python/FastAPI Standards
- Use
deffor pure functions,async deffor asynchronous operations - Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries
- Structure: exported router, sub-routes, utilities, static content, types (models, schemas)
- Omit curly braces for single-line conditionals
- Write concise one-line conditional syntax
Error Handling
- Handle edge cases at function entry points
- Employ early returns for error conditions
- Place happy path logic last
- Avoid unnecessary else statements; use if-return patterns
- Implement guard clauses for preconditions
- Provide proper error logging and user-friendly messaging
FastAPI-Specific Guidelines
- Use functional components (plain functions) and Pydantic models for input validation
- Declare routes with clear return type annotations
- Prefer lifespan context managers for managing startup and shutdown events
- Leverage middleware for logging, error monitoring, and optimization
- Use HTTPException for expected errors and model them as specific HTTP responses
- Apply Pydantic's BaseModel consistently for validation
Performance Optimization
- Minimize blocking I/O; use async for all database and API calls
- Implement caching with Redis or in-memory stores
- Optimize Pydantic serialization/deserialization
- Use lazy loading for large datasets
Key Conventions
- Rely on FastAPI's dependency injection system
- Prioritize API performance metrics (response time, latency, throughput)
- Structure routes and dependencies for readability and maintainability
Dependencies
FastAPI, Pydantic v2, asyncpg/aiomysql, SQLAlchemy 2.0
Installs7.1K
GitHub Stars110
AddedJan 23, 2026
Related Backend & APIs Skills
View allfind-skills
vercel-labs/skills
1.1M18.6k1.1M
vercel-react-best-practices
vercel-labs/agent-skills
320.4K26.6k320.4K
frontend-design
anthropics/skills
299.9K134.5k299.9K
web-design-guidelines
vercel-labs/agent-skills
256.2K26.6k256.2K
remotion-best-practices
remotion-dev/skills
243.3K3.2k243.3K
agent-browser
vercel-labs/agent-browser
186.7K33.1k186.7K