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/rileyhilliard/claude-essentials/writing-sqlnpx skills add rileyhilliard/claude-essentials --skill writing-sqlgit clone --depth 1 https://github.com/rileyhilliard/claude-essentialsWrote 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/rileyhilliard/claude-essentials/writing-sql)<a href="https://agentmods.dev/skills/rileyhilliard/claude-essentials/writing-sql"><img src="https://agentmods.dev/badge/skills/rileyhilliard/claude-essentials/writing-sql.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.00050 | $0.00557 |
| Opus 5 | $0.00025 | $0.00279 |
| Sonnet 5 | $0.00010 | $0.00111 |
| Haiku 4.5 | $0.00005 | $0.00056 |
Grade A, and why
writing-sql 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 — 38 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Writing SQL
Core principle: Every query you write has an execution plan. Write SQL with that plan in mind, not just the result.
This skill covers only what Claude's defaults miss. Topics already handled by managing-databases/postgres-querying.md (LATERAL, CTE materialization, DISTINCT ON, EXPLAIN red flags, ROWS vs RANGE) are not repeated here.
Topic Navigation
| Task | Load |
|---|---|
| Planner picking bad plans on multi-column WHERE | extended-statistics.md |
| LIKE search not using index, text pattern matching | index-internals.md |
| Composite index column ordering, INCLUDE clause | index-internals.md |
| Type mismatch between param and column silently bypassing index | index-internals.md |
| Conditional aggregation, pivot queries, subtotals | aggregation-patterns.md |
| GROUPING SETS, ROLLUP, CUBE | aggregation-patterns.md |
| NULL edge cases in aggregates and window functions | aggregation-patterns.md |
| Paginating large result sets | query-anti-patterns.md |
| NOT IN returning zero rows unexpectedly | query-anti-patterns.md |
| DISTINCT added to fix duplicate rows | query-anti-patterns.md |
| Correlated subqueries in SELECT list | query-anti-patterns.md |
| Functions in WHERE bypassing indexes | query-anti-patterns.md |
Iron Rules
These apply to every query, no exceptions:
- Never paginate with OFFSET on large tables. Use keyset pagination.
- Never use NOT IN when the subquery column is nullable. Use NOT EXISTS.
- Always match parameter types to column types exactly. Implicit casts bypass indexes.
- Replace CASE WHEN inside aggregates with FILTER. It's cleaner and semantically correct.
- When a multi-column WHERE produces bad estimates, add extended statistics before adding hints or rewrites.
What ships with it
4 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.
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 · 38 lines · 50 tokens per session scan A 23cc891a10bf
writing-sql is a skill published in the GitHub repository rileyhilliard/claude-essentials (128 stars, last pushed 17d ago), licensed MIT. It adds 50 tokens to every session and 557 once invoked, about $0.0003 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
safe-sql-execution
Use whenever code will build, return, fetch, or execute SQL that runs against a user's real Postgres database — even when the request reads like an ordinary feature or bug fix and never says "security," "injection," or "SafeSqlFragment." This covers: writing or editing any pg-meta function, query builder, or endpoint…
ecto-patterns
Ecto patterns — schemas, changesets, queries, migrations, Multi, associations, preloads, upserts. Use when editing Repo calls, Ecto.Query, or schema fields. Skip for Ash.
pg-pool-cloudsql-reconnect
Fix Node.js pg-pool not reconnecting after CloudSQL connection reset (ECONNRESET). Use when: (1) Retries fail with same ECONNRESET error despite retry logic, (2) "Connection terminated" or "connection already closed" errors persist across retries, (3) "remaining connection slots are reserved" errors in CloudSQL, (4)…
nw-database-technology-selection
Database comparison catalogs, RDBMS vs NoSQL selection criteria, CAP/ACID/BASE theory, OLTP vs OLAP, and technology-specific characteristics.
database-patterns
DB schema design and query tuning: normalization, indexing, N+1, transactions, EXPLAIN. Triggers: schema, index, slow query, N+1, PostgreSQL, MySQL, EXPLAIN, deadlock, query plan.
software-database-design
Designs database schemas, migrations, and data models for PostgreSQL, MySQL, MongoDB, and Redis. Use when planning tables, relationships, indexes, or ORM-backed schema changes.