pattern-engineer-databaselisted
Install: claude install-skill MartinKChen/harness-claude-code
# pattern-engineer-database
## When to activate
Activate when writing or reviewing an Alembic revision (`alembic/versions/*.py`), setting up `pytest-alembic`, running Alembic CLI commands (`revision`, `upgrade`, `downgrade`, `current`), adding the `migrate` service to `compose.yaml`, or designing schema/indexes/queries (column types, FK indexes, RLS, pagination, locking). Skip for migration-unrelated app logic.
## Project memory overlay
After loading this skill, also check `$MAIN_ROOT/.claude/memory/patterns/pattern-engineer-database.md` in the consuming project (resolve `MAIN_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"`). If present, load it as an **additive overlay** to the rules below; if absent, skip silently. See `memory-convention` for the full contract (additivity, severity floor, conflict surfacing).
## Patterns
### Code-first
- ORM model is the single source of truth. Migrations are derived artifacts.
- Edit the model first; run `alembic revision --autogenerate -m "<short imperative>"`.
- Always review the autogenerated migration. It misses server defaults, check constraints, type changes, and data migrations.
- Never edit the DB schema directly (no `psql ALTER TABLE`) and backfill the model after — that produces drift.
- Commit model + migration in the same commit.
### `pytest-alembic` — non-negotiable
- Every migration is testable. Single-head + round-trip assertions are baseline.
- "Round-trips without crashing" is NOT suf