AGENT SKILL

fastapi-standards

Use when building a FastAPI service in a touchstone repo — routers, dependencies, pydantic schemas, async endpoints, serving. Triggers on `fastapi` in pyproject/imports, `APIRouter`, `app = FastAPI()`. Language rules live in the python skill.

License 许可
MIT
所属仓库
hwanngo/touchstone
最近更新
2026-08-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
fastapi-standards
license
MIT
metadata
{ "author": "touchstone", "version": "0.2.0" }
description
Use when building a FastAPI service in a touchstone repo — routers, dependencies, pydantic schemas, async endpoints, serving. Triggers on `fastapi` in pyproject/imports, `APIRouter`, `app = FastAPI()`. Language rules live in the python skill.

03 SKILL.md 正文

FastAPI (framework)

Full standard: standards/frameworks/fastapi.md (layers on standards/languages/python.md). Rules:

Always

  • Domain/module structure (src/<domain>/{router,schemas,service,deps}), NOT file-type folders.
  • Sync vs async routes: async def only for non-blocking I/O; blocking I/O → plain def (FastAPI runs it in a threadpool); CPU-bound → a worker. Don't make everything async.
  • Pydantic v2 request/response/db schemas separated; response_model; never return ORM objects raw. Settings via pydantic-settings.
  • DI via Depends (db session per request, auth, pagination); yield deps for cleanup; override in tests.

Defer (don't duplicate)

  • API contract/errors → ../../standards/design/api-design.md; DB + Alembic → ../../standards/platform/database.md; authN/authZ → ../../standards/practices/app-security.md; async correctness → ../../standards/languages/python.md.

Done

ruff/pyright/pytest green · domain modules · async routes correct · OpenAPI versioned. See the doc.

04 同仓库更多 Skills