sql-optimizer

sql-optimizer is a skill for Claude Code, Codex from FutureJJ/claude-skills. It costs 64 tokens per session (411 once invoked), scanned A, original, MIT.

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

Written for no agent in particular: nothing here depends on one.

Good fit Use it to read EXPLAIN output, choose indexes, rewrite queries, optimize joins and filters, and compare performance before and after changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/futurejj/claude-skills/sql-optimizer
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.

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.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sql-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/futurejj/claude-skills/sql-optimizer/github.svg)](https://agentmods.dev/skills/futurejj/claude-skills/sql-optimizer)
Your own site
<a href="https://agentmods.dev/skills/futurejj/claude-skills/sql-optimizer"><img src="https://agentmods.dev/badge/skills/futurejj/claude-skills/sql-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sql-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/skills/futurejj/claude-skills/sql-optimizer"><img src="https://agentmods.dev/badge/skills/futurejj/claude-skills/sql-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00064 $0.00411
Opus 5.5 $0.00026 $0.00164
Sonnet 5.5 $0.00013 $0.00082
Haiku 4.5 $0.00006 $0.00041

Measured 1mo ago against content hash 899b61dc186b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 7mo ago), licensed MIT. It adds 64 tokens to every session and 411 once invoked, about $0.0003 per session on Opus 5.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

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

pipeline-architect

Designs and implements data pipelines: ETL/ELT, streaming, batch processing, schema migrations, and data warehouse architecture. Covers Kafka, Airflow, dbt, Spark, ClickHouse, BigQuery, Snowflake, Redis Streams, and more. Use this skill when the user asks about data pipelines, ETL jobs, data transformation, streaming…

mturac/hermes-supercode-skills · 148 tokens

swift-persistence

Implements a persistence layer using SwiftData or CoreData following MVVM — models, repository abstraction, and testable in-memory setup. Use when user says "add CoreData", "set up SwiftData", "persist data", "save to database", "add a data model", "create Core Data entities", or "use SwiftData models".

jeremieb/swift-unit-test-instructions · 74 tokens

offensive-sqli

SQL injection testing skill for offensive security assessments and bug bounty hunting. Covers error-based, UNION-based, boolean/time-based blind, out-of-band, second-order, NoSQL, GraphQL, WebSocket, and JSON-operator SQLi. Includes WAF bypass techniques, database-specific exploitation (MySQL, MSSQL, PostgreSQL…

SnailSploit/Claude-Red · 117 tokens

mssql

Execute read-only SQL queries against multiple Microsoft SQL Server databases. Use when: (1) querying MSSQL/SQL Server databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent…

sanjay3290/ai-skills · 84 tokens

mysql

Execute read-only SQL queries against multiple MySQL databases. Use when: (1) querying MySQL databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent auto-selection. Blocks…

sanjay3290/ai-skills · 79 tokens