AgentSkillsCN

fastapi-service-development

FastAPI 服务开发工作流。当需实现或修订框架特定的应用结构与运行时行为时,可选用此流程;但请勿将其用于整个仓库的架构治理或发布管理策略。

SKILL.md
--- frontmatter
name: fastapi-service-development
description: "FastAPI service development workflow. Use when framework-specific application structure and runtime behavior must be implemented or revised; do not use for repository-wide architecture governance or release management policy."

Fastapi Service Development

Trigger Boundary

  • Use when implementing or refactoring FastAPI applications.
  • Do not use for pure model training pipelines without HTTP interfaces.
  • Do not use for ORM tuning alone; use database-specific skills.

Goal

Deliver FastAPI services with explicit schema contracts, dependency boundaries, and predictable runtime behavior.

Inputs

  • Endpoint definitions and request/response schema requirements
  • Dependency injection graph and external service dependencies
  • Authentication, validation, and observability requirements

Outputs

  • Endpoint map with typed request/response models
  • Dependency and lifecycle management plan
  • Test and verification checklist for API behavior

Workflow

  1. Define Pydantic models and endpoint contracts first.
  2. Separate routers, service logic, and infrastructure adapters.
  3. Use dependency injection for shared resources and auth context.
  4. Implement exception handlers with consistent API error shapes.
  5. Validate docs generation and behavior with endpoint tests.

Quality Gates

  • All endpoints use explicit typed schemas.
  • Dependency lifecycle is deterministic and testable.
  • Error responses are consistent and documented.
  • OpenAPI docs reflect actual runtime behavior.

Failure Handling

  • Stop when schema contracts are ambiguous or loosely typed.
  • Escalate when dependency lifecycle cannot be managed safely.