Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
existential-birds avatar

Fastapi Code Review

  • 344 installs
  • 74 repo stars
  • Updated July 21, 2026
  • existential-birds/beagle

fastapi-code-review is a Claude agent skill that audits FastAPI Python services for routing, dependency injection, Pydantic models, async pitfalls, and OpenAPI correctness before merge or release.

About

fastapi-code-review is a specialized agent skill for backend engineers shipping FastAPI microservices and REST APIs. The skill walks an AI coding agent through a structured review checklist covering APIRouter route definitions, Depends() dependency injection chains, Pydantic v2 request and response models, async/await concurrency pitfalls, and OpenAPI schema accuracy against actual endpoints. Developers reach for fastapi-code-review when a pull request touches FastAPI routers, background tasks, or auto-generated Swagger docs and they want a second pass before code review or release. The skill focuses on Python async patterns that commonly cause production bugs—blocking calls inside async handlers, incorrect Depends scopes, and schema drift between Pydantic models and documented OpenAPI fields. It is designed for teams maintaining typed Python APIs where correctness of dependency graphs and contract documentation matters as much as business logic.

  • Router and DI checks
  • Pydantic schema validation
  • Async and lifespan review
  • OpenAPI contract audit
  • Security and error handling

Fastapi Code Review by the numbers

  • 344 all-time installs (skills.sh)
  • Ranked #272 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/existential-birds/beagle --skill fastapi-code-review

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs344
repo stars74
Last updatedJuly 21, 2026
Repositoryexistential-birds/beagle

How do you review FastAPI code before merging?

Review FastAPI services for routing, dependency injection, Pydantic models, async pitfalls, and OpenAPI correctness before merge or release.

Who is it for?

Backend engineers maintaining FastAPI services who want a systematic pre-merge audit of routing, DI, Pydantic models, and OpenAPI contracts.

Skip if: Teams not using FastAPI or Python, or developers who only need generic language-agnostic code review without API-framework specifics.

When should I use this skill?

A pull request modifies FastAPI routers, Depends() chains, Pydantic schemas, async handlers, or OpenAPI documentation and needs a framework-specific review pass.

What you get

Structured review findings covering routing, dependency injection, Pydantic models, async pitfalls, and OpenAPI schema mismatches.

  • Pre-merge review findings
  • OpenAPI schema mismatch report

Files

SKILL.mdMarkdownGitHub ↗

FastAPI Code Review

Quick Reference

Issue TypeReference
APIRouter setup, response_model, status codesreferences/routes.md
Depends(), yield deps, cleanup, shared depsreferences/dependencies.md
Pydantic models, HTTPException, 422 handlingreferences/validation.md
Async handlers, blocking I/O, background tasksreferences/async.md

Review Checklist

  • [ ] APIRouter with proper prefix and tags
  • [ ] All routes specify response_model for type safety
  • [ ] Correct HTTP methods (GET, POST, PUT, DELETE, PATCH)
  • [ ] Proper status codes (200, 201, 204, 404, etc.)
  • [ ] Dependencies use Depends() not manual calls
  • [ ] Yield dependencies have proper cleanup
  • [ ] Request/Response models use Pydantic
  • [ ] HTTPException with status code and detail
  • [ ] All route handlers are async def
  • [ ] No blocking I/O (requests, time.sleep, open())
  • [ ] Background tasks for non-blocking operations
  • [ ] No bare except in route handlers

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
  • Dependency injection for database sessions - Sessions come from Depends(), not passed as function arguments
  • HTTPException for all HTTP errors - FastAPI handles conversion to proper HTTP responses
  • Async def endpoint without await - May be using sync dependencies or simple operations; FastAPI handles this
  • Type annotation on Depends() - This is documentation/IDE support, not a type assertion
  • Query/Path/Body defaults - FastAPI processes these at runtime, not traditional Python defaults
  • Returning dict from endpoint - Pydantic converts automatically if response_model 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 with validators
  • Flag missing auth ONLY IF the endpoint isn't using Depends() with an auth dependency
  • Flag missing error handling ONLY IF HTTPException isn't raised appropriately for error cases
  • Flag sync in async ONLY IF the operation is actually blocking (file I/O, network calls, CPU-bound), not just non-async

Gates (FastAPI-specific)

Run once per FastAPI-related finding, after you can anchor `file:line` for the handler (see review-verification-protocol) and before the finding text 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

StepActionPass condition
1aOpen the handler’s route decorator in the repo (not from memory).`file:line` for @router.* / @app.* (or the site that registers this handler).
1bRecord HTTP method, response_model=, and status_code= on that decorator (or note they are absent).Snippet from that line or explicit absent with the same `file:line`.

Gate 2 — Blocking or “should be async”

StepActionPass condition
2aRead the full handler body.`file:line` range covering the body.
2bIf claiming blocking I/O: name each blocking call (e.g. requests., open(, time.sleep, sync DB/ORM).Each call has `file:line`, or withdraw the finding if none after the read.

Gate 3 — Depends, validation, auth

StepActionPass condition
3aList parameters: Depends / Annotated[..., Depends], Pydantic models, Body/Query/Path, Request/Response.Names + mechanism tied to `file:line` on the signature.
3bIf claiming missing auth: search the handler file (and its APIRouter module if separate) for Depends, Security, HTTPBearer, or project auth dependencies.Citation to an existing hook, or search result: paths searched + N matches (zero is allowed).
3cIf claiming missing validation: confirm the argument is not already a Pydantic model or constrained Query/Path/Body.Type/source with `file:line`, or withdraw if validation already applies.

FastAPI Framework Behaviors

FastAPI + Pydantic handle many concerns automatically:

  • Request validation via Pydantic models
  • Response serialization via response_model
  • Dependency injection for cross-cutting concerns
  • Exception handling via exception handlers

Before flagging "missing" functionality, verify FastAPI isn't handling it.

When to Load References

  • Reviewing route definitions → routes.md
  • Reviewing dependency injection → dependencies.md
  • Reviewing Pydantic models/validation → validation.md
  • Reviewing async route handlers → async.md

Review Questions

1. Do all routes have explicit response models and status codes? 2. Are dependencies injected via Depends() with proper cleanup? 3. Do all Pydantic models validate inputs correctly? 4. Are all route handlers async and non-blocking?

Before Submitting Findings

1. For each FastAPI-related finding, complete Gates (FastAPI-specific) above. 2. Load and follow review-verification-protocol (Pre-Report checklist and Verification by Issue Type) before reporting any issue.

Related skills

How it compares

Pick fastapi-code-review over generic Python linters when the review must cover FastAPI-specific patterns like Depends(), Pydantic schemas, and OpenAPI contract drift.

FAQ

What does fastapi-code-review check?

fastapi-code-review audits FastAPI services for routing correctness, Depends() dependency injection, Pydantic model validation, async concurrency pitfalls, and OpenAPI schema alignment before merge or release.

When should I run fastapi-code-review?

Run fastapi-code-review on pull requests that touch FastAPI routers, background tasks, Pydantic schemas, or Swagger docs, especially before merging to main or cutting a release.

Code Review & Qualitybackendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.