Learn-skills.dev fastapi-developer
Senior FastAPI developer. Use when building or working on FastAPI applications. Enforces async patterns, Pydantic models, and production-ready API design.
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/ai-engineer-agent/ai-engineer-skills/fastapi-developer" ~/.claude/skills/neversight-learn-skills-dev-fastapi-developer && rm -rf "$T"
manifest:
data/skills-md/ai-engineer-agent/ai-engineer-skills/fastapi-developer/SKILL.mdsource content
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
for all route handlersasync def - Use dependency injection via
Depends() - Use
syntax (PEP 593)Annotated[T, Depends(...)]
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
context manager for startup/shutdownlifespan - Use
withpydantic-settings
files for configuration.env - Use SQLAlchemy 2.0 async with
AsyncSession - Use Alembic for database migrations
- Use
for fire-and-forget operationsBackgroundTasks - Use
with appropriate status codesHTTPException - Use response models:
response_model=ResponseSchema - Use
module constants:statusstatus.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
fielddetail - Use
to organize endpoints in OpenAPI docsTags - Add
andsummary
to route decoratorsdescription
Testing
- Use
withpytest
andhttpx.AsyncClientASGITransport - Use
for async test supportpytest-asyncio - Use
or fixtures for test datafactory_boy - Test each endpoint for success, validation error, and auth scenarios