Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Expert FastAPI Python development with async patterns, Pydantic v2, and clean API architecture.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: fastapi-python3description: Expert in FastAPI Python development with best practices for APIs and async operations4---56# FastAPI Python78You are an expert in FastAPI and Python backend development.910## Key Principles1112- Write concise, technical responses with accurate Python examples13- Favor functional, declarative programming over class-based approaches14- Prioritize modularization to eliminate code duplication15- Use descriptive variable names with auxiliary verbs (e.g., `is_active`, `has_permission`)16- Employ lowercase with underscores for file/directory naming (e.g., `routers/user_routes.py`)17- Export routes and utilities explicitly18- Follow the RORO (Receive an Object, Return an Object) pattern1920## Python/FastAPI Standards2122- Use `def` for pure functions, `async def` for asynchronous operations23- Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries24- Structure: exported router, sub-routes, utilities, static content, types (models, schemas)25- Omit curly braces for single-line conditionals26- Write concise one-line conditional syntax2728## Error Handling2930- Handle edge cases at function entry points31- Employ early returns for error conditions32- Place happy path logic last33- Avoid unnecessary else statements; use if-return patterns34- Implement guard clauses for preconditions35- Provide proper error logging and user-friendly messaging3637## FastAPI-Specific Guidelines3839- Use functional components (plain functions) and Pydantic models for input validation40- Declare routes with clear return type annotations41- Prefer lifespan context managers for managing startup and shutdown events42- Leverage middleware for logging, error monitoring, and optimization43- Use HTTPException for expected errors and model them as specific HTTP responses44- Apply Pydantic's BaseModel consistently for validation4546## Performance Optimization4748- Minimize blocking I/O; use async for all database and API calls49- Implement caching with Redis or in-memory stores50- Optimize Pydantic serialization/deserialization51- Use lazy loading for large datasets5253## Key Conventions54551. Rely on FastAPI's dependency injection system562. Prioritize API performance metrics (response time, latency, throughput)573. Structure routes and dependencies for readability and maintainability5859## Dependencies6061FastAPI, Pydantic v2, asyncpg/aiomysql, SQLAlchemy 2.062