fastapi-patterns

fastapi-patterns is a skill for Claude Code from ruslan-korneev/claude-plugins. It costs 0 tokens per session (1,297 once invoked), scanned A, original, MIT.

A set of design patterns for FastAPI applications using SQLAlchemy 2.0 and dependency-injector. FastAPI is a Python framework for building web APIs, SQLAlchemy connects code to databases, and dependency injection manages shared services.

In plain words
What is it for?
Use it when creating FastAPI modules, database models and repositories, dependency-injection setup, or Pydantic data-transfer objects.
Why use it?
It gives a consistent structure for separating web requests, business rules, database access, and data validation as the project grows.

Skill for Claude Code

Written for Claude Code: ${CLAUDE_PLUGIN_ROOT} variable.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the fastapi plugin — 2 skills, 5 commands, 1 agent shipped together

Good fit Use it when creating FastAPI modules, database models and repositories, dependency-injection setup, or Pydantic data-transfer objects.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add ruslan-korneev/claude-plugins
Claude Code
/plugin install fastapi

Made for: Claude Code.

Or install fastapi, the plugin that ships this one along with the rest of its 2 skills, 5 commands, 1 agent.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/ruslan-korneev/claude-plugins/fastapi-patterns/github.svg)](https://agentmods.dev/skills/ruslan-korneev/claude-plugins/fastapi-patterns)
Your own site
<a href="https://agentmods.dev/skills/ruslan-korneev/claude-plugins/fastapi-patterns"><img src="https://agentmods.dev/badge/skills/ruslan-korneev/claude-plugins/fastapi-patterns/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-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/ruslan-korneev/claude-plugins/fastapi-patterns"><img src="https://agentmods.dev/badge/skills/ruslan-korneev/claude-plugins/fastapi-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,297 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.
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.00000 $0.01297
Opus 5.5 $0.00000 $0.00519
Sonnet 5.5 $0.00000 $0.00259
Haiku 4.5 $0.00000 $0.00130

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

Security

Grade A, and why

fastapi-patterns 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 3mo 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.

plugins/fastapi/skills/fastapi-patterns/SKILL.md · 219 lines

How it starts

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

FastAPI Patterns

Best practices and patterns for FastAPI projects with SQLAlchemy 2.0 and dependency-injector.

Triggers

Use this skill when the user:

  • Creates a new FastAPI project or module
  • Asks about FastAPI application structure
  • Works with SQLAlchemy models and repositories
  • Configures Dependency Injection
  • Creates DTOs (Pydantic models)

Layer Architecture

Router → Service → Repository → Database
   ↓        ↓          ↓
  DTO     DTO     Model/DTO
  • Router — HTTP endpoints, request validation
  • Service — business logic, orchestration
  • Repository — database operations, CRUD operations

Modular Structure

src/
├── core/
│   ├── config.py         # Settings (pydantic-settings)
│   ├── database.py       # Engine, Base, session
│   ├── container.py      # DI Container
│   ├── dependencies.py   # FastAPI dependencies
│   ├── exceptions.py     # Custom exceptions
│   └── repositories.py   # BaseRepository
├── modules/
│   ├── users/
│   │   ├── __init__.py
│   │   ├── models.py
│   │   ├── dto.py
│   │   ├── repositories.py
│   │   ├── services.py
│   │   └── routers.py
│   └── orders/
│       └── ...
└── main.py

BaseRepository with Generics

More details: ${CLAUDE_PLUGIN_ROOT}/skills/fastapi-patterns/references/repository.md

from typing import Generic, TypeVar
from collections.abc import Sequence
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession

ModelT = TypeVar("ModelT")
CreateDTOT = TypeVar("CreateDTOT")
ReadDTOT = TypeVar("ReadDTOT")


class BaseRepository(Generic[ModelT, CreateDTOT, ReadDTOT]):
    """Base repository with generic CRUD operations."""

    def __init__(self, session: AsyncSession, model: type[ModelT]) -> None:
        self._session = session
        self._model = model

    async def get_all(self) -> Sequence[ReadDTOT]:
        result = await self._session.execute(select(self._model))
        return result.scalars().all()

    async def save(self, data: ModelT | CreateDTOT) -> ReadDTOT:
        if isinstance(data, self._model):
            entity = data
        else:
            entity = self._model(**data.model_dump())
        self._session.add(entity)
        await self._session.flush()
        return entity

Read the full file on GitHub · 219 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3mo ago First seen · 219 lines · 0 tokens per session scan A 563209124156

Subscribe to this mod's changes

fastapi-patterns is a skill published in the GitHub repository ruslan-korneev/claude-plugins (5 stars, last pushed 9mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,297 tokens. 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-31.

Related

fastapi-patterns compared with skills from other repositories

fastapi-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
fastapi-patternsruslan-korneev/claude-pluginsSkill59mo agoMITA0Claude Code
phoenix-contextsoliver-kriska/claude-elixir-phoenixSkill579yesterdayMITA46Claude Code
drizzle-orm-d1secondsky/claude-skillsSkill257yesterdayMITA76Claude Code
cloudflare-hyperdrivesecondsky/claude-skillsSkill257yesterdayMITA45Claude Code
idempotency-handlingsecondsky/claude-skillsSkill257yesterdayMITA46Claude Code
architecture-paradigm-cqrs-esathola/claude-night-marketSkill358todayMITA33Claude Code
domain-modelingrsmdt/the-startupSkill5881mo agoMITA42Claude Code