sqlalchemy-models

sqlalchemy-models is a skill for Claude Code, Codex from robhowley/py-pit-skills. It costs 66 tokens per session (2,580 once invoked), scanned A, original, MIT.

A set of instructions for defining SQLAlchemy 2.x database models in Python backends. Database models describe stored data, its fields, and the relationships between records.

In plain words
What is it for?
Use it when creating or reorganizing models for a FastAPI or other Python backend. It covers a shared base class, typed columns, relationships, package structure, and Alembic migration support.
Why use it?
It helps keep model definitions consistent, typed, easy to migrate, and separate from API request and response schemas. This reduces common problems such as circular imports and broken relationships.

Skill for Claude CodeCodex

Part of the py-pit plugin — 16 skills, 1 hook shipped together

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/robhowley/py-pit-skills/sqlalchemy-models
Any agent
npx skills add robhowley/py-pit-skills --skill sqlalchemy-models
Clone the repo
git clone --depth 1 https://github.com/robhowley/py-pit-skills

Made for: Claude Code, Codex.

Or install py-pit, the plugin that ships this one along with the rest of its 16 skills, 1 hook.

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 sqlalchemy-models

README.md
[![agentmods](https://agentmods.dev/badge/skills/robhowley/py-pit-skills/sqlalchemy-models.svg)](https://agentmods.dev/skills/robhowley/py-pit-skills/sqlalchemy-models)
Your own site
<a href="https://agentmods.dev/skills/robhowley/py-pit-skills/sqlalchemy-models"><img src="https://agentmods.dev/badge/skills/robhowley/py-pit-skills/sqlalchemy-models.svg" alt="Measured on agentmods" height="20"></a>
Per session 66 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,580 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 $0.00066 $0.02580
Opus 5 $0.00033 $0.01290
Sonnet 5 $0.00013 $0.00516
Haiku 4.5 $0.00007 $0.00258

Measured 3d ago against content hash f97e46cf296d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sqlalchemy-models 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 3d 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/sqlalchemy-models/SKILL.md · 437 lines

How it starts

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

Skill: sqlalchemy-models

Core position

This skill creates clean, production-ready SQLAlchemy 2.x ORM models for Python backend projects.

It enforces disciplined model patterns that prevent common problems such as:

  • inconsistent base/model definitions
  • broken or asymmetric relationships
  • circular imports
  • weak typing
  • migration-hostile schema definitions
  • persistence and API schema concerns getting mixed together

The skill favors explicit, typed, migration-friendly ORM design and ensures model code is:

  • SQLAlchemy 2.x native
  • typed
  • composable
  • easy to migrate
  • easy to review

Goals

Produce a model layer that:

  1. Uses SQLAlchemy 2.x canonical style
  2. Centralizes model infrastructure around a single DeclarativeBase
  3. Defines columns and relationships with explicit typing
  4. Organizes models in a predictable package structure
  5. Avoids circular import traps
  6. Stays compatible with Alembic autogenerate
  7. Keeps ORM models separate from Pydantic/API schemas

Step 0 — Inspect the existing project first

Before generating anything:

  1. Check whether a models/ package or existing model files already exist. If they do, extend the existing structure rather than creating a parallel one.
  2. Note the existing package layout. If the project was scaffolded with fastapi-init, the package root is {pkg_name}/{pkg_name}/ — place models at {pkg_name}/models/, not app/models/.
  3. Check whether a DeclarativeBase subclass already exists anywhere. If one does, adopt it rather than introducing a second base.
  4. Check whether an Alembic env.py is present and how it imports Base.metadata — preserve that import path.
  5. Only create new files if the relevant structure is absent.

Read the full file on GitHub · 437 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. 3d ago First seen · 437 lines · 66 tokens per session scan A f97e46cf296d

Subscribe to this mod's changes

sqlalchemy-models is a skill published in the GitHub repository robhowley/py-pit-skills (5 stars, last pushed 5mo ago), licensed MIT. It adds 66 tokens to every session and 2,580 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-08-31.

Related

Other skills, from other repositories

geopipe-agent

Use when building AI-driven GIS data pipelines with YAML-defined steps — format conversion, spatial validation, QC reporting, PostGIS loading, WMS publishing. GeoPipe Agent: YAML-driven GIS ETL pipeline agent with quality control.

znlgis/opengis-skills · 50 tokens

database

Relational database authority — PostgreSQL, async ORM (SQLAlchemy 2 / asyncpg), Alembic schema migrations, Supabase Python and JS clients, query optimisation, index strategy, connection pooling, transaction patterns, and bulk operations across Python and Node stacks.

LuuOW/meridian-mcp · 54 tokens

ubiquitous-language

Extract a DDD-style ubiquitous language glossary from the current conversation, flagging ambiguities and proposing canonical terms. Saves to UBIQUITOUSLANGUAGE.md. Use when user wants to define domain terms, build a glossary, harden terminology, create a ubiquitous language, or mentions "domain model" or "DDD".

shekohex/dotai · 70 tokens

fastapi-best-practices

Use this skill when creating or modifying Python backend services with FastAPI. It defines API design, security, and testing standards.

ApexIQ/skillsmith · 32 tokens

python-fastapi-coding-conventions

This skill should be used when creating a service class, adding an API route, defining Pydantic schemas, writing error handling, reviewing code style, checking project directory structure, writing or running database migrations, or deciding what belongs in which layer. Covers style, naming, error handling, logging…

aishajv/claude-everything · 84 tokens

modular-monolith-architecture

Design or review a modular monolith by defining bounded contexts, assigning ownership, enforcing public service-layer interfaces, keeping dependencies one-way, and separating shared technical code from business code. Use when planning modules, adding a feature that crosses module boundaries, or finding direct…

aishajv/claude-everything · 66 tokens