agentleFS
andrewthetechieandrewthetechie/andrew-skills/skills/fastapi-pro/SKILL.md

fastapi-pro

Skill6 starsChanged 4 months agoMITView on GitHub

Designs, implements, reviews, and diagnoses production FastAPI services with Pydantic and SQLAlchemy. Use when work involves FastAPI routes, dependencies, validation, authentication, async I/O, database sessions, WebSockets or SSE, OpenAPI contracts, tests, or API performance.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default to async-first, end-to-end non-blocking I/O for FastAPI work.

    line 8
  2. Distinctive:

    Use Pydantic models at the transport boundary.

    line 41
  3. Very specific:

    Use FastAPI dependencies for request-scoped resources and cross-cutting policy.

    line 42
  4. Very specific:

    Keep one SQLAlchemy session per request or unit of work.

    line 45
  5. Distinctive:

    Keep HTTP translation at the router boundary.

    line 46
  6. Distinctive:

    If there are no material findings, say so and identify residual risks or unverified behavior.

    line 56
  7. Distinctive:

    Add or update focused tests for the changed contract and regression.

    line 70
  8. Distinctive:

    Run the repository's configured formatter, linter, type checker, and smallest sufficient test set.

    line 72

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

FastAPI Pro

Default to async-first, end-to-end non-blocking I/O for FastAPI work. Treat synchronous I/O as an explicit compatibility boundary and isolate it from the event loop rather than letting it shape the service.

Within that default, treat the repository's pinned versions, architecture, and conventions as the source of truth. Do not add dependencies or upgrade packages unless the task requires it.

Workflow

1. Ground the task

  • Classify the work as build/change, design/review, or diagnosis/performance.
  • Inspect project configuration and adjacent app construction, routes, schemas, dependencies, persistence code, exception handlers, and tests before proposing a pattern.
  • Trace the request path across the HTTP, validation, authorization, domain, persistence, and external-service boundaries that the task touches.

Complete this step when the target behavior, compatibility constraints, framework versions, and affected boundaries are known.

2. Make the contract explicit

For endpoint work, define or recover:

  • method and path;
  • path, query, header, and body inputs with validation constraints;
  • success response schema, headers, and status code;
  • error conditions and the project's error envelope;
  • authentication, object-level authorization, and sensitive-data rules;
  • pagination, idempotency, concurrency, or versioning semantics when relevant.

Preserve public behavior unless a breaking change is requested. For REST endpoint design or review, read and apply REST_API_CHECKLIST.md.

Complete this step when every externally observable outcome has an intentional contract.

3. Take the matching branch

Build or change

  • Use Pydantic models at the transport boundary; keep persistence models internal. Separate input and output models when mutability, permissions, or representation differ.
  • Use FastAPI dependencies for request-scoped resources and cross-cutting policy. Prefer typed Annotated aliases when the repository already uses them.
  • Build an end-to-end async I/O chain by default: use async def, async database drivers, and async HTTP clients. When a blocking library is unavoidable, isolate it with the repository's thread-pool or worker pattern; never execute blocking I/O on the event loop.
  • Manage shared application resources with lifespan context and request resources with cleanup-aware dependencies.
  • Keep one SQLAlchemy session per request or unit of work. Bound transactions explicitly, roll back failures, prevent accidental lazy I/O, and never share an AsyncSession across concurrent tasks.
  • Keep HTTP translation at the router boundary. Introduce service or repository layers only when domain complexity or the existing architecture warrants them.
  • Map domain failures to stable HTTP errors at the boundary. Do not leak internals, credentials, or data the caller cannot access.

Complete this branch when the implementation matches the contract and resource, transaction, authorization, and async boundaries are explicit.

Design or review

  • Apply every relevant item in the REST checklist and trace implementation behavior rather than judging route declarations alone.
  • Prioritize correctness, contract compatibility, authorization, data exposure, transaction safety, async hazards, and missing tests.
  • Report findings first, ordered by severity. Include file and line, observed evidence, impact, and a concrete correction; avoid speculative rewrites.
  • If there are no material findings, say so and identify residual risks or unverified behavior.

Complete this branch when every affected contract and relevant checklist item has been accounted for.

Diagnose or tune

  • Reproduce the failure or establish a baseline before changing code.
  • Form and test specific hypotheses. Inspect blocking I/O, N+1 queries, implicit lazy loads, oversized serialization, connection-pool pressure, leaked resources, transaction scope, and downstream latency as relevant.
  • Make the smallest evidence-backed correction, then repeat the original measurement or reproduction.

Complete this branch when evidence identifies the cause and the same probe demonstrates the result.

4. Verify

  • Add or update focused tests for the changed contract and regression. Cover success plus relevant validation, not-found/conflict, authentication, authorization, rollback, and concurrency cases.
  • Assert status, response body and headers, side effects, and forbidden side effects—not merely that the endpoint returns.
  • Run the repository's configured formatter, linter, type checker, and smallest sufficient test set; widen testing when shared boundaries changed.
  • Confirm generated OpenAPI reflects the intended public contract when routes or schemas changed.

Complete the task only when changed behavior is exercised, applicable checks pass, and any check that could not run is reported with the reason.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.