fastapi-code-review
БесплатноБез исполняемых скриптовНе проверенReviews FastAPI code for routing patterns, dependency injection, Pydantic v2 validation, and async/sync handler safety. Use when reviewing FastAPI apps…
от existential-birds★ 92 звезды на GitHubОб этом скилле
FastAPI Code Review
Quick Reference
| Issue Type | Reference |
|---|---|
| APIRouter setup, response_model, status codes, lifespan | references/routes.md |
Annotated[..., Depends()], yield deps, pure ASGI middleware |
references/dependencies.md |
Pydantic v2 ConfigDict, HTTPException, 422 handling |
references/validation.md |
def vs async def, blocking I/O, asyncio.to_thread, background tasks |
references/async.md |
Review Checklist
-
APIRouterwith proper prefix and tags - All routes specify
response_model=or a typed return annotation (-> UserResponse) for validation/OpenAPI - Correct HTTP methods (
GET,POST,PUT,DELETE,PATCH) and status codes (201,204, etc.) - Dependencies use
Annotated[T, Depends(...)](orDepends(...)), not manual calls - Yield dependencies clean up resources in
finally(or viaasync with) - Request/Response models use Pydantic v2 (
ConfigDict,@model_validator,@field_validator) -
HTTPExceptionincludes explicit status code anddetail -
async defhandlers contain no blocking I/O (requests,time.sleep, syncopen(), sync DB); syncdefhandlers are used for sync I/O (run in AnyIO threadpool) -
BackgroundTasksused for fire-and-forget post-response work - App startup/shutdown uses
lifespancontext manager (not deprecatedon_event) - Middleware uses pure ASGI (
__call__(scope, receive, send)) rather thanBaseHTTPMiddlewarewherecontextvars, streaming, or WebSockets matter
Valid Patterns (Do NOT Flag)
These are idiomatic FastAPI patterns that may appear problematic but are correct:
- Pydantic validates request body automatically — No manual validation needed when using typed Pydantic models as parameters
- Sync
defroute handlers for sync I/O — FastAPI runsdefhandlers in an AnyIO worker threadpool so they do not block the event loop async defendpoint withoutawait— Valid for non-blocking computations or simple returns- Dependency injection via
Depends()— Sessions and services come fromDepends(), with type inferred from the callable if unannotated - Response model different from DB model — Intentional separation between API schemas and persistence models
BackgroundTasksparameter — Standard pattern for fire-and-forget post-response operations- Direct
request.stateaccess — Standard pattern for middleware-injected or lifespan-initialized state Query/Path/BodyinAnnotated[...]or defaults — FastAPI processes these at runtime- Returning
dictor ORM object from endpoint — Pydantic validates and serializes automatically whenresponse_model=or a return-type annotation is set
Context-Sensitive Rules
Only flag issues when the context warrants it:
- Flag missing validation ONLY IF the field isn't already in a Pydantic model or constrained via
Query/Path/Body - Flag missing auth ONLY IF neither the endpoint nor its
APIRouter/FastAPIapp applies an auth dependency - Flag missing error handling ONLY IF no
HTTPExceptionor app exception handler handles the failure case - Flag blocking in async ONLY IF an actually blocking operation (sync network I/O,
time.sleep, heavy file/CPU work, sync DB driver) runs directly inside anasync defhandler or dependency (not inside adefhandler)
Gates (FastAPI-specific)
Run once per FastAPI-related finding, after anchoring file:line for the handler per review-verification-protocol (review-verification-protocol) and before the finding ships. If a step's pass condition is not met, do not assert the finding as written—gather evidence, withdraw, downgrade severity, or rephrase as a question.
Gate 1 — Route decorator and response surface
| Step | Action | Pass condition |
|---|---|---|
| 1a | Open the handler's route decorator in the repo (not from memory). | file:line for @router.* / @app.* (or the site that registers this handler). |
| 1b | Record HTTP method, response_model=, return-type annotation, and status_code= on that decorator/signature (or note they are absent). |
Snippet from those lines or explicit absent with the same file:line. |
Gate 2 — Blocking I/O in async def
| Step | Action | Pass condition |
|---|---|---|
| 2a | Confirm the handler/dependency is async def and read its full body. |
file:line range covering the async def body. |
| 2b | Name each blocking call inside async def (e.g., requests., open(, time.sleep, sync DB/ORM). Do not flag def handlers merely for being sync. |
Each blocking call has file:line, or withdraw the finding if none after the read. |
Gate 3 — Depen
Установить fastapi-code-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл fastapi-code-review?
Reviews FastAPI code for routing patterns, dependency injection, Pydantic v2 validation, and async/sync handler safety. Use when reviewing FastAPI apps, checking APIRouter setup, Depends()/Annotated usage, or response models.
Как установить скилл fastapi-code-review?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл fastapi-code-review запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic