跳到正文
cccskills
免费在 GitHub 公开

fastapi-python

Build Python APIs with FastAPI using clear routes, validated inputs, and consistent error handling. It guides asynchronous database and API calls, reusable dependencies, caching, and code organization to support readable implementations and responsive services.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Expert in FastAPI Python development with best practices for APIs and async operations

查看安装方法

适用场景

  • Designing API routes and input validation
  • Reviewing asynchronous database and API calls
  • Organizing error handling and logging
  • Improving response performance with caching

包含的文件(1)

  • SKILL.md2.4 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

vite

免费

Set up and refine web projects with Vite, a tool for running development servers and building production files. It covers framework integration, environment settings, live code updates, testing configuration, and splitting code to improve loading.

中文简介正在准备中。当前显示英语简介。

  • Setting up React, Vue, or Svelte projects
  • Configuring environment variables and API proxies
  • Splitting production code into smaller files
debpalash/VoiceStudio7.7万2026年10月19日 更新

Connect agents and automated workflows to VoiceStudio to generate speech with saved or designed voices, transcribe recordings, create subtitles, and manage dubbing or narration. It uses the running backend and checks available models and capabilities.

中文简介正在准备中。当前显示英语简介。

  • Generating narration with a saved voice
  • Transcribing recordings and creating subtitles
  • Managing dubbing while preserving timing and background audio
debpalash/VoiceStudio7.7万2026年10月19日 更新

Maintain VoiceStudio by investigating reported bugs, reviewing contributed changes, diagnosing automated check failures, and preparing requested releases. It guides focused fixes, testing, and packaging verification for the Electron app and Python backend.

中文简介正在准备中。当前显示英语简介。

  • Investigating reported VoiceStudio bugs
  • Reviewing contributor pull requests
  • Diagnosing automated check failures
debpalash/VoiceStudio7.7万2026年10月19日 更新

查看 debpalash 的全部技能

报告此技能的问题