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.
npx agentmods add skills/miaoge-ge/coding-agent-skills/sql-expertnpx skills add Miaoge-Ge/coding-agent-skills --skill sql-expertgit clone --depth 1 https://github.com/Miaoge-Ge/coding-agent-skillsWrote 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.
[](https://agentmods.dev/skills/miaoge-ge/coding-agent-skills/sql-expert)<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>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.
| Model | Per session | Once 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 |
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.
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/decimalfor money (never float),uuid/bigintkeys, nativeenum/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. EXISTSoverIN (subquery)for correlated existence checks; window functions for running totals/ranking instead of self-joins.
3. Indexing
- Index columns in
WHERE,JOIN, andORDER 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.
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.
- 4d ago First seen · 79 lines · 93 tokens per session scan A 5b65f02c4e82
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.
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.
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.
sql_mastery
CREATE OR REPLACE PROCEDURE sprefreshattributiondaily() LANGUAGE plpgsql AS $$ BEGIN -- 1. Truncate Staging TRUNCATE TABLE stgdailytraffic.
skill-gamma
A completely different skill for database operations. Use when working with PostgreSQL queries, schema design, or database migrations.
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…
clickhouse-io
ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.