Skip to content
Development
Skill

/database-patterns

Schema design, Alembic migrations and database versioning. Use when creating migrations, designing or normalizing schemas, or fixing schema drift.

From plugin
orchestkit
301122 skills36 agents

Claude Code

$ npx -y skills add yonatangross/orchestkit --skill database-patterns --agent claude-code

SKILL.md

database-patterns.SKILL.md
name: database-patterns
license: MIT
compatibility: "Claude Code 2.1.277+."
description: "Schema design, Alembic migrations and database versioning. Use when creating migrations, designing or normalizing schemas, or fixing schema drift."
user-invocable: false
disable-model-invocation: false
targets:
  - library: sqlalchemy
    version: ">=2.1.1"
metadata:
  owner-agent: "database-engineer"
  category: document-asset-creation
  version: "2.0.0"
  author: "OrchestKit"
  complexity: "medium"
  tags: "database, migrations, alembic, schema-design, versioning, postgresql, sql, nosql"
allowed-tools: "Read Glob Grep WebFetch WebSearch"
paths: ["**/migrations/**", "**/models/**", "alembic.ini", "**/schema*"]
path_patterns: ["*.sql", "**/migrations/**", "**/alembic/**", "**/prisma/**"]

<!-- directive-density: intentional (teaches migration anti-patterns; NEVER markers describe real production-break conditions, not aspirational guidance) -->

Database Patterns

Comprehensive patterns for database migrations, schema design, and version management. Each category has individual rule files in `rules/` loaded on-demand.

Quick Reference

| Category | Rules | Impact | When to Use | |----------|-------|--------|-------------| | [Alembic Migrations](#alembic-migrations) | 2 | CRITICAL | Data migrations, branch management | | [Schema Design](#schema-design) | 3 | HIGH | Normalization, indexing strategies, NoSQL patterns | | [Versioning](#versioning) | 2 | HIGH | Changelogs, schema drift detection | | [Zero-Downtime Migration](#zero-downtime-migration) | 2 | CRITICAL | Expand-contract, pgroll, rollback monitoring |

| [Database Selection](#database-selection) | 1 | HIGH | Choosing the right database, PostgreSQL vs MongoDB, cost analysis |

**Total: 10 rules across 5 categories**

This skill is a wrap around Alembic and PostgreSQL, not a replacement for their docs. Read `references/ork-delta.md` first: it holds the version floors, corrections and house conventions that upstream does not carry. Everything in the table below was removed on purpose.

Upstream coverage (do not restate)

These topics are vendor documentation. Fetch them from the source instead of re-teaching them here.

| Topic | First-party source | |-------|--------------------| | Alembic autogenerate, async `env.py` template, `revision`/`upgrade`/`downgrade`/`history` CLI | https://alembic.sqlalchemy.org/en/latest/autogenerate.html (our one correction to the async template is in `references/ork-delta.md`) | | Migration branches, merge revisions, tuple `down_revision`, branch labels | https://alembic.sqlalchemy.org/en/latest/branches.html | | Multi-database `env.py`, batched backfill recipes, migration hooks, environment-conditional migrations | https://alembic.sqlalchemy.org/en/latest/cookbook.html | | Rollback and data-integrity test harnesses | `references/migration-testing.md` | | JSONB operators, indexing and storage tradeoffs | https://www.postgresql.org/docs/current/datatype-json.html (normal forms and the house denormalization call stay in `rules/schema-normalization.md`) | | Full index-type reference and syntax (B-tree, GIN, partial, covering, `CREATE INDEX CONCURRENTLY`, `REINDEX`) | https://www.postgresql.org/docs/current/sql-createindex.html (the house subset we actually apply stays in `rules/schema-indexing.md`) | | `lock_timeout`, `statement_timeout`, advisory locks during migration | https://www.postgresql.org/docs/current/runtime-config-client.html and `rules/versioning-drift.md` | | Enum type changes | https://www.postgresql.org/docs/current/datatype-enum.html | | Table partitioning | https://www.postgresql.org/docs/current/ddl-partitioning.html | | Trigger functions | https://www.postgresql.org/docs/current/plpgsql-trigger.html | | Foreign-key cascade semantics | https://www.postgresql.org/docs/current/ddl-constraints.html | | Temporal and audit-trail tables, CDC change logs, stored-procedure and view versioning | https://www.postgresql.org/docs/18/sql-createtable.html (read `references/ork-delta.md` before assuming these give row history) | | HNSW and vector index tuning (`m`, `ef_construction`, `hnsw.ef_search`) | https://github.com/pgvector/pgvector | | Generic pre-deployment, backup and schema-review checklists | https://alembic.sqlalchemy.org/en/latest/tutorial.html | | Async SQLAlchemy sessions, FastAPI wiring, connection pool tuning | `ork:python-backend` skill |

Quick Start

# Alembic: Auto-generate migration from model changes
# alembic revision --autogenerate -m "add user preferences"

def upgrade() -> None:
    op.add_column('users', sa.Column('org_id', UUID(as_uuid=True), nullable=True))
    op.execute("UPDATE users SET org_id = 'default-org-uuid' WHERE org_id IS NULL")

def downgrade() -> None:
    op.drop_column('users', 'org_id')
-- Schema: Normalization to 3NF with proper indexing
-- PG18: prefer uuidv7() (time-ordered, better B-tree locality) over gen_random_uuid() (random v4)
CREATE TABLE orders (
    id UUID PRIMARY KEY DEFAULT uuidv7(),
    customer_id UUID NOT NULL REFERENCES customers(id),
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_orders_customer_id ON orders(customer_id);

Alembic Migrations

Migration management with Alembic for SQLAlchemy 2.0 async applications.

| Rule | File | Key Pattern | |------|------|-------------| | Data Migration | `rules/alembic-data-migration.md` | Batch backfill, two-phase NOT NULL, zero-downtime | | Branching | `rules/alembic-branching.md` | Feature branches, merge migrations, conflict resolution |

Autogenerate setup is upstream. Our one deviation from Alembic's async `env.py` template (the `in_greenlet()` guard) is in `references/ork-delta.md`.

Schema Design

SQL and NoSQL schema design with normalization, indexing, and constraint patterns.

| Rule | File | Key Pattern | |------|------|-------------| | Normalization | `rules/schema-normalization.md` | 1NF-3NF, when to denormalize, JSON vs no

Read more
@yonatangross
Ships withorchestkit

The Complete AI Development Toolkit for Claude Code. 115 skills, 36 agents, 163 hooks. Install `ork` for stable (v10.x).

301122 skills36 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
301
Star history of yonatangross/orchestkit on GitHub, a chart by star-history.com

Other skills on orchestkit.

ork-assess

ork-assess

Assess a code change, design, architecture, workflow, or competing options against explicit criteria and evidence. Use when a…

ork-brainstorm

ork-brainstorm

Compare plausible implementation, architecture, product, or operational approaches before committing to one. Use when a request…

ork-explore

ork-explore

Map an unfamiliar codebase, feature, architecture, data flow, or operational path with file-backed evidence. Use when a request…

ork-glyph

ork-glyph

Render an answer inline as compact ASCII or box-drawing art with semantic status icons. Use for status, inventories, budgets,…

ork-implement

ork-implement

Make an approved, scoped change and prove the affected behavior. Use when a request asks to implement, build, add, or land a…

ork-review-pr

ork-review-pr

Review a pull request or branch for correctness, regressions, security, operational risk, and missing evidence. Use when a…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills12d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about database-patterns.

Which coding agents can use database-patterns?
database-patterns installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.