sql-insight

sql-insight is a skill for Claude Code, Codex from zebbern/claude-code-guide. It costs 64 tokens per session (1,966 once invoked), scanned A, original, MIT.

A helper that turns plain-language questions into SQL for SQLite and PostgreSQL, then checks queries and explains their execution plans. An execution plan shows how a database intends to find and return the requested rows.

In plain words
What is it for?
Use it to extract schema details, create SQL from questions, review query patterns, suggest optimizations, and interpret EXPLAIN output.
Why use it?
It helps write queries that match the database structure and find causes of slow performance, such as full table scans or missing indexes.

Skill for Claude CodeCodex

About the project

Claude Code Guide is a reference collection for configuring and using Claude Code, Anthropic’s command-line coding agent. Developers use it to learn commands, skills, agents, MCP, automation, security, integrations, and troubleshooting. Its catalogue add-ons provide many of the documented skills and agents.

zebbern/claude-code-guide · 4,600 stars · on GitHub

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/zebbern/claude-code-guide/sql-insight
Any agent
npx skills add zebbern/claude-code-guide --skill sql-insight
Clone the repo
git clone --depth 1 https://github.com/zebbern/claude-code-guide

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-insight

README.md
[![agentmods](https://agentmods.dev/badge/skills/zebbern/claude-code-guide/sql-insight.svg)](https://agentmods.dev/skills/zebbern/claude-code-guide/sql-insight)
Your own site
<a href="https://agentmods.dev/skills/zebbern/claude-code-guide/sql-insight"><img src="https://agentmods.dev/badge/skills/zebbern/claude-code-guide/sql-insight.svg" alt="Measured on agentmods" 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 1,966 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.01966
Opus 5 $0.00032 $0.00983
Sonnet 5 $0.00013 $0.00393
Haiku 4.5 $0.00006 $0.00197

Measured yesterday against content hash d3350c171fb6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sql-insight 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 yesterday.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/sql_query_helper.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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-insight/SKILL.md · 212 lines

How it starts

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

sql-insight

SQL query assistant — natural language to SQL translation, query optimization analysis, and EXPLAIN plan interpretation.

Capabilities

Feature Description
Schema Extraction Extracts database table structure (columns, types, indexes, foreign keys, sample data) to provide context for NL→SQL
Natural Language → SQL Translates natural language descriptions into SQL queries using schema context
Query Optimization Analysis Detects SQL anti-patterns based on 13 rules and provides optimization suggestions
EXPLAIN Interpretation Runs EXPLAIN and interprets the query plan, identifying full table scans, missing indexes, and more

Workflow

Natural Language → SQL

  1. Use the schema command to extract the database table structure
  2. Use the schema as context to translate the user's natural language request into SQL
  3. Use the optimize command to check if the generated SQL can be improved
  4. Use the explain command to verify the query execution plan
# Step 1: Extract schema (compact mode, suitable for LLM context)
python3 scripts/sql_query_helper.py --db-path data.db schema --compact

# Step 2: Analyze SQL optimization suggestions
python3 scripts/sql_query_helper.py optimize "SELECT * FROM orders WHERE user_id = 100"

# Step 3: View EXPLAIN execution plan
python3 scripts/sql_query_helper.py --db-path data.db explain "SELECT * FROM orders WHERE user_id = 100"

Quick Start

Schema Extraction

# Extract full schema (JSON format, with sample data)
python3 scripts/sql_query_helper.py --db-path data.db schema

# Compact mode (plain text, suitable for embedding in prompts)
python3 scripts/sql_query_helper.py --db-path data.db schema --compact

# Skip data sampling
python3 scripts/sql_query_helper.py --db-path data.db schema --sample-rows 0

# PostgreSQL
python3 scripts/sql_query_helper.py --db-type postgres --dsn "host=localhost dbname=mydb user=reader" schema --compact

Read the full file on GitHub · 212 lines

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. yesterday First seen · 212 lines · 64 tokens per session scan A d3350c171fb6

Subscribe to this mod's changes

sql-insight is a skill published in the GitHub repository zebbern/claude-code-guide (4,600 stars, last pushed yesterday), licensed MIT. It adds 64 tokens to every session and 1,966 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-09-03.

Related

Other skills, from other repositories

rag

Use when setting up LibreChat RAG (Retrieval-Augmented Generation), configuring embeddings providers, setting up file search in agents, configuring PGVector/PostgreSQL for vector storage, or troubleshooting document indexing and retrieval. Also use when users ask about 'chat with documents' or 'file search' features.

bethanychamberlain/claude-skills-librechat · 63 tokens

dev-supabase

Backend development with Supabase. Trigger when the user wants to configure auth, the database, or Supabase storage.

christopherlouet/claude-base · 28 tokens

ops-database

Database schema design. Trigger when the user wants to create tables, migrations, or optimize queries.

christopherlouet/claude-base · 23 tokens

cli-audit-data

Audit PostgreSQL database safety in Rust/SQLx applications. Use for schemas, migrations, constraints, indexes, transactions, repositories, state transitions, idempotency, concurrency, queues, multi-tenancy, soft deletion, ledgers, auditability, repair, database incidents, or whenever SQLx and PostgreSQL changes could…

Destynova2/cli-code-skills · 85 tokens

cli-forge-data

Design and implement safe PostgreSQL database changes for Rust/SQLx applications. Use for new schemas, migrations, constraints, indexes, repositories, transaction boundaries, state machines, idempotency, concurrency control, queues, multi-tenancy, soft deletion, ledgers, outbox/inbox, repair jobs, or corrections…

Destynova2/cli-code-skills · 76 tokens

ccc-pro-migration

Zero-downtime schema versioning, backfills, and safe deploy patterns · Pro tier only.

KevinZai/commander · 24 tokens