fastapi-pro

fastapi-pro is a skill for Claude Code from tranhieutt/software_development_department. It costs 67 tokens per session (2,578 once invoked), scanned A, original, MIT.

A production-pattern guide for FastAPI, a Python framework for building web APIs. It covers asynchronous endpoints, database access, validation, dependency injection, JWT login tokens, and testing.

In plain words
What is it for?
It is for building and testing Python 3.11+ FastAPI services with SQLAlchemy, Pydantic, authentication, and reliable request handling.
Why use it?
It helps avoid common backend problems such as blocking asynchronous servers, leaking database sessions, losing background work, or sharing unsafe in-memory state between workers.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

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.

agentmods
npx agentmods add skills/tranhieutt/software_development_department/fastapi-pro
Any agent
npx skills add tranhieutt/software_development_department --skill fastapi-pro
Clone the repo
git clone --depth 1 https://github.com/tranhieutt/software_development_department

Made for: Claude Code.

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-pro

README.md
[![agentmods](https://agentmods.dev/badge/skills/tranhieutt/software_development_department/fastapi-pro.svg)](https://agentmods.dev/skills/tranhieutt/software_development_department/fastapi-pro)
Your own site
<a href="https://agentmods.dev/skills/tranhieutt/software_development_department/fastapi-pro"><img src="https://agentmods.dev/badge/skills/tranhieutt/software_development_department/fastapi-pro.svg" alt="Measured on agentmods" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,578 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00067 $0.02578
Opus 5 $0.00034 $0.01289
Sonnet 5 $0.00013 $0.00516
Haiku 4.5 $0.00007 $0.00258

Measured 2d ago against content hash d87d5ae6da33, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

fastapi-pro 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 2d 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.

.claude/skills/fastapi-pro/SKILL.md · 297 lines

How it starts

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

FastAPI Production Patterns

Critical rules (non-obvious)

  • async def endpoint blocking sync DB call → blocks entire event loop. Either use async DB driver (asyncpg/aiomysql) throughout OR switch endpoint to plain def (FastAPI runs it in threadpool).
  • Pydantic V2 model_config = ConfigDict(...) replaces V1 class Config. Forgetting this silently loses settings like from_attributes=True needed for ORM → DTO conversion.
  • Depends() caches per-request: same dependency called twice in one request returns same instance. Don't rely on this for cross-request state — use app state / Redis instead.
  • SQLAlchemy 2.0 async session must not leak across requests: always scope via Depends with async with AsyncSession(...) — raw module-level session causes GreenletError under load.
  • BackgroundTasks runs AFTER response sent in the same worker process: if worker dies mid-task the work is lost. For durable background jobs use Celery / Dramatiq / ARQ.
  • Uvicorn --workers N forks processes — can't share in-memory state. Use Redis or DB for any shared state (rate-limit counters, cache).

Project layout

app/
├── main.py               # FastAPI() instance + lifespan
├── api/
│   ├── deps.py           # shared Depends (get_db, get_current_user)
│   └── v1/
│       ├── users.py      # APIRouter
│       └── products.py
├── core/
│   ├── config.py         # Pydantic Settings
│   ├── security.py       # JWT encode/decode, password hashing
│   └── db.py             # engine + AsyncSession factory
├── models/               # SQLAlchemy ORM models
├── schemas/              # Pydantic DTOs (Request/Response)
├── services/             # business logic (no framework coupling)
└── tests/

Pydantic V2 settings + config

# app/core/config.py
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict

class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", env_prefix="APP_")

    database_url: str = Field(..., description="postgresql+asyncpg://...")
    jwt_secret: str = Field(..., min_length=32)
    jwt_algorithm: str = "HS256"
    jwt_exp_minutes: int = 30
    cors_origins: list[str] = Field(default_factory=list)

settings = Settings()  # fails fast at import if required vars missing

Read the full file on GitHub · 297 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. 2d ago First seen · 297 lines · 67 tokens per session scan A d87d5ae6da33

Subscribe to this mod's changes

fastapi-pro is a skill published in the GitHub repository tranhieutt/software_development_department (72 stars, last pushed 3mo ago), licensed MIT. It adds 67 tokens to every session and 2,578 once invoked, about $0.0003 per session on Opus 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-09-03.

Related

Other skills, from other repositories

fastapi

Skill "fastapi" from DongDuong2001/pudo-code-system, covering python fastapi pudo checklist, 1. plan (architecture & strategy), 2. understand (context & auditing), 3. develop (implementation) and 4. optimize (performance & review).

DongDuong2001/pudo-code-system · 0 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

django-pro

Master Django 5.x with async views, DRF, Celery, and Django Channels. Build scalable web applications with proper architecture, testing, and deployment. Use PROACTIVELY for Django development, ORM optimization, or complex Django patterns.

rmyndharis/antigravity-skills · 52 tokens

fastapi-pro

Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use PROACTIVELY for FastAPI development, async optimization, or API architecture.

rmyndharis/antigravity-skills · 57 tokens

framework-migration-assistant

Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI). Use when you need to migrate an existing web application to a modern framework while preserving functionality. The skill analyzes the codebase, updates routes, handlers, configuration, dependency injection patterns…

ArabelaTso/Skills-4-SE · 92 tokens