/godmode:fastapifrom godmode
Guides building FastAPI apps with Pydantic models, async DB access, dependency injection, and testing. Useful for new projects or reviewing existing FastAPI code.
Ships in godmode. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
/godmode:fastapi# Detect FastAPI project
grep -l "fastapi" pyproject.toml requirements.txt \
setup.py 2>/dev/null
# Check Python version
python3 --version
# Detect package manager
ls uv.lock poetry.lock Pipfile.lock 2>/dev/null
FASTAPI ASSESSMENT:
FastAPI version: <0.115.x>
Python: <3.12+ recommended>
ORM: SQLAlchemy 2.0 async | Tortoise | SQLModel
Auth: JWT | OAuth2 | API keys
Package manager: uv (preferred) | Poetry | pip
IF Python < 3.12: recommend upgrade for performance
IF using sync psycopg2: must migrate to asyncpg
IF no Alembic: add migration support immediately
PROJECT STRUCTURE:
app/
├── main.py # FastAPI app factory
├── config.py # pydantic-settings
├── dependencies.py # Shared DI (DB, auth)
├── api/v1/
│ ├── router.py # Aggregates all v1 routes
│ ├── orders.py # Order endpoints
│ └── customers.py # Customer endpoints
├── models/ # SQLAlchemy models
├── schemas/ # Pydantic schemas
├── services/ # Business logic
└── tests/
PYDANTIC PATTERNS:
| Pattern | Usage |
|--------------------------|---------------------|
| Separate Create/Update/Resp | Per-operation |
| field_validator | Single-field custom |
| model_validator | Cross-field logic |
| Field(gt=0, max_length) | Declarative limits |
| from_attributes=True | ORM → Pydantic |
| Generic PaginatedResp[T] | Reusable pagination|
THRESHOLDS:
max_length for strings: always set (default 255)
gt=0 for IDs and counts: always set
le=1000 for pagination page_size: prevent abuse
IF no Field() constraints: validation is incomplete
DI PATTERNS:
| Pattern | Usage |
|---------------------|---------------------|
| Annotated[T, Depends]| Type-safe DI |
| yield dependencies | Resource lifecycle |
| Nested dependencies | Service → Repo → DB|
| Class-based deps | Service classes |
| Lifespan events | App-scoped pools |
RULES:
Max DI chain depth: 3 levels
IF deeper: refactor, something is over-abstracted
IF using module globals for DB: refactor to Depends()
# Install async driver
uv add asyncpg sqlalchemy[asyncio] alembic
# Initialize Alembic
alembic init -t async alembic
ASYNC DB RULES:
Driver: asyncpg (never psycopg2 in async context)
expire_on_commit: False (always)
Loading: selectin (async-safe, not lazy)
Query style: SQLAlchemy 2.0 (select(), Mapped[])
Migrations: Alembic (never metadata.create_all())
Pool: min 5, max 20 connections (tune per traffic)
IF N+1 detected: add with() eager loading
IF pool exhaustion: increase max, add connection timeout
TASK STRATEGY:
| Approach | When to Use |
|-----------------|------------------------|
| BackgroundTasks | Simple fire-and-forget |
| Celery | Complex, scheduling |
| ARQ | Async-native, light |
| asyncio.create | In-process async work |
WEBSOCKET RULES:
Authenticate in handshake (JWT in query params)
Handle WebSocketDisconnect gracefully
IF multi-worker: use Redis Pub/Sub (not in-memory)
Connection limit: 1000 per server instance
# Run async tests
uv run pytest tests/ -v --tb=short
# Run with coverage
uv run pytest tests/ --cov=app --cov-report=term
TESTING STRATEGY:
| Layer | Approach |
|-------------|------------------------|
| Endpoints | HTTPX AsyncClient |
| Services | pytest + async fixtures|
| Schemas | Pydantic validation |
| Repos | Test DB session |
| Dependencies| dependency_overrides |
THRESHOLDS:
Coverage target: >= 80% overall
Endpoint coverage: 100% of routes
Schema tests: every validation rule tested
IF test uses real external service: mock it
FASTAPI VALIDATION:
| Check | Status |
|------------------------------|--------|
| Async endpoints throughout | ? |
| Pydantic schemas for all I/O | ? |
| DI via Depends() (no globals)| ? |
| Async DB driver (asyncpg) | ? |
| N+1 prevention (selectin) | ? |
| Auth on protected endpoints | ? |
| Field() constraints on schemas| ? |
| Alembic migrations present | ? |
Commit: "fastapi: <service> — <N> async endpoints, Pydantic schemas, pytest"
Never ask to continue. Loop autonomously until done.
1. FastAPI imports, Python version, package manager
2. ORM: SQLAlchemy/Tortoise/SQLModel, async driver
3. Auth: python-jose/authlib, Pydantic v1 vs v2
4. Tests: pytest/httpx, Alembic migrations
Print: FastAPI: {action}, {endpoints} endpoints, {models} models. Tests: {status}. Verdict: {verdict}.
timestamp project endpoints models migrations tests status
KEEP if: tests pass AND quality improved
AND no regressions
DISCARD if: tests fail OR performance regressed
STOP when ANY of:
- All tasks complete and validated
- User requests stop
- Max iterations reached
alembic merge heads.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Claude Code installs this plugin but refuses to load it
hooks/hooks.json: hooks.json declares PreToolUse/PermissionRequest at its top level, outside the "hooks" object — a PreToolUse/PermissionRequest hook that cannot be loaded may be what guards the permissions declared beside it, so nothing it sits in is applied until the entry is fixed or removed
hooks/hooks.json: hooks.json declares PreToolUse/PermissionRequest at its top level, outside the "hooks" object — a PreToolUse/PermissionRequest hook that cannot be loaded may be what guards the permissions declared beside it, so nothing it sits in is applied until the entry is fixed or removed
Checked against Claude Code 2.1.332. The listing below is what the repository ships; Claude Code doesn't load it as published.
135 skills in this plugin
/a11yAccessibility. WCAG 2.1 AA/AAA, a11y audit, color contrast, keyboard navigation, screen reader, Axe, Pa11y, Lighthouse./agentAI agent development. ReAct/plan-and-execute/multi-agent architectures, tool design, memory systems, guardrails, orchestration (LangChain, LlamaIndex, CrewAI, AutoGen)./analyticsProduct analytics implementation — event tracking, funnel analysis, A/B testing, Segment/Amplitude/Mixpanel/PostHog, privacy-compliant instrumentation./angularAngular architecture. NgRx, Signals, RxJS, standalone components, lazy loading, dependency injection, Jasmine, Jest./apiAPI design and specification. REST, GraphQL, gRPC, OpenAPI, design an API, create API spec, validate my API, endpoint./apidocsAPI documentation. OpenAPI, Swagger, Redoc, contract-first development, spec-first, code-first, interactive docs.Other plugins' skills for the same job