fastapi

fastapi is a skill for Claude Code from nimadorostkar/Claude-Skills-collection. It costs 89 tokens per session (1,065 once invoked), scanned A, original, MIT.

A set of guidelines for building APIs with FastAPI, a Python web framework. It covers request and response validation, dependency injection, asynchronous database access, authentication, background tasks, and testing.

In plain words
What is it for?
Use it when creating or reviewing FastAPI endpoints, organizing routers and dependencies, defining Pydantic models, connecting async SQLAlchemy sessions, adding authentication, and testing with an HTTP client.
Why use it?
It helps prevent blocking work inside asynchronous handlers, overly large route functions, incorrectly scoped database sessions, and responses that expose more data than intended.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the backend plugin — 11 skills shipped together

Good fit Use it when creating or reviewing FastAPI endpoints, organizing routers and dependencies, defining Pydantic models, connecting async SQLAlchemy sessions, adding authentication, and testing with an HTTP client.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nimadorostkar/claude-skills-collection/fastapi
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add nimadorostkar/Claude-Skills-collection --skill fastapi
Clone the repo
git clone --depth 1 https://github.com/nimadorostkar/Claude-Skills-collection

Made for: Claude Code.

Or install backend, the plugin that ships this one along with the rest of its 11 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fastapi

README.md
[![agentmods](https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/fastapi/github.svg)](https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/fastapi)
Your own site
<a href="https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/fastapi"><img src="https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/fastapi/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for fastapi

Your own site · 80×15
<a href="https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/fastapi"><img src="https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/fastapi.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,065 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00089 $0.01065
Opus 5.5 $0.00036 $0.00426
Sonnet 5.5 $0.00018 $0.00213
Haiku 4.5 $0.00009 $0.00106

Measured 15d ago against content hash ec07bc9ce2bf, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

fastapi scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 15d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/backend/fastapi/SKILL.md · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

FastAPI

Purpose

Build FastAPI services that use the framework's strengths — declarative validation and dependency injection — without falling into its two standard traps: blocking calls inside async def, and business logic in the route handler.

When to Use

  • Building or reviewing a FastAPI application.
  • Structuring dependencies, authentication, and database sessions.
  • Diagnosing latency that appears only under concurrency.
  • Writing tests for FastAPI endpoints.

Capabilities

  • Route and router organization.
  • Pydantic v2 models for request, response, and settings.
  • Dependency injection with scoped lifecycles.
  • Async SQLAlchemy sessions, correctly scoped per request.
  • Authentication and authorization dependencies.
  • Testing with httpx.AsyncClient and dependency overrides.

Inputs

  • The API contract and the data layer.
  • Whether the workload is I/O-bound (nearly always) or CPU-bound.

Outputs

  • Thin route handlers delegating to service functions.
  • Response models that control exactly what is serialized.
  • A test suite that overrides dependencies rather than mocking internals.

Workflow

  1. Define the schemas — Separate request, response, and internal models. Never return an ORM object directly; a response_model is your defense against leaking a password hash.
  2. Build the dependencies — Database session, current user, feature flags. These are the injection points that make the app testable.
  3. Keep handlers thin — Parse, authorize, delegate, return. Business logic lives in a service module that knows nothing about HTTP.
  4. Get async right — In an async def handler, every I/O call must be awaited. A blocking call there stalls the entire event loop, not just that request.
  5. Test through the app — httpx.AsyncClient with app.dependency_overrides gives you real routing, real validation, and a fake database.

Best Practices

  • A blocking call inside async def (a sync DB driver, requests, time.sleep) blocks every concurrent request on that worker. If a handler must call blocking code, define it as def — FastAPI runs it in a thread pool.
  • Always set response_model. Without it, whatever your service returns is what the client sees, including fields you added last week.
  • Use Annotated[Session, Depends(get_session)] — it keeps signatures readable and reusable.
  • Validate settings with pydantic-settings at startup. Fail to boot on a bad config rather than at 3am on the first request that touches it.
  • BackgroundTasks runs in the same process and dies with it. For anything that must not be lost, use a real queue.
  • Mount routers by domain, not by HTTP verb.

Read the full file on GitHub · 102 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 15d ago Changed · +55 tokens per session ec07bc9ce2bf
  2. 1mo ago First seen · 102 lines · 34 tokens per session scan A a412a14083b2

Subscribe to this mod's changes

fastapi is a skill published in the GitHub repository nimadorostkar/Claude-Skills-collection (32 stars, last pushed 2d ago), licensed MIT. It adds 89 tokens to every session and 1,065 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

create-pubsub-python

Creates a Dapr pub/sub app in Python with FastAPI (publisher, subscriber or both) and declarative, programmatic or streaming subscriptions. Use for "create a pub/sub app in Python" or "build a FastAPI publisher and subscriber with Dapr". For an existing app use add-pubsub-python.

diagrid-labs/dapr-skills · 70 tokens

create-workflow-python

Creates a Dapr workflow app in Python, run locally with dapr run. Use for "create a workflow in Python" or "build a workflow app in Python". For Diagrid Catalyst use the catalyst-ai plugin.

diagrid-labs/dapr-skills · 49 tokens

add-pubsub-python

Adds Dapr pub/sub to an existing Python FastAPI app. Keeps its subscription type, shows a plan for approval, then makes targeted edits and checks imports after each. Use for "add pub/sub to my FastAPI app" or "make this Python service subscribe to a Dapr topic". For a new app use create-pubsub-python.

diagrid-labs/dapr-skills · 76 tokens

django-expert

Use when building Django web applications or REST APIs with Django REST Framework. Invoke when working with settings.py, models.py, manage.py, or any Django project file. Creates Django models with proper indexes, optimizes ORM queries using selectrelated/prefetchrelated, builds DRF serializers and viewsets, and…

Jeffallan/claude-skills · 96 tokens

fastapi-expert

Use when building high-performance async Python APIs with FastAPI and Pydantic V2. Invoke to create REST endpoints, define Pydantic models, implement authentication flows, set up async SQLAlchemy database operations, add JWT authentication, build WebSocket endpoints, or generate OpenAPI documentation. Trigger terms…

Jeffallan/claude-skills · 95 tokens

beautifulsoup-parsing

Expert guidance for HTML/XML parsing using BeautifulSoup in Python with best practices for DOM navigation, data extraction, and efficient scraping workflows.

Mindrally/skills · 32 tokens