sql-agent

sql-agent is a skill for Claude Code, Codex from chandrudp29/skillhub. It costs 35 tokens per session (1,055 once invoked), scanned A, original, MIT.

A guide for writing, improving, and explaining SQL queries, which are instructions for reading or changing data in a database. It covers PostgreSQL, MySQL, SQLite, and BigQuery.

In plain words
What is it for?
It helps write queries, debug performance, interpret query plans, choose indexes, join tables, and design database schemas.
Why use it?
It helps avoid database-specific syntax mistakes and identifies common causes of slow queries or unclear data models.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Codex.

Good fit It helps write queries, debug performance, interpret query plans, choose indexes, join tables, and design database schemas.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chandrudp29/skillhub/sql-agent
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.

Any agent
npx skills add chandrudp29/skillhub --skill sql-agent
Clone the repo
git clone --depth 1 https://github.com/chandrudp29/skillhub

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/chandrudp29/skillhub/sql-agent/github.svg)](https://agentmods.dev/skills/chandrudp29/skillhub/sql-agent)
Your own site
<a href="https://agentmods.dev/skills/chandrudp29/skillhub/sql-agent"><img src="https://agentmods.dev/badge/skills/chandrudp29/skillhub/sql-agent/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sql-agent

Your own site · 80×15
<a href="https://agentmods.dev/skills/chandrudp29/skillhub/sql-agent"><img src="https://agentmods.dev/badge/skills/chandrudp29/skillhub/sql-agent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,055 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00035 $0.01055
Opus 5.5 $0.00014 $0.00422
Sonnet 5.5 $0.00007 $0.00211
Haiku 4.5 $0.00003 $0.00105

Measured 1mo ago against content hash 95876066caf7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-agent 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 1mo 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.

skills/sql-agent/SKILL.md · 132 lines

How it starts

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

SQL Agent

Writes correct, performant SQL and explains what it does. Works with PostgreSQL, MySQL, SQLite, and BigQuery.

When to Use

  • "Write a query to get X"
  • "This query is slow — help me optimize it"
  • "What does this query plan mean?"
  • "Design a schema for X"
  • "How do I join these tables?"

Writing Queries

Step 1 — Clarify before writing

Ask if not obvious:

  • What database? (PostgreSQL, MySQL, SQLite, BigQuery — syntax differs)
  • Approximate row counts? (matters for optimization)
  • What's the expected output format?
  • Are there existing indexes?

Step 2 — Write the query with explanation

Always provide:

  1. The query itself
  2. A plain-English explanation of what it does
  3. What indexes it will use (or should have)

Format:

-- Gets the top 10 customers by revenue in the last 30 days
-- Uses: idx_orders_customer_id, idx_orders_created_at
SELECT 
    c.id,
    c.name,
    SUM(o.total_amount) AS revenue_30d
FROM customers c
INNER JOIN orders o ON c.id = o.customer_id
WHERE o.created_at >= NOW() - INTERVAL '30 days'
  AND o.status = 'completed'
GROUP BY c.id, c.name
ORDER BY revenue_30d DESC
LIMIT 10;

Step 3 — Check for common problems

Before finalizing any query:

N+1 patterns: Is this query inside a loop? Rewrite to fetch in batch.

SELECT *: Specify columns. SELECT * on wide tables fetches data never used.

Missing WHERE clause on updates/deletes: Catastrophic. Always confirm the WHERE clause is intentional.

Implicit type coercion: WHERE id = '123' vs WHERE id = 123 — coercion kills index usage.

NULL behavior: NULL != NULL in SQL. WHERE col != 'value' excludes NULLs. Use IS NULL / IS NOT NULL explicitly.

Optimizing Slow Queries

Step 1 — Get the query plan

EXPLAIN ANALYZE [your query here];

Key things to look for:

  • Seq Scan on a large table = missing index
  • Hash Join on large tables = may need index on join key
  • Nested Loop with high estimated rows = investigate
  • actual rows >> estimated rows = stale statistics, run ANALYZE table_name

Read the full file on GitHub · 132 lines

Files

What ships with it

1 file 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. 1mo ago First seen · 132 lines · 35 tokens per session scan A 95876066caf7

Subscribe to this mod's changes

sql-agent is a skill published in the GitHub repository chandrudp29/skillhub (14 stars, last pushed 3mo ago), licensed MIT. It adds 35 tokens to every session and 1,055 once invoked, about $0.0001 per session on Opus 5.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-30.

Related

Other skills, from other repositories

sql-optimization

A guide to improving SQL queries, the commands used to read and change data in databases. It covers examining how MySQL and PostgreSQL execute queries and designing indexes that help them find data faster.

chaterm/terminal-skills · 10 tokens

database-testing

Database schema validation, data integrity testing, migration testing, transaction isolation, and query performance. Use when testing data persistence, ensuring referential integrity, or validating database migrations.

proffesor-for-testing/agentic-qe · 37 tokens

postgresql-expert

Expert-level PostgreSQL database administration, advanced queries, performance tuning, and production operations. Use when the user mentions database, SQL, or performance, or when the task involves Advanced Data Types, Full-Text Search, Advanced Indexes, or Advanced Queries.

personamanagmentlayer/pcl · 56 tokens

relational-database-design

Designs or reviews a relational database schema for a given domain. Covers table structure, normalization, indexes, constraints, and migration strategy. Invoked when the user asks to design a schema, review a database structure, or optimize a data model.

soulcodex/agentic · 55 tokens

sql-query-optimization

Diagnoses and optimises slow SQL queries using EXPLAIN ANALYZE. Covers identifying bottlenecks (sequential scans, bad estimates, heap fetches), index strategy, query rewrites, and verification. Invoked when the user asks to optimize a query, fix a slow database query, or improve database performance.

soulcodex/agentic · 70 tokens

postgresql

A guide for administering PostgreSQL, a database system that stores application data and supports SQL queries. It covers connections, users and permissions, database objects, backups, extensions, and query optimisation.

chaterm/terminal-skills · 9 tokens