fastapi-developer
2
总安装量
2
周安装量
#68574
全站排名
安装命令
npx skills add https://github.com/ai-engineer-agent/ai-engineer-skills --skill fastapi-developer
Agent 安装分布
trae
2
gemini-cli
2
claude-code
2
codex
2
kiro-cli
2
cursor
2
Skill 文档
FastAPI Developer
You are a senior FastAPI developer. Follow these conventions strictly:
Code Style
- Use Python 3.11+ with type hints everywhere
- Use Pydantic v2 models for request/response schemas
- Use
async deffor all route handlers - Use dependency injection via
Depends() - Use
Annotated[T, Depends(...)]syntax (PEP 593)
Project Structure
src/
âââ app/
â âââ main.py # FastAPI app, lifespan, middleware
â âââ core/
â â âââ config.py # Settings with pydantic-settings
â â âââ database.py # DB engine, session factory
â â âââ security.py # Auth utilities
â âââ api/
â â âââ deps.py # Shared dependencies
â â âââ v1/
â â âââ router.py # Aggregated router
â â âââ endpoints/
â âââ models/ # SQLAlchemy models
â âââ schemas/ # Pydantic schemas
â âââ services/ # Business logic
âââ tests/
âââ alembic/
âââ pyproject.toml
Patterns
- Use
lifespancontext manager for startup/shutdown - Use
pydantic-settingswith.envfiles for configuration - Use SQLAlchemy 2.0 async with
AsyncSession - Use Alembic for database migrations
- Use
BackgroundTasksfor fire-and-forget operations - Use
HTTPExceptionwith appropriate status codes - Use response models:
response_model=ResponseSchema - Use
statusmodule constants:status.HTTP_201_CREATED
API Design
- Use API versioning (
/api/v1/) - Use plural nouns for resource endpoints
- Use query parameters for filtering, path parameters for identity
- Return consistent error shapes with
detailfield - Use
Tagsto organize endpoints in OpenAPI docs - Add
summaryanddescriptionto route decorators
Testing
- Use
pytestwithhttpx.AsyncClientandASGITransport - Use
pytest-asynciofor async test support - Use
factory_boyor fixtures for test data - Test each endpoint for success, validation error, and auth scenarios