/superskills:db-optimizefrom Superskills
Audits database performance: detects N+1 queries, missing indexes, slow queries, and runs EXPLAIN analysis. Use when asked to optimize the database or find slow queries.
Ships in Superskills. 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.
Comprehensive database performance audit: N+1 detection, EXPLAIN analysis, slow query log review, index gaps, join opportunities, and per-endpoint call counts.
[ -f DBMAP.md ] && echo "DBMAP_EXISTS=true" || echo "DBMAP_EXISTS=false"
If DBMAP_EXISTS=false, tell the user: "No DBMAP.md found. Run /dbmap first to generate a schema map — this audit uses it to cross-reference indexes and table structure."
Check if a slow query log exists or can be accessed:
# PostgreSQL — check pg_stat_statements if available
psql "$DATABASE_URL" -c "SELECT query, calls, total_exec_time, mean_exec_time, rows FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 20;" 2>/dev/null || echo "PG_STAT_UNAVAILABLE"
# MySQL — check slow query log location
mysql -e "SHOW VARIABLES LIKE 'slow_query_log%';" 2>/dev/null || echo "MYSQL_UNAVAILABLE"
If neither is available, scan the codebase for query logging output files:
find . -name "*.log" | xargs grep -l "slow\|duration\|query_time" 2>/dev/null | head -5
Report the 10 slowest queries found, sorted by mean execution time. For each: query text (truncated to 120 chars), call count, mean time (ms), total time (ms).
For each slow query identified in Step 2 (or any query the user provides), run EXPLAIN ANALYZE:
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) <query>;
Interpret the output and flag:
ANALYZE <table>Format findings as:
EXPLAIN: <query summary>
⚠ Seq Scan on orders (5,432 rows) — add index on orders.user_id
⚠ Sort on created_at — add index on events(created_at)
✓ Index Scan on users — OK
Scan the codebase for N+1 patterns:
ORM patterns to flag:
.find, .where, .query, .fetch, .get, .filter, .select).user, .author, .comments, .items etc. on a model instance inside a loop)# Find loops with DB calls inside
grep -rn "for\|each\|map\|forEach\|loop" --include="*.rb" --include="*.py" --include="*.js" --include="*.ts" --include="*.go" --include="*.java" . | head -5
For each file with loop+query patterns, read the surrounding context and determine if it's a true N+1.
Flag as:
⚠ N+1 DETECTED: app/controllers/orders_controller.rb:45
Loop over orders calls order.user on each iteration
Fix: Use includes(:user) / eager_load(:user) / preload(:user)
SQL impact: 1 query → 1+N queries (N = number of orders)
Scan route handlers / controller actions for query counts:
For each endpoint/action found, count the number of distinct DB calls made:
db.query, connection.execute, pool.query.find, .findAll, .where, .first, .save, .create, .updateFlag any endpoint making more than 3 DB calls as a candidate for optimization:
⚠ HIGH DB CALL COUNT: GET /api/orders (OrdersController#index)
8 DB calls detected:
- Order.all (1)
- order.user (N — N+1 pattern)
- order.items (N — N+1 pattern)
Fix: Use a single query with LEFT JOINs or eager loading
Find places where multiple sequential queries fetch related data that could be a single LEFT JOIN:
Pattern: two queries where the second uses IDs from the first result.
💡 JOIN OPPORTUNITY: app/services/dashboard_service.rb:23-31
Query 1: SELECT * FROM orders WHERE user_id = ?
Query 2: SELECT * FROM items WHERE order_id IN (...)
Fix: SELECT o.*, i.* FROM orders o LEFT JOIN items i ON i.order_id = o.id WHERE o.user_id = ?
Output a prioritized findings report:
## DB Optimization Report
### Critical (fix immediately)
- N+1 queries: X found
- Endpoints with >10 DB calls: Y found
### High Priority
- Slow queries (>100ms mean): Z found
- Missing indexes on FK columns: W found (see DBMAP.md Index Analysis)
### Optimization Opportunities
- JOIN consolidations: V found
- EXPLAIN issues: U found
### Recommended next steps
1. [highest impact fix]
2. [second fix]
3. ...
Ask the user: "Want me to implement any of these fixes now? I can start with the highest-impact items."
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ariadoss/superskills --plugin superskills48 skills in this plugin
/a11yAccessibility audit for frontend changes — WCAG 2.2 AA, screen-reader
compatibility, keyboard navigation, focus management, ARIA correctness, color
contrast, and reduced-motion. Static diff-scoped analysis (safe to auto-run) plus
an optional dynamic axe pass against a running app. Use when asked to "check
accessibility", "a11y audit", "screen reader check", "WCAG", "is this
accessible", "keyboard navigation", "ARIA review", or after heavy frontend work.
/articleExtract clean article content from URLs (blog posts, articles, tutorials) and save as readable text. Use when user wants to download, extract, or save an article/blog post from a URL without ads, navigation, or clutter./basic-reviewRead-only correctness review of pending changes, needing no external
install: correctness, security, reliability/performance and contract risk,
each finding cited as file:line with why it is wrong and a fix. The fallback
when gstack's /review is unavailable (not installed, or its install is
broken); /qa-full and /daily-qa call it automatically then. Applies a
vendored copy of gstack's pre-landing checklist. Use when asked for
a "basic review", a "quick review without gstack", or a review in a tool where
/review is missing. Not for quality cleanups (use /clean-code), and not the
first choice when /review is installed: /review goes deeper and applies fixes.
/cache-strategyImplement a permanent cache-first strategy: check cache before hitting the DB,
write to cache on first read, invalidate only when data changes. No TTL timeouts.
Modeled on Play Framework's cache model. Use when asked to "add caching",
"implement cache strategy", "cache DB results", or "reduce DB load".
/clean-codeAudit → fix → verify the branch diff against KISS, DRY, SOLID, and YAGNI.
Finds duplicated logic, units with more than one reason to change, needless
abstraction or speculative extensibility, wrong-altitude code, and dead code
in the changed files — then applies the smallest safe refactor for each,
one atomic commit per fix, under a green test suite. Quality only: it does
not hunt for bugs (use /review or /code-review for that). Use when asked to
"clean up the diff", "simplify this", "DRY this up", "refactor for SOLID",
"remove duplication", "KISS", "YAGNI check", or "tidy before ship".
/cli-for-agentDesign or review CLIs so coding agents can run them reliably: non-interactive
flags first, layered --help with real copy-pasteable examples, stdin/pipeline
support, fail-fast errors that include a correct invocation, idempotency,
--dry-run/--yes for destructive actions, and machine-useful success output.
Use when building a CLI, adding commands or subcommands, writing --help
text, or when asked for an "agent-friendly CLI". Not for GUIs, TUIs, or
library APIs (no CLI surface to design).
Other plugins' skills for the same job