/claude-db:db-query-patternsfrom Claude DB
Audits SQL query shape anti-patterns: SELECT *, structural N+1, OFFSET pagination, and non-SARGable predicates. Uses grep and EXPLAIN ANALYZE to detect issues that defeat indexes.
Ships in Claude DB. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
How queries are written decides whether the indexes from M11 can even be used. This module inspects
query shape in ORM source and raw SQL. Feeds the Performance & Scale score (axis performance,
relational Query w18, shared with M3/M19).
SELECT * — fetching all columns defeats covering indexes, bloats network/cache, and couples
code to column order. Flag in hot paths.IN. Static detection is directional (the loop's runtime cardinality is
unknown) — it points at the structure, never claims a row count.LIMIT n OFFSET m degrades linearly with depth; deep pagination should use
keyset/seek (WHERE id > $last ORDER BY id LIMIT n).WHERE lower(email)=…,
WHERE date(created_at)=…, leading-wildcard LIKE '%x', implicit type cast) so the index can't be
used. Recommend an expression index or rewriting the predicate. For the leading-wildcard /
LIKE '%x%' case a B-tree can never help — name the remedy: a pg_trgm GIN/GiST index on the
column (or a dedicated search engine for heavy full-text search).Feeds performance only (relational Query w18; Query category in document/time-series/graph profiles).
Grep ORM call sites and raw SQL for SELECT *, function-wrapped indexed columns, leading-wildcard
LIKE, and OFFSET; detect query calls inside loops/.map/per-item relation access for N+1. All
query-pattern findings are at most directional from source — confirming the actual plan/cost needs
runtime (needs_api / Tier-2).
EXPLAIN (ANALYZE, BUFFERS) <the suspect query>;
Method explain_plan. A Seq Scan where an index exists confirms a non-SARGable predicate; the
actual rows × loops confirms an N+1 amplification. Tier-2 pg_stat_statements (ordered by
total_exec_time) surfaces the real hot queries — without it, hotness is directional.
Emit findings per schema/finding.schema.json. Examples:
M13.orders.select_star_hot_path — SELECT * in a frequent read (severity:2, warn, axis
performance, confidence directional, fixable: proposed).M13.users.n_plus_one_posts — per-row relation load in a loop (severity:3, warn, directional,
fixable: advisory — requires app-side eager load / batching).M13.feed.offset_deep_pagination — OFFSET deep paging (severity:2, warn, directional,
fixable: proposed — keyset rewrite).M13.users.non_sargable_lower_email — function-wrapped indexed column (severity:3, warn,
directional, fixable: proposed — expression index or predicate rewrite).Each finding: evidence.observed quotes the query / call site verbatim (secrets redacted);
verification.reproduce is the EXPLAIN above referencing $DATABASE_URL, or a grep for the
pattern; expected_impact is banded + confidence-tagged (no naked %).
SELECT * is harmless on a small lookup or a one-shot admin query — scope severity to hot paths.proposed/advisory,
never auto; expression-index additions can be proposed.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub hainrixz/claude-db --plugin claude-db36 skills in this plugin
/auditAudit a database schema, ORM model, or migrations for design and performance — produces two independent 0-100 scores (Design & Integrity + Performance & Scale) plus a prioritized, evidence-backed report. Read-only; never writes or migrates. Use when the user asks to audit, analyze, review, check, or score a database, schema, data model, migrations, indexes, keys, referential integrity, types, constraints, query patterns, partitioning, or connection pooling — for Postgres, MySQL, Mongo, DynamoDB, Cassandra, pgvector, ClickHouse, Neo4j, and friends./checklistRender a production-readiness GO/NO-GO grid for a database — runs a read-only audit, then maps the findings onto a fixed launch checklist (PITR/backups, RLS on tenant tables, FK indexes, money-as-numeric, timestamptz/UTC, connection pooling sized, migration reversibility, secrets-not-in-schema, charset/utf8mb4). Each row is PASS/WARN/FAIL/NEEDS-LIVE with the finding id, topped by a plain-language verdict. Read-only. Use when the user asks if a database is production-ready, ready to launch/ship, a go/no-go, a pre-launch or readiness checklist, or what to fix before going live./db-antipatternsUnified cross-paradigm anti-pattern catalog (M19) — relational and NoSQL smells that no single structural module owns cleanly: EAV / generic key-value tables, the "god table" with hundreds of columns, comma-separated lists in a column, polymorphic associations without FK, boolean-flag soup, Mongo unbounded array growth, deeply nested documents, the document fan-out / "join in app code" trap, Redis as a relied-on durable primary store. Each finding is re-homed to inherit the natural module's category. Feeds the Design & Integrity AND Performance & Scale scores depending on the smell./db-concurrencyAudit concurrency correctness — transaction isolation level, lost-update / read-modify-write races, queue-worker contention (SKIP LOCKED), and idempotency for key-value / document / wide-column writes. Module M14. Feeds the Performance & Scale score./db-connection-poolingAudit connection management — serverless functions opening direct Postgres connections, transaction-mode pooler misuse (PgBouncer / Supabase / prepared statements), and pool sizing against backend max_connections. Module M15. Feeds the Performance & Scale score./db-constraintsAudit data-integrity constraints — missing NOT NULL on required columns, absent CHECK constraints for domain rules, missing UNIQUE on natural keys, and the over-nullable UNIQUE trap where NULLs silently permit duplicates. Module M5. Feeds the Design & Integrity score (Constraints category).Other plugins' skills for the same job