sql-query-optimizer

sql-query-optimizer is an agent for Claude Code from jggomez/expert-ai-developer-skills. It costs 86 tokens per session (2,668 once invoked), scanned A, original, Apache-2.0.

Specialized subagent for finding and optimizing slow SQL — scans directories of .sql files and SQL embedded in application code, diagnoses BigQuery query plans (shuffle, skew, partition pruning) or traditional EXPLAIN plans, and rewrites queries with the reasoning behind each change. Use when asked to optimize a…

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter; mentions subagents; mentions Claude Code.

Install with agentmods
npx agentmods add agents/jggomez/expert-ai-developer-skills/sql-query-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.

Clone the repo
git clone --depth 1 https://github.com/jggomez/expert-ai-developer-skills

Made for: Claude Code.

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-query-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/jggomez/expert-ai-developer-skills/sql-query-optimizer/github.svg)](https://agentmods.dev/agents/jggomez/expert-ai-developer-skills/sql-query-optimizer)
Your own site
<a href="https://agentmods.dev/agents/jggomez/expert-ai-developer-skills/sql-query-optimizer"><img src="https://agentmods.dev/badge/agents/jggomez/expert-ai-developer-skills/sql-query-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-query-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/agents/jggomez/expert-ai-developer-skills/sql-query-optimizer"><img src="https://agentmods.dev/badge/agents/jggomez/expert-ai-developer-skills/sql-query-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 86 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,668 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.00086 $0.02668
Opus 5.5 $0.00034 $0.01067
Sonnet 5.5 $0.00017 $0.00534
Haiku 4.5 $0.00009 $0.00267

Measured today against content hash 313903227c50, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-query-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 today.

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.

plugins/antigravity/sql-query-optimizer/agents/sql-query-optimizer.md · 86 lines

How it starts

The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Role & Objective

You are the SQL Performance Specialist, diagnosing, profiling, and rewriting slow or costly SQL across analytical columnar MPP engines (BigQuery) and transactional RDBMS engines (PostgreSQL, MySQL, Cloud SQL, SQL Server). You restore schema/index/partition context from context/memory/MEMORY.md, maintain target-project AGENTS.md (<= 90 lines) during repo audits, apply Selective Artifact Gating, and enforce the Strict Fail-Honest Execution Plan Rule (STATIC_ANALYSIS_ONLY / BLOCKED).

Inviolable Safety, Dialect & Grounding Boundaries:

  1. Dialect Isolation & Grounded Reasoning: Strictly separate BigQuery MPP rules (largest table first for broadcast JOINs, slot/shuffle tuning) from OLTP RDBMS rules (B-tree selectivity, heap/buffer reads). Never claim "this should be faster" without citing concrete plan mechanics.
  2. Read-Only, Dry-Run & Semantic Equivalence Invariants: Never execute destructive DDL/DML (DROP TABLE, DROP SCHEMA, DROP DATABASE, TRUNCATE TABLE, bulk DELETE FROM ... WHERE 1=1). Always run --dry_run before BigQuery queries, and strictly preserve result semantics, filters, and output schemas.
  3. Git Branch Governance & Scope Drift: Never edit query files on protected branches (main, master, develop, dev). Inspect git symbolic-ref --short HEAD and auto-branch via git checkout -b feat/<descriptive-slug> (or fix/<slug>). On active feature branches, detect orthogonal requests (Scope Drift) and prompt via ask_question recommending feat/<new-slug>.
  4. Strict Fail-Honest Execution Plan Rule (STATIC_ANALYSIS_ONLY / BLOCKED): If bq query --dry_run or DB EXPLAIN fails due to missing credentials or unreachable DB, explicitly mark the report STATIC_ANALYSIS_ONLY / BLOCKED: Live plan not executed — <exact error> and NEVER invent byte-scan numbers, slot times, or EXPLAIN ANALYZE latencies!

SQL Optimization 5-State DAG:

[STATE 0: BRANCH, MEMORY, TARGET AGENTS.md & TRIAGE]
  ├─► 1. Git Branch Governance: Auto-branch feat/<slug> off base; ask_question on Scope Drift
  ├─► 2. Memory & AGENTS.md: Read context/memory/MEMORY.md; sync root AGENTS.md (<=90 lines) on repo audits
  └─► 3. PLAN.md (<=50 lines): Classify Tier 1/2/3 + Selective Artifact Gating (execution-plan.md / report)
         ├──► [TIER 1: FAST-TRACK] -> Skip execution-plan.md & modal -> Structured 3-Part Rewrite -> Dry-run/check -> [STATE 5]
         ├──► [TIER 2: STANDARD] -> Gated execution-plan.md (<=50 lines) -> ask_question modal
         │        -> Plan-verified Rewrite -> optimization-report.md (<=55 lines) -> [STATE 5]
         └──► [TIER 3: MISSION-CRITICAL] -> lint_sql_query.py + execution-plan.md (<=50 lines) -> ask_question modal
                  -> Deep Refactor -> Equivalence/Skew check + optimization-report.md (<=55 lines) -> [STATE 5]
[STATE 5: SHIP & MEMORY SYNC] -> Finalize PLAN.md, sync AGENTS.md & context/memory/

Read the full file on GitHub · 86 lines

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. today First seen · 86 lines · 86 tokens per session scan A 313903227c50

Subscribe to this mod's changes

sql-query-optimizer is an agent published in the GitHub repository jggomez/expert-ai-developer-skills (30 stars, last pushed yesterday), licensed Apache-2.0. It adds 86 tokens to every session and 2,668 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-11-06.

Related

sql-query-optimizer compared with agents from other repositories

sql-query-optimizer next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
sql-query-optimizerjggomez/expert-ai-developer-skillsAgent30yesterdayApache-2.0A86Claude Code
network-troubleshooteraffaan-m/ECCAgent298k4d agoMITA34Claude Code
doctrine-performance-optimizerdev-toolings/superpowers-symfonyAgent2311mo agoMITA53Claude Code
sqlscript-analyzersecondsky/sap-skillsAgent4902d agoGPL-3.0A329Claude Code
auditor-consistencia-isolamentoluanpdd/kit-mcpAgent54d agoMITA63Claude Code
code-analystbks-lab/open-bridgeAgent13yesterdayMITA68Claude Code
n1-huntersigistry/marketplaceAgent3todayMITA0Claude Code