fastapi-pydantic-orm-patterns-skill

fastapi-pydantic-orm-patterns-skill is a skill for OpenCode from darellchua2/opencode-config-template. It costs 46 tokens per session (2,395 once invoked), scanned A, original, Apache-2.0.

A collection of backend patterns for Python services built with FastAPI, Pydantic v2, and SQLAlchemy or asyncpg. It covers common mistakes in validation, database access, migrations, authentication, and multi-tenant systems.

In plain words
What is it for?
Use it when building or reviewing FastAPI endpoints, Pydantic models, Alembic migrations, authentication flows, and service error handling.
Why use it?
It helps prevent production bugs such as inefficient database queries, unsafe tenant access, broken migrations, and race conditions. It also provides checks for using current Pydantic conventions.

Skill for OpenCode

Written for OpenCode: installed under .opencode/. Also seen: mentions OpenCode.

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/darellchua2/opencode-config-template/fastapi-pydantic-orm-patterns-skill
Any agent
npx skills add darellchua2/opencode-config-template --skill fastapi-pydantic-orm-patterns-skill
Clone the repo
git clone --depth 1 https://github.com/darellchua2/opencode-config-template

Made for: OpenCode.

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-pydantic-orm-patterns-skill

README.md
[![agentmods](https://agentmods.dev/badge/skills/darellchua2/opencode-config-template/fastapi-pydantic-orm-patterns-skill.svg)](https://agentmods.dev/skills/darellchua2/opencode-config-template/fastapi-pydantic-orm-patterns-skill)
Your own site
<a href="https://agentmods.dev/skills/darellchua2/opencode-config-template/fastapi-pydantic-orm-patterns-skill"><img src="https://agentmods.dev/badge/skills/darellchua2/opencode-config-template/fastapi-pydantic-orm-patterns-skill.svg" alt="Measured on agentmods" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,395 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.00046 $0.02395
Opus 5 $0.00023 $0.01197
Sonnet 5 $0.00009 $0.00479
Haiku 4.5 $0.00005 $0.00239

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

Security

Grade A, and why

fastapi-pydantic-orm-patterns-skill 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.

opencode_app/.opencode/skills/fastapi-pydantic-orm-patterns-skill/SKILL.md · 311 lines

How it starts

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

What I do

I provide battle-tested patterns for FastAPI + Pydantic v2 + SQLAlchemy/asyncpg backends, extracted from production incidents across multiple repos. Each pattern caused a real bug and has a concrete fix.

When to use me

Use this skill when:

  • Writing or reviewing FastAPI endpoints, especially with async sessions
  • Configuring Pydantic v2 models, validators, or serializers
  • Writing Alembic migrations (especially with asyncpg + JSONB)
  • Auditing multi-tenant isolation or auth flows
  • Debugging race conditions in state transitions
  • Reviewing error handling in service-to-service calls
  • python-backend-skill: Project scaffolding. This skill covers the runtime patterns python-backend-skill references.
  • database-migration-skill: Migration workflow patterns. This skill covers the asyncpg-specific pitfalls.
  • security-audit-skill: Security auditing. This skill covers the FastAPI-specific auth/encryption patterns.

A. Pydantic v2 Conventions

A1. Canonical Checklist

Use V2 APIs exclusively — the V1 compatibility layer is deprecated and hides bugs.

Concern V2 Correct V1 Legacy (reject)
Config model_config = ConfigDict(...) class Config:
Extra fields extra="forbid" on API boundary, "ignore" on embedded spec Extra.ignore
Validators @field_validator, @model_validator @validator
Serialization .model_dump(), .model_validate() .dict(), .parse_obj()
Computed @computed_field @property only
Immutable model_config = ConfigDict(frozen=True) custom __setattr__
Serializer @field_serializer / @model_serializer json_encoders
Type adapter TypeAdapter[T] for non-model validation custom parse_*
Polymorphism SerializeAsAny[Base] manual discriminated unions
Rebuild model_rebuild() after forward refs silent failure
Name mode validate_by_name=True (v2.11+) Config.allow_population_by_field_name
Init hook model_post_init() __init__ override

Read the full file on GitHub · 311 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 · 311 lines · 46 tokens per session scan A 1f3954a56ea4

Subscribe to this mod's changes

fastapi-pydantic-orm-patterns-skill is a skill published in the GitHub repository darellchua2/opencode-config-template (6 stars, last pushed 5d ago), licensed Apache-2.0. It adds 46 tokens to every session and 2,395 once invoked, about $0.0002 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

azure-postgres-ts

Connect to Azure Database for PostgreSQL Flexible Server from Node.js/TypeScript using the pg (node-postgres) package. Use for PostgreSQL queries, connection pooling, transactions, and Microsoft Entra ID (passwordless) authentication. Triggers: "PostgreSQL", "postgres", "pg client", "node-postgres", "Azure PostgreSQL…

microsoft/skills · 94 tokens

butterbase

AI-native, open-source backend-as-a-service with a built-in Model Context Protocol server. Postgres, auth, storage, functions, AI gateway.

butterbase-ai/butterbase · 34 tokens

supabase

Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies…

supabase/agent-skills · 185 tokens

supabase-cli

This skill should be used when user asks to "use supabase CLI", "supabase init", "supabase start", "run migrations", "deploy edge functions", "manage Supabase project", or works with the supabase command-line tool for local development and project management.

fcakyon/claude-codex-settings · 60 tokens

supabase-js

This skill should be used when user asks to "use supabase-js", "query Supabase database", "supabase auth", "supabase storage", "supabase realtime", "supabase edge functions", or works with the @supabase/supabase-js JavaScript/TypeScript SDK.

fcakyon/claude-codex-settings · 64 tokens

firebase-data-connect

Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational database with Firebase…

firebase/agent-skills · 74 tokens