From mk
Guides schema design, migration writing, and query optimization with PostgreSQL as primary target. Useful for designing tables, writing up/down migrations, adding indexes, or optimizing slow SQL.
How this skill is triggered — by the user, by Claude, or both
Slash command
/mk:database [schema|migration|query|optimize] [description]When to use
Use when designing schemas, writing migrations, or optimizing SQL queries (PostgreSQL primary). NOT for ORM/code-level data access patterns.
[schema|migration|query|optimize] [description]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Provides reference-backed guidance for database design tasks. PostgreSQL is the primary
Provides reference-backed guidance for database design tasks. PostgreSQL is the primary target; most patterns apply to MySQL and SQLite with minor syntax differences.
Phase: 1 (Plan) for schema design and migration planning
Phase: 3 (Build) for implementation and query writing
Handoff: Developer implements, reviewer validates per references/migration-patterns.md safety checklist
Determine which task is being requested:
| Task | Load Reference |
|---|---|
| Schema design (new tables, relationships) | references/schema-design.md |
| Migration (up/down, rollback, zero-downtime) | references/migration-patterns.md |
| Query writing or optimization | references/query-optimization.md |
| Multiple tasks | Load all relevant references |
Check the project for database markers:
| Marker | Database |
|---|---|
postgres:// or postgresql:// in env/config | PostgreSQL |
mysql:// or mysql2 package | MySQL |
sqlite3 package or .sqlite file | SQLite |
mongodb:// or mongoose | MongoDB |
If PostgreSQL or unknown → use PostgreSQL syntax (most complete). If MySQL/SQLite → note any syntax differences in the response. MongoDB → schema-design and query-optimization references apply conceptually; migrations differ.
Load the relevant reference file(s) and apply the patterns to the specific task.
Always validate the output against these checks:
Schema checklist:
created_at and updated_at timestamps presentMigration checklist:
Query checklist:
SELECT * in production queriesLIMIT present on unbounded queriesReturn:
NEVER write SQL with string interpolation or template literals — parameterized queries only.
See security-rules.md — SQL injection is a blocked pattern.
-- BLOCKED: string interpolation
WHERE id = ${userId}
-- CORRECT: parameterized
WHERE id = $1 -- PostgreSQL
WHERE id = ? -- MySQL/SQLite
references/schema-design.md — naming, normalization, common patterns, anti-patternsreferences/migration-patterns.md — safe migrations, zero-downtime, rollbackreferences/query-optimization.md — indexing, N+1, EXPLAIN, paginationALTER TABLE users ADD COLUMN verified BOOLEAN NOT NULL acquires an exclusive lock for the full backfill; add the column as nullable first, backfill in batches, then add the NOT NULL constraint with ALTER TABLE ... SET NOT NULL (uses constraint scan, not rewrite, on PG 12+).CREATE INDEX without CONCURRENTLY blocks all writes — a standard index build holds ShareLock; on a table with high write throughput this causes queue buildup in pg_stat_activity; always use CREATE INDEX CONCURRENTLY in production, noting it cannot run inside a transaction block.CASCADE DELETE on a foreign key silently removes child rows across migrations — if a parent row is deleted during a data migration, all FK-cascaded children are gone with no error; audit every FK with ON DELETE CASCADE before batch-deleting seed or test data in production.EXPLAIN ANALYZE executes the query; EXPLAIN does not — running EXPLAIN ANALYZE DELETE FROM ... will delete rows; always wrap in a transaction and rollback, or use EXPLAIN (ANALYZE, BUFFERS) only on SELECT queries unless you understand the side effect.pool_timeout fires; the symptom looks like a slow query but pg_stat_activity shows dozens of idle in transaction connections from callers that forgot to release; always release connections in a finally block.READ COMMITTED) allows non-repeatable reads — two SELECTs in the same transaction can return different rows if another transaction commits between them; use REPEATABLE READ or SERIALIZABLE for financial or inventory operations where consistency across reads matters.npx claudepluginhub ngocsangyem/meowkit --plugin mkProvides best practices for database schema design, query optimization, migrations, indexing, N+1 avoidance, pagination, and transactions across PostgreSQL, MySQL, Oracle, SQLite. Use for schema design, queries, or migrations.
Designs database schemas, indexes, and query optimizations for SQL and NoSQL databases. Guides normalization, migration planning, and N+1 query fixes.
Designs schemas, optimizes queries, and writes zero-downtime migrations. Use when designing entity schemas, diagnosing slow queries, writing migrations, or selecting a database engine.