Expert SQL & relational databases: queries, schema design, indexing, query-plan optimization, and transactions (Postgres/MySQL/SQLite). Trigger keywords: SQL, database, Postgres, MySQL, SQLite, JOIN, index, EXPLAIN, query plan, slow query, N+1, normalization, transaction, isolation, deadlock, migration. Use for writing/optimizing queries, designing schemas, or fixing slow/locking queries.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sql-expert:sql-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Think in sets, not loops. The database is smarter than your application loop. When something is slow, read the plan (`EXPLAIN ANALYZE`) before guessing — the answer is almost always a missing index or a bad join.
Think in sets, not loops. The database is smarter than your application loop. When something is slow, read the plan (
EXPLAIN ANALYZE) before guessing — the answer is almost always a missing index or a bad join.
nodejs-backend-expert / language skill.rag-expert.software-architect.timestamptz (not naive timestamps), numeric/decimal for money (never float), uuid/bigint keys, native enum/boolean. Enforce integrity at the DB: NOT NULL, UNIQUE, FOREIGN KEY, CHECK — the app is not the only writer.SELECT * in app queries — it breaks covering indexes and over-fetches).SUM/COUNT. Pre-aggregate in a subquery/CTE.WHERE id IN (...) instead of a query per row.EXISTS over IN (subquery) for correlated existence checks; window functions for running totals/ranking instead of self-joins.WHERE, JOIN, and ORDER BY. Composite index order: equality columns first, then the range/sort column. The index serves a left-to-right prefix.WHERE lower(email)=…, WHERE created_at::date=…) defeats a plain index — index the expression or rewrite as a sargable range.EXPLAIN (ANALYZE, BUFFERS). Red flags: seq scan on a large table for a selective filter, row-estimate vs actual far off (stale stats — ANALYZE), nested-loop over huge sets.READ COMMITTED default; SERIALIZABLE for invariants, with retry on serialization failure). Acquire locks in a consistent order to avoid deadlocks.SELECT * in application code → over-fetch, fragile, no covering index.WHERE → full scan.OFFSET 100000) → slow; use keyset/cursor pagination.numeric.Avoid JOIN fan-out with a CTE; keyset pagination
WITH totals AS (
SELECT order_id, SUM(qty * unit_price) AS total
FROM order_items GROUP BY order_id
)
SELECT o.id, o.created_at, t.total
FROM orders o
JOIN totals t ON t.order_id = o.id
WHERE (o.created_at, o.id) < ($1, $2) -- keyset cursor, not OFFSET
ORDER BY o.created_at DESC, o.id DESC
LIMIT 20;
Composite index matching a query
-- WHERE tenant_id = $1 AND status = $2 ORDER BY created_at DESC
CREATE INDEX idx_orders_tenant_status_created
ON orders (tenant_id, status, created_at DESC);
nodejs-backend-expert — calling the DB safely (pooling, parameterization).performance-expert — end-to-end latency and profiling.api-design-expert — cursor pagination contracts backed by SQL.security-expert — parameterization and least-privilege access.Searches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.
Guides Payload CMS config (payload.config.ts), collections, fields, hooks, access control, APIs. Debugs validation errors, security, relationships, queries, transactions, hook behavior.
Implements vector databases with Pinecone, Weaviate, Qdrant, Milvus, pgvector for semantic search, RAG, recommendations, and similarity systems. Optimizes embeddings, indexing, and hybrid search.
npx claudepluginhub miaoge-ge/coding-agent-skills --plugin sql-expert