explain-sql

A guide for turning SQL queries into plain-language explanations, with diagrams and notes about query behavior. SQL is the language used to retrieve and transform data in databases; the guide also covers dbt models, which are SQL files used to build data transformations.

In plain words
What is it for?
Use it when someone provides a SQL query, file path, or dbt model and asks what it does. It explains the query step by step and can show how data moves through it.
Why use it?
It helps developers and analysts understand unfamiliar queries without tracing every join, common table expression, or window calculation themselves. It can also point out performance concerns and common query mistakes.

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

Made for: Claude Code, Codex.

Per session 72 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,480 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.00072 $0.04480
Opus 5 $0.00036 $0.02240
Sonnet 5 $0.00014 $0.00896
Haiku 4.5 $0.00007 $0.00448

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

Security

Grade A, and why

explain-sql 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.

.claude/skills/explain-sql/SKILL.md · 390 lines

How it starts

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

SQL Explained

You are a senior analytics engineer and SQL expert. When given a SQL query, you will produce a comprehensive, human-readable explanation that makes the query understandable to anyone on the team — from junior analysts to principal engineers. Follow every step below.

Step 0: Acquire the Query

Determine the SQL query to explain from one of these sources (in priority order):

  1. Inline paste: The user pastes a query directly after invoking this skill.
  2. File path: The user provides a path like models/marts/fct_orders.sql or queries/revenue.sql. Read the file contents.
  3. dbt model reference: The user provides a dbt model name like fct_orders or stg_payments. Search for the corresponding .sql file under models/ directories using Glob patterns like **/fct_orders.sql.
  4. Interactive: If none of the above, ask the user to provide the query.

If the file is a dbt model (contains {{ ref( or {{ source( or Jinja templating), note this and handle the dbt-specific analysis in Step 7.

Step 1: Dialect Detection

Auto-detect the SQL dialect from syntax clues. Check for these markers:

Dialect Identifying Syntax
PostgreSQL ::type casts, ILIKE, LATERAL, GENERATE_SERIES, RETURNING, ON CONFLICT
MySQL backtick identifiers, LIMIT x, y syntax, IFNULL, GROUP_CONCAT, AUTO_INCREMENT
BigQuery UNNEST, STRUCT, ARRAY_AGG, SAFE_DIVIDE, backtick project.dataset.table, EXCEPT(), DATE_DIFF(..., ..., DAY)
Snowflake FLATTEN, LATERAL FLATTEN, TRY_CAST, OBJECT_CONSTRUCT, QUALIFY, $$ blocks, MATCH_RECOGNIZE
DuckDB EXCLUDE, REPLACE, COLUMNS(*), read_parquet(), read_csv_auto(), PIVOT/UNPIVOT inline
SQL Server TOP N, CROSS APPLY, OUTER APPLY, NOLOCK, @@ROWCOUNT, ISNULL(), + for string concat
Redshift DISTKEY, SORTKEY, DISTSTYLE, UNLOAD, COPY, GETDATE()
Standard SQL None of the above markers detected

Read the full file on GitHub · 390 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. 2d ago First seen · 390 lines · 72 tokens per session scan A f2c96bcf2070

Subscribe to this mod's changes

explain-sql is a skill published in the GitHub repository adityawrk/analytics-with-claude-code (5 stars, last pushed 6mo ago), licensed MIT. It adds 72 tokens to every session and 4,480 once invoked, about $0.0004 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

pr-verify

Verify a Docglow change actually works before submitting or merging a PR. Runs the conformance suite, then a behavioral verification pass (flag matrix, artifact-join spot checks, pipeline contract sweep, payload budget). Use when reviewing a PR, self-reviewing a branch before opening a PR, or when asked to "verify…

docglow/docglow · 79 tokens

developing-incremental-models

Develops and troubleshoots dbt incremental models. Use when working with incremental materialization for: (1) Creating new incremental models (choosing strategy, uniquekey, partition) (2) Task mentions "incremental", "append", "merge", "upsert", or "late arriving data" (3) Troubleshooting incremental failures (merge…

AltimateAI/data-engineering-skills · 112 tokens

altimate-code

Delegates dbt and warehouse work to altimate-code, a specialized CLI agent with 100+ purpose-built data tools. USE THIS SKILL FIRST whenever the task mentions or implies: warehouse access (Snowflake, BigQuery, Redshift, Databricks, Postgres, MySQL, DuckDB), column-level lineage, downstream-impact analysis, dbt builds…

AltimateAI/data-engineering-skills · 184 tokens

debugging-dbt-errors

Debugs and fixes dbt errors systematically. Use when working with dbt errors for: (1) Task mentions "fix", "error", "broken", "failing", "debug", "wrong", or "not working" (2) Compilation Error, Database Error, or test failures occur (3) Model produces incorrect output or unexpected results (4) Need to troubleshoot…

AltimateAI/data-engineering-skills · 112 tokens

documenting-dbt-models

Documents dbt models and columns in schema.yml. Use when working with dbt documentation for: (1) Adding model descriptions or column definitions to schema.yml (2) Task mentions "document", "describe", "description", "dbt docs", or "schema.yml" (3) Explaining business context, grain, meaning of data, or business rules…

AltimateAI/data-engineering-skills · 105 tokens

refactoring-dbt-models

Safely refactors dbt models with downstream impact analysis. Use when restructuring dbt models for: (1) Task mentions "refactor", "restructure", "extract", "split", "break into", or "reorganize" (2) Extracting CTEs to intermediate models or creating macros (3) Modifying model logic that has downstream consumers (4)…

AltimateAI/data-engineering-skills · 108 tokens