sqlalchemy-patterns SKILL.md skillA

sqlalchemy-patterns from omarsaleh506/skills is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.

Install it, pinned
mdr add omarsaleh506/skills/sqlalchemy-patterns@git:20261006.98751eb

Pins git:20261006.98751eb in mdr.lock. Pin the fingerprint instead.

Audit grade
A, 17 of 17 checks passed
Kind
SKILL.md skill
Repository
omarsaleh506/skills
Path
skills/sqlalchemy-patterns/SKILL.md
Versions recorded
4
Latest version
git:20261006.98751eb, committed Oct 6, 2026
First version recorded
Jun 28, 2026
Size
15,072 bytes
Repository stars
3
License
MIT

Comprehensive SQLAlchemy 2.0+ async + PostgreSQL patterns — declarative models, relationships, type-safe Mapped[ columns, querying, eager loading, transactions, and Alembic migrations. Use when working with SQLAlchemy; to write a model, declarative model, or ORM model; add a column, mapped_column, or Mapped[ annotation; define a relationship, foreign key, or index on a table; choose selectinload, joinedload, or load_only; configure an async session or call session.execute; fix N+1 queries; do…

Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.

What the file says

# SQLAlchemy 2.0+ Patterns (Async · PostgreSQL)

Rules for writing SQLAlchemy 2.0 / 2.1 code where **PostgreSQL is the database and async is the execution model**. Everything here is 2.0-style — no legacy `Column()` class attributes, `session.query()`, or `declarative_base()`.

> Project-agnostic: examples use generic names (`User`, `Order`). Adapt names to the project; never copy example session names or pool numbers as if they were rules.

**Versions:** works on SQLAlchemy 2.0 and 2.1 (current release line). On 2.1: Python ≥ 3.11, install `sqlalchemy[asyncio]` (greenlet is no longer pulled in by default), and always name the driver in the URL (`postgresql+asyncpg://` / `postgresql+psycopg://`). Upgrade notes: `references/migration-2.1.md`.

---

## Quick Reference Cheatsheet

| Rule | Do this |
|---|---|
| Base class | `class Base(AsyncAttrs, DeclarativeBase)` — never `declarative_base()` |
| Columns | `mapped_column()` + `Mapped[T]` — never bare `Column()` on a mapped class |
| Nullable | `Mapped[str]` = NOT NULL · `Mapped[str \| None]` = NULL |
| UUID PK | `Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid4)` (maps to `Uuid` automatically) |
…

Read the whole file at its exact version.

How to install

The exact contents, by fingerprint
mdr add omarsaleh506/skills/sqlalchemy-patterns@sha256:28968f9757c51af0

The line at the top of this page pins the label git:20261006.98751eb, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.

Badge

mdr badge

[![mdr](https://markdownregistry.com/badge/art_g5kuy7zlnzscackp.svg)](https://markdownregistry.com/a/art_g5kuy7zlnzscackp)

3 badge image fetches in 30 days. What the badge shows.

Versions

The registry has recorded 4 versions of this file, between Jun 28, 2026 and Oct 6, 2026, about one every 33 days.

versioncommittedcommitsizeaudit
git:20261006.98751eb latest2026-10-06 98751eb 15,072 BA view · diff
git:20260629.89b93c62026-06-29 89b93c6 43,102 BA view · diff
git:20260628.4788b852026-06-28 4788b85 42,976 BA view · diff
git:20260628.96e2c512026-06-28 96e2c51 42,869 BA view

Audit of the latest version

A  17 of 17 checks passed. Fixed automatic checks with no AI involved, so the same checks give the same answer every run.
  • pass: Frontmatter block present
  • pass: Frontmatter declares a name
  • pass: Frontmatter declares a description
  • pass: Size between 200 bytes and 200 KB (15072 bytes)
  • pass: No zero-width or bidi control characters
  • pass: No instruction hidden inside an HTML comment
  • pass: No link to an exfiltration or paste host
  • pass: No credential-shaped string
  • pass: No instruction to send local credentials anywhere
  • pass: No text hidden with inline styles
  • pass: No prompt-injection phrasing
  • pass: No curl or wget piped into a shell
  • pass: No recursive delete of root, home or parent
  • pass: No instruction to read or print local credentials
  • pass: No base64 blob over 200 characters
  • pass: No link to a raw IP address
  • pass: No script tag

Source

GitHub

omarsaleh506/skills · 3 stars · license MIT · pushed 2026-10-07 · branch main

API

GET https://markdownregistry.com/api/v1/artifacts/art_g5kuy7zlnzscackp
GET https://markdownregistry.com/api/v1/resolve?ref=omarsaleh506/skills/sqlalchemy-patterns
GET https://markdownregistry.com/api/v1/blob/28968f9757c51af04d3584f014ae9a4eb82183c3d0a842ff68bb72bda2c9eae4

Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.

Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.

More from omarsaleh506/skills

CLAUDE.md CLAUDE.md file
omarsaleh506/skills · CLAUDE.md
git:20260629.2d500d5 · audit A · 3 stars
ai-os-init SKILL.md skill
omarsaleh506/skills · skills/ai-os-init/SKILL.md · Scaffolds an "AI Operating System" project structure into any project, non-destructively — adds only missing pieces…
git:20261006.008e80e · audit A · 3 stars
clean-tests SKILL.md skill
omarsaleh506/skills · skills/ai-os-init/templates/.claude/skills/clean-tests/SKILL.md · Audits and refactors existing test files for quality — removes brittle assertions, fixes implementation coupling…
git:20261006.008e80e · audit A · 3 stars
new-adr SKILL.md skill
omarsaleh506/skills · skills/ai-os-init/templates/.claude/skills/new-adr/SKILL.md · Creates a new Architecture Decision Record (ADR) in docs/decisions/. Auto-numbers the file based on the highest…
git:20260628.cd7722f · audit A · 3 stars
CLAUDE.md@skills/ai-os-init/templates CLAUDE.md file
omarsaleh506/skills · skills/ai-os-init/templates/CLAUDE.md
git:20260628.cd7722f · audit A · 3 stars
shop-scout SKILL.md skill
omarsaleh506/skills · skills/shop-scout/SKILL.md · Comparison-shops any product across many online stores, finds the genuinely cheapest option after discounts, surfaces…
git:20261007.0c6d22c · audit A · 3 stars
system-flow-mapper SKILL.md skill
omarsaleh506/skills · skills/system-flow-mapper/SKILL.md · Produces three grounded deliverables for ANY codebase by reading it (source unchanged), written into the project under…
git:20261006.1f9c93b · audit B · 3 stars

Every file in omarsaleh506/skills

Browse by kind, by grade A, or by owner.