首页/后端开发/fastapi-python
F

fastapi-python

by @mindrallyv1.0.0
4.0(0)

FastAPI Python开发专家,掌握API和异步操作的最佳实践。

FastAPIPythonREST APIAsynchronous ProgrammingBackend DevelopmentGitHub
安装方式
npx skills add mindrally/skills --skill fastapi-python
compare_arrows

Before / After 效果对比

1
使用前

传统Python Web框架在构建高性能异步API时,学习曲线陡峭,开发效率不高。开发者常面临性能瓶颈和复杂代码结构。

使用后

掌握FastAPI最佳实践,能快速构建高性能、易于维护的异步API。利用其强大功能,显著提升开发速度和API响应能力,简化开发流程。

description SKILL.md


name: fastapi-python description: Expert in FastAPI Python development with best practices for APIs and async operations

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 def for pure functions, async def for 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

  1. Rely on FastAPI's dependency injection system
  2. Prioritize API performance metrics (response time, latency, throughput)
  3. Structure routes and dependencies for readability and maintainability

Dependencies

FastAPI, Pydantic v2, asyncpg/aiomysql, SQLAlchemy 2.0

forum用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价,来写第一条吧

统计数据

安装量2.2K
评分4.0 / 5.0
版本1.0.0
更新日期2026年3月16日
对比案例1 组

用户评分

4.0(0)
5
0%
4
0%
3
0%
2
0%
1
0%

为此 Skill 评分

0.0

兼容平台

🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI

时间线

创建2026年3月16日
最后更新2026年3月16日