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/chandrudp29/skillhub/sql-agentnpx skills add chandrudp29/skillhub --skill sql-agentgit clone --depth 1 https://github.com/chandrudp29/skillhubWhat 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.00035 | $0.01055 |
| Opus 5 | $0.00017 | $0.00528 |
| Sonnet 5 | $0.00007 | $0.00211 |
| Haiku 4.5 | $0.00003 | $0.00105 |
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 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.
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:
- The query itself
- A plain-English explanation of what it does
- 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
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.
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.
- 2d ago First seen · 132 lines · 35 tokens per session scan A 95876066caf7
sql-agent is a skill published in the GitHub repository chandrudp29/skillhub (13 stars, last pushed 2mo ago), licensed MIT. It adds 35 tokens to every session and 1,055 once invoked, about $0.0002 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-30.
Other skills, from other repositories
supabase-postgres
Postgres optimization — 70 rules (queries, indexes, RLS, concurrency). Use when writing SQL or reviewing schema.
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.
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.
sql-optimization
SQL query optimization techniques and best practices.
Database Schema Reviewer
Reviews database schemas for normalization issues, missing indexes, naming inconsistencies, and scalability risks.
SQL Query Optimizer
Reviews SQL queries for performance issues and rewrites them with optimized execution plans.