Agent Skillsdebpalash/VoiceStudio › fastapi-python

fastapi-python

GitHub

提供FastAPI和Python后端开发的最佳实践指南,涵盖异步操作、Pydantic模型验证、RORO模式及性能优化,辅助构建高性能、模块化的RESTful API。

.agents/skills/fastapi-python/SKILL.md debpalash/VoiceStudio

Trigger Scenarios

需要编写或优化FastAPI接口代码 询问Python后端架构与最佳实践

Install

npx skills add debpalash/VoiceStudio --skill fastapi-python -g -y
More Options

Non-standard path

npx skills add https://github.com/debpalash/VoiceStudio/tree/main/.agents/skills/fastapi-python -g -y

Use without installing

npx skills use debpalash/VoiceStudio@fastapi-python

指定 Agent (Claude Code)

npx skills add debpalash/VoiceStudio --skill fastapi-python -a claude-code -g -y

安装 repo 全部 skill

npx skills add debpalash/VoiceStudio --all -g -y

预览 repo 内 skill

npx skills add debpalash/VoiceStudio --list

SKILL.md

Frontmatter
{
    "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)
  • Use ordinary Python control flow; prefer readability over compressed one-line conditionals

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. In async def handlers, use awaitable database/API clients; put synchronous SQLite or other blocking work in synchronous routes or explicitly offload it
  • 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

Version History

  • 032c5ab Current 2026-08-27 20:11

Same Skill Collection

.agents/skills/vite/SKILL.md
skills/omnivoice/SKILL.md
skills/oss-maintainer/SKILL.md
.claude/skills/omnivoice/SKILL.md

Metadata

Files
0
Version
6d42d22
Hash
bb3edfdc
Indexed
2026-08-27 20:11

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-03 05:21
浙ICP备14020137号-1 $mapa de visitantes$