sql-optimizer

A guide to making SQL database queries faster by examining execution plans, indexes, joins, filters, and analytical features such as window functions and common table expressions.

In plain words
What is it for?
Use it to read EXPLAIN output, choose indexes, rewrite queries, optimize joins and filters, and compare performance before and after changes.
Why use it?
It helps identify the actual cause of slow queries instead of relying on guesswork, including unnecessary scans, poor joins, and stale database statistics.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/futurejj/claude-skills/sql-optimizer
Any agent
npx skills add FutureJJ/claude-skills --skill sql-optimizer
Clone the repo
git clone --depth 1 https://github.com/FutureJJ/claude-skills

Made for: Claude Code, Codex.

Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 411 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00064 $0.00411
Opus 5 $0.00032 $0.00205
Sonnet 5 $0.00013 $0.00082
Haiku 4.5 $0.00006 $0.00041

Measured 2d ago against content hash 899b61dc186b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sql-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/sql-optimizer/SKILL.md · 37 lines

What it actually says

SQL Optimizer

You are a database performance expert who reads EXPLAIN plans like a book.

Workflow

  1. Get the EXPLAIN plan. Always start with EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT).
  2. Find the bottleneck. Look for sequential scans on large tables, nested loops with high row counts, sorts on unindexed columns.
  3. Fix the root cause. Usually: missing index, bad join order, or fetching too many rows.

Core Principles

  • Index for your queries, not your schema. Indexes serve query patterns, not table structure.
  • Covering indexes reduce I/O. Include SELECT columns to avoid table lookups.
  • Filter early, join later. Push WHERE conditions close to base tables.
  • Measure before and after. Compare EXPLAIN output, not gut feeling.

Anti-Patterns

  • SELECT * when you need 3 columns — more I/O, blocks covering indexes
  • Functions on indexed columns (WHERE YEAR(created_at) = 2024) — kills index usage
  • OR conditions spanning different columns — use UNION instead
  • Missing LIMIT on exploratory queries — full table scan on millions of rows
  • Not running ANALYZE after bulk inserts — planner uses stale statistics

Reference Guide

Topic Reference Load When
EXPLAIN plans references/query-plans.md Reading EXPLAIN output, node types
Indexing strategies references/indexing.md Index types, composite indexes, partial indexes
Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 37 lines · 64 tokens per session scan A 899b61dc186b

Subscribe to this mod's changes

sql-optimizer is a skill published in the GitHub repository FutureJJ/claude-skills (3 stars, last pushed 5mo ago), licensed MIT. It adds 64 tokens to every session and 411 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

auth-architect

Designs and implements authentication and identity systems. Covers OAuth2 and OIDC flows including authorization code, PKCE, and client credentials; JWT design including RS256 vs HS256, key rotation, token blacklisting, and refresh token strategy; RBAC and ABAC modeling; SSO with Google, GitHub, and SAML 2.0; session…

mturac/hermes-supercode-skills · 166 tokens

db-whisperer

Diagnoses and improves application-layer databases: Postgres, MySQL, SQLite, and MongoDB. Covers EXPLAIN ANALYZE, slow query detection, index strategy, N+1 detection, schema migrations with up/down scripts, connection pooling, replication setup, and vacuum/analyze operations. Use this skill when the user says "this…

mturac/hermes-supercode-skills · 131 tokens

obs-guardian

Builds observability, monitoring, alerting, and incident visibility for production systems. Covers OpenTelemetry instrumentation for traces, metrics, and logs; structured logging with JSON, correlation IDs, and sampling; Prometheus and Grafana scrape configs, dashboards, and recording rules; distributed tracing with…

mturac/hermes-supercode-skills · 165 tokens

api-sculptor

Designs and implements APIs: REST, GraphQL, gRPC, and WebSocket. Produces OpenAPI 3.1 specs, GraphQL SDL schemas, Protocol Buffer definitions, and working server implementations. Use this skill when the user asks about API design, endpoint structure, schema definition, versioning strategy, pagination, authentication…

mturac/hermes-supercode-skills · 143 tokens

deploy-ninja

Handles zero-downtime deployments: blue-green, canary releases, rolling updates, and feature flag rollouts. Covers Kubernetes, Docker, Cloudflare Workers, Terraform, and CI/CD pipeline setup. Use this skill when the user wants to deploy an application, set up a deployment pipeline, implement canary releases, configure…

mturac/hermes-supercode-skills · 147 tokens

ghost-scraper

Extracts structured data from websites — static HTML, JavaScript-rendered SPAs, paginated listings, and API-backed pages. Handles anti-bot detection awareness, rate limiting, and robots.txt compliance. Use this skill whenever the user wants to scrape a website, extract data from a URL, pull product listings, harvest…

mturac/hermes-supercode-skills · 139 tokens