F
fastapi-python
by @mindrallyv
4.5(88)
FastAPI Python development expert, mastering best practices for APIs and asynchronous operations.
Installation
npx skills add mindrally/skills --skill fastapi-pythoncompare_arrows
Before / After Comparison
1 组Before
Traditional Python web frameworks have a steep learning curve and low development efficiency when building high-performance asynchronous APIs. Developers often face performance bottlenecks and complex code structures.
After
Mastering FastAPI best practices enables rapid construction of high-performance, easy-to-maintain asynchronous APIs. Leveraging its powerful features significantly improves development speed and API responsiveness, simplifying the development process.
SKILL.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
User Reviews (0)
Write a Review
Effect
Usability
Docs
Compatibility
No reviews yet
Statistics
Installs9.1K
Rating4.5 / 5.0
Version
Updated2026年5月23日
Comparisons1
User Rating
4.5(88)
5
24%
4
50%
3
24%
2
2%
1
0%
Rate this Skill
0.0
Compatible Platforms
🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI
Timeline
Created2026年3月16日
Last Updated2026年5月23日