sql-pro

sql-pro is a skill for Claude Code, Codex from eric861129/SKILLS_All-in-one. It costs 115 tokens per session (1,169 once invoked), scanned A, a copy of sql-pro, MIT.

A guide for writing and improving SQL queries and designing database schemas. It covers joins, common table expressions, window functions, indexes, execution plans, and differences between database systems.

In plain words
What is it for?
Use it to write complex queries, review schemas, inspect query plans, add suitable indexes, and troubleshoot database performance.
Why use it?
It helps explain slow queries, avoid inefficient table scans, and choose structures that better support the data and workload.

Skill for Claude CodeCodex

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

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/eric861129/skills_all-in-one/sql-pro
Any agent
npx skills add eric861129/SKILLS_All-in-one --skill sql-pro
Clone the repo
git clone --depth 1 https://github.com/eric861129/SKILLS_All-in-one

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/eric861129/skills_all-in-one/sql-pro.svg)](https://agentmods.dev/skills/eric861129/skills_all-in-one/sql-pro)
Your own site
<a href="https://agentmods.dev/skills/eric861129/skills_all-in-one/sql-pro"><img src="https://agentmods.dev/badge/skills/eric861129/skills_all-in-one/sql-pro.svg" alt="Measured on agentmods" height="20"></a>
Per session 115 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,169 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 92% copy Near-identical to another mod 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.00115 $0.01169
Opus 5 $0.00057 $0.00584
Sonnet 5 $0.00023 $0.00234
Haiku 4.5 $0.00012 $0.00117

Measured 2d ago against content hash 5f265ffc6d63, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

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

Origin

This is a copy

92% identical to sql-pro — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

public/SKILLS/Data & Analysis/sql-pro/SKILL.md · 130 lines

How it starts

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

SQL Pro

Core Workflow

  1. Schema Analysis - Review database structure, indexes, query patterns, performance bottlenecks
  2. Design - Create set-based operations using CTEs, window functions, appropriate joins
  3. Optimize - Analyze execution plans, implement covering indexes, eliminate table scans
  4. Verify - Run EXPLAIN ANALYZE and confirm no sequential scans on large tables; if query does not meet sub-100ms target, iterate on index selection or query rewrite before proceeding
  5. Document - Provide query explanations, index rationale, performance metrics

Reference Guide

Load detailed guidance based on context:

Topic Reference Load When
Query Patterns references/query-patterns.md JOINs, CTEs, subqueries, recursive queries
Window Functions references/window-functions.md ROW_NUMBER, RANK, LAG/LEAD, analytics
Optimization references/optimization.md EXPLAIN plans, indexes, statistics, tuning
Database Design references/database-design.md Normalization, keys, constraints, schemas
Dialect Differences references/dialect-differences.md PostgreSQL vs MySQL vs SQL Server specifics

Quick-Reference Examples

CTE Pattern

-- Isolate expensive subquery logic for reuse and readability
WITH ranked_orders AS (
    SELECT
        customer_id,
        order_id,
        total_amount,
        ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) AS rn
    FROM orders
    WHERE status = 'completed'          -- filter early, before the join
)
SELECT customer_id, order_id, total_amount
FROM ranked_orders
WHERE rn = 1;                           -- latest completed order per customer

Window Function Pattern

-- Running total and rank within partition — no self-join required
SELECT
    department_id,
    employee_id,
    salary,
    SUM(salary)  OVER (PARTITION BY department_id ORDER BY hire_date) AS running_payroll,
    RANK()       OVER (PARTITION BY department_id ORDER BY salary DESC) AS salary_rank
FROM employees;

Read the full file on GitHub · 130 lines

Files

What ships with it

5 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 · 130 lines · 115 tokens per session scan A 5f265ffc6d63

Subscribe to this mod's changes

sql-pro is a skill published in the GitHub repository eric861129/SKILLS_All-in-one (52 stars, last pushed 4mo ago), licensed MIT. It adds 115 tokens to every session and 1,169 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. It is 92% identical to sql-pro, differing in 2 lines, and is treated as a copy.

Related

Other skills, from other repositories

sql-optimization-patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

HermeticOrmus/LibreUIUX-Claude-Code · 44 tokens

rb:constraint-debug

Diagnosing Active Record constraint failures: unique-index, foreign-key, NOT-NULL violations. Triggers: "constraint error", "unique violation", "foreign key", "PG::UniqueViolation".

slbug/claude-ruby-grape-rails · 44 tokens

landing-performance

Fix performance issues in apps/landing for leaderboards, battles, rankings, vote/reaction summaries, and high-cardinality result pages.

conectlens/lenserfight · 30 tokens

ck:fix

Fix a bug using Scout → Diagnose → Fix → Review → Finalize. Use when the user pastes an error message, stack trace, or test failure, or says "fix this bug", "something's broken", "tests are failing", "I'm getting an error". Also accepts --from-quality or --from-test to fix exactly the findings/failures a report lists.…

huuanh20/awesome-ai-agent-skills · 0 tokens

When Stuck - Problem-Solving Dispatch

Dispatch to the right problem-solving technique based on how you're stuck.

huuanh20/awesome-ai-agent-skills · 22 tokens

debug

Structured debugging with hypothesis testing. Observe, hypothesize, verify, fix, explain — teaches debugging methodology via a domain-adapted hint ladder. Defers to .agents/README.md.

xDido/chiron · 40 tokens