agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what…
Use when a database is the bottleneck. Covers finding the expensive queries, index strategy, lock contention, connection saturation, and the schema decisions that make queries fast or impossible. Trigger on "this query is slow", "the page is slow and i think it's the database",
Claude Code
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill database-performance --agent claude-code
Codex
$ npx skills add nimadorostkar/Claude-Skills-collection --skill database-performance -a codex -y
Cursor
$ npx skills add nimadorostkar/Claude-Skills-collection --skill database-performance -a cursor -y
Gemini CLI
$ npx skills add nimadorostkar/Claude-Skills-collection --skill database-performance -a gemini-cli -y
GitHub Copilot
$ npx skills add nimadorostkar/Claude-Skills-collection --skill database-performance -a github-copilot -y
OpenCode
$ npx skills add nimadorostkar/Claude-Skills-collection --skill database-performance -a opencode -y
Windsurf
$ npx skills add nimadorostkar/Claude-Skills-collection --skill database-performance -a windsurf -y
name: database-performance description: Use when a database is the bottleneck. Covers finding the expensive queries, index strategy, lock contention, connection saturation, and the schema decisions that make queries fast or impossible. Trigger on "this query is slow", "the page is slow and i think it's the database", "deadlocks in production", "too many connections". Do not use for Postgres-specific vacuum, bloat, or pooling — see the postgres skill; for writing the SQL itself, see the sql skill. metadata: category: data version: 1.0.0 tags: [performance, indexing, locks, query-optimization, scaling]
Make the database fast by finding what it is actually spending time on. Database performance work fails when it starts from intuition; it succeeds when it starts from `EXPLAIN ANALYZE` and the slow-query log.
1. **Rank by total time, not by mean** — The query taking 20ms and running 50,000 times per minute is the problem. The 3-second report that runs hourly is not. 2. **Read the plan** — `EXPLAIN (ANALYZE, BUFFERS)`. Look for: a sequential scan on a large table, an estimate that differs from the actual by more than 10x, and a nested loop over many rows. 3. **Fix the biggest thing** — Usually a missing index, an N+1 from the application, or a query that fetches far more rows than it uses. 4. **Check the locks** — If queries are fast in isolation but slow in production, the problem is contention, not the plan. Look at lock waits and long-running transactions. 5. **Size the pool correctly** — More connections is not more throughput. Beyond the point where the database is saturated, additional connections increase latency for everyone. 6. **Re-measure under production-like load** — A query that is fast on a warm cache with 10,000 rows tells you nothing about 10 million.
**Reading a plan for what is actually wrong:**
EXPLAIN (ANALYZE, BUFFERS) SELECT o.id, o.total_cents, c.name FROM orders o JOIN customers c ON c.id = o.customer_id WHERE o.status = 'open' AND o.created_at > now() - interval '7 days' ORDER BY o.created_at DESC LIMIT 50;
Limit (cost=284913.42..284919.26 rows=50) (actual time=3184.221..3184.238 rows=50 loops=1)
-> Sort (actual time=3184.219..3184.229 rows=50 loops=1)
Sort Method: top-N heapsort Memory: 32kB
-> Hash Join (actual time=812.4..3102.8 rows=48,213 loops=1)
-> Seq Scan on orders o (actual time=0.9..2894.1 rows=48,213 loops=1)
Filter: ((status = 'open') AND (created_at > ...))
Rows Removed by Filter: 8,214,502 <-- reading 8.2M rows
Buffers: shared read=184,221 <-- ~1.4 GB from disk
Planning Time: 0.4 ms
Execution Time: 3184.9 msThe diagnosis is in "Rows Removed by Filter": Postgres read 8.2 million rows to return 50. The fix is an index that matches the filter *and* the sort:
CREATE INDEX CONCURRENTLY idx_orders_open_recent ON orders (created_at DESC) WHERE status = 'open'; -- Execution time: 3184ms -> 1.8ms. The partial index is also small enough -- to stay entirely in cache.
**Finding an N+1 from the application side:**
# The database sees 201 fast queries and reports no problem.
# The endpoint takes 900ms. Count queries per request to see it.
with query_counter() as counted:
response = client.get("/orders")
assert counted.total <= 3, f"N+1 detected: {counted.total} queries for one request"A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory,…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling,…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.