sql-expert

sql-expert is a skill for Claude Code, Codex from Miaoge-Ge/coding-agent-skills. It costs 93 tokens per session (1,102 once invoked), scanned A, original, MIT.

A guide to SQL, the language used to read and change data in relational databases such as PostgreSQL, MySQL, and SQLite. It covers database structure, indexes, query plans, and transactions.

In plain words
What is it for?
Use it to write or improve queries, design tables and relationships, add indexes, investigate slow queries, and handle transactions, locks, and migrations.
Why use it?
It helps find why database operations are slow or incorrect and supports safer choices about data structure and concurrent changes.

Skill for Claude CodeCodex

Part of the sql-expert plugin — 1 skill shipped together

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/miaoge-ge/coding-agent-skills/sql-expert
Any agent
npx skills add Miaoge-Ge/coding-agent-skills --skill sql-expert
Clone the repo
git clone --depth 1 https://github.com/Miaoge-Ge/coding-agent-skills

Made for: Claude Code, Codex.

Or install sql-expert, the plugin that ships this one along with the rest of its 1 skill.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/miaoge-ge/coding-agent-skills/sql-expert.svg)](https://agentmods.dev/skills/miaoge-ge/coding-agent-skills/sql-expert)
Your own site
<a href="https://agentmods.dev/skills/miaoge-ge/coding-agent-skills/sql-expert"><img src="https://agentmods.dev/badge/skills/miaoge-ge/coding-agent-skills/sql-expert.svg" alt="Measured on agentmods" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,102 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.00093 $0.01102
Opus 5 $0.00046 $0.00551
Sonnet 5 $0.00019 $0.00220
Haiku 4.5 $0.00009 $0.00110

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

Security

Grade A, and why

sql-expert 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 4d 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.

plugins/sql-expert/skills/sql-expert/SKILL.md · 79 lines

How it starts

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

SQL & Database Expert

Think in sets, not loops. The database is smarter than your application loop. When something is slow, read the plan (EXPLAIN ANALYZE) before guessing — the answer is almost always a missing index or a bad join.

When to Use

  • Writing, debugging, or optimizing SQL.
  • Schema design: tables, relationships, constraints, types, migrations.
  • Slow queries, missing/unused indexes, N+1, lock contention.
  • Transactions, isolation levels, and concurrency correctness.

When NOT to Use

  • ORM/app wiring → nodejs-backend-expert / language skill.
  • Vector/semantic retrieval → rag-expert.
  • Data-platform / warehouse-scale architecture → software-architect.

Core Principles

1. Schema design

  • Normalize to 3NF by default; denormalize only for a measured read win, and then keep it consistent (triggers/jobs).
  • Right types: timestamptz (not naive timestamps), numeric/decimal for money (never float), uuid/bigint keys, native enum/boolean. Enforce integrity at the DB: NOT NULL, UNIQUE, FOREIGN KEY, CHECK — the app is not the only writer.

2. Query like a pro

  • Select only needed columns (no SELECT * in app queries — it breaks covering indexes and over-fetches).
  • Know your JOINs and beware fan-out: a one-to-many join multiplies rows and inflates SUM/COUNT. Pre-aggregate in a subquery/CTE.
  • Kill N+1 patterns: one query with a JOIN or WHERE id IN (...) instead of a query per row.
  • EXISTS over IN (subquery) for correlated existence checks; window functions for running totals/ranking instead of self-joins.

3. Indexing

  • Index columns in WHERE, JOIN, and ORDER BY. Composite index order: equality columns first, then the range/sort column. The index serves a left-to-right prefix.
  • A function/expression on the column (WHERE lower(email)=…, WHERE created_at::date=…) defeats a plain index — index the expression or rewrite as a sargable range.
  • Indexes speed reads, slow writes, and use space — add deliberately. Drop unused ones. Use partial/covering indexes for hot queries.

Read the full file on GitHub · 79 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. 4d ago First seen · 79 lines · 93 tokens per session scan A 5b65f02c4e82

Subscribe to this mod's changes

sql-expert is a skill published in the GitHub repository Miaoge-Ge/coding-agent-skills (5 stars, last pushed 3mo ago), licensed MIT. It adds 93 tokens to every session and 1,102 once invoked, about $0.0005 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

review-database

Review database usage for migration safety, query performance, connection/transaction management, and schema design. Covers PostgreSQL and MySQL. Runs squawk for PostgreSQL migration linting if available. Use when the user asks for a database review, SQL review, migration review, or schema review.

paultyng/skill-issue · 62 tokens

bitrix-postgresql

Covers PostgreSQL support in Bitrix — PgsqlConnection, migration from MySQL, compatible code, module support matrix. Applied when configuring or migrating to PostgreSQL Enterprise editions. Key terms — PostgreSQL, PgsqlConnection, migration, compatible-code.

bxmaximum/bitrix-framework-skills · 56 tokens

sql_mastery

CREATE OR REPLACE PROCEDURE sprefreshattributiondaily() LANGUAGE plpgsql AS $$ BEGIN -- 1. Truncate Staging TRUNCATE TABLE stgdailytraffic.

MidOSresearch/midos · 0 tokens

skill-gamma

A completely different skill for database operations. Use when working with PostgreSQL queries, schema design, or database migrations.

JuanJoseGonGi/skill-compact · 27 tokens

ai-prompt-evaluator

Activate when designing, evaluating, red-teaming, and refining LLM system prompts, agent instructions, structured JSON schemas, and defense boundaries against prompt injections and hallucinations — trigger phrasings include "evaluate my system prompt", "red-team this AI prompt", "improve my prompt to prevent…

ieeecsopen/mcp-cs · 109 tokens

clickhouse-io

ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

deepelementlab/jupyter-studio · 26 tokens