MeowKit
Skills

mk:database

Database patterns — schema design, safe migrations, query optimization, and indexing. PostgreSQL primary; patterns apply to MySQL and SQLite.

Source.claude/skills/database/SKILL.md
Ownerportability
Runtimeportable
Riskhigh

What This Skill Does

Owns the data layer end to end: invariants, schema, safe evolution, and query/index evidence, plus the ORM data-access boundary. It discovers the engine, migration tool, and ORM the repository already runs before proposing any syntax — there is no default engine, and an answer written for the wrong one is wasted.

When to Use

  • Designing a data model, or changing a schema
  • Writing or reviewing a migration, backfill, or recovery path
  • Diagnosing a slow query or choosing an index from evidence
  • Shaping the ORM data-access boundary, or selecting a datastore on greenfield work
  • NOT for: API contracts (mk:api-design-principles), service or handler code (mk:backend-development), infrastructure and deployment (mk:devops), or the security verdict

Ownership Boundary

OwnerOwns
mk:databaseData invariants, schema, migration and recovery, query/index evidence, ORM boundary
mk:api-design-principlesThe API contract — a table is not an API type
mk:backend-developmentThe service change that consumes the data
mk:devopsProvisioning, backups, replicas, and any production effect

Arguments

[model|migration|query|index|orm|store] [description]

Workflow

  1. Discover the source of truth — dependency manifest, schema, migration tool, ORM config, query call sites, data tests, active plan. No engine stated means ask.
  2. Classify — model/schema, migration, query/index, or store and ORM selection
  3. State invariants before syntax — entity and lifecycle, identity and uniqueness, tenancy and authorization boundary, retention and personal data, consistency need, known access patterns, performance baseline; unknowns marked unknown
  4. Design proportional to the evidence — normalize or denormalize only with a stated rationale; index from filter/join/order evidence weighed against write cost
  5. Evolve safely — compatibility with running code, locking behavior at this size, backfill approach, verification signal, and a reverse migration or forward recovery
  6. Validate and hand off — on a disposable database with synthetic, non-personal fixtures

References

FileLoad when
references/schema-design.mdEntities, keys, relationships, tenancy, constraints
references/migration-patterns.mdChanging a table that holds data; backfills; recovery
references/query-optimization.mdA slow query, or an index decision needing evidence

Security Constraint

Never build a query by string interpolation or template concatenation. Use the parameter mechanism the driver or ORM provides. Never log, print, or copy personal data while investigating — a row that reproduces a bug can be described by its shape.

Pro Tips

  • There is no default engine. Every locking, index-type, and DDL claim below is conditional on the one the repository actually runs.
  • The analysing form of EXPLAIN executes the statement. Never run it on a mutating statement outside a transaction you will roll back.
  • A reverse migration that silently discards data is worse than declaring the change irreversible. Say recovery is forward-only and name the corrective change.
  • Pool exhaustion looks like a slow query, not a pool error. Check for connections held past their work before optimizing.

On this page