sql-authoring

sql-authoring is a skill for Claude Code from kouroshez/coding-os. It costs 169 tokens per session (1,559 once invoked), scanned A, original, Apache-2.0.

A guide to writing SQL queries for reading and changing data in relational databases, including joins, pagination, upserts, and query-plan analysis. It also covers parameterized values, which keep user input separate from SQL commands.

In plain words
What is it for?
Use it to write or review SELECT, INSERT, UPDATE, and DELETE statements, read EXPLAIN plans, fix N+1 queries, and move queries between PostgreSQL and MySQL.
Why use it?
It helps avoid incorrect results, slow queries, SQL injection, and inefficient patterns such as sending one query per row.

Skill for Claude Code

Written for Claude Code: paths in frontmatter. Also seen: positional $N argument.

Good fit Use it to write or review SELECT, INSERT, UPDATE, and DELETE statements, read EXPLAIN plans, fix N+1 queries, and move queries between PostgreSQL and MySQL.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kouroshez/coding-os/sql-authoring
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 kouroshez/coding-os --skill sql-authoring
Clone the repo
git clone --depth 1 https://github.com/kouroshez/coding-os

Made for: Claude Code.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/kouroshez/coding-os/sql-authoring.svg)](https://agentmods.dev/skills/kouroshez/coding-os/sql-authoring)
Your own site
<a href="https://agentmods.dev/skills/kouroshez/coding-os/sql-authoring"><img src="https://agentmods.dev/badge/skills/kouroshez/coding-os/sql-authoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 169 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,559 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.00169 $0.01559
Opus 5 $0.00084 $0.00779
Sonnet 5 $0.00034 $0.00312
Haiku 4.5 $0.00017 $0.00156

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

Security

Grade A, and why

sql-authoring 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 5d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/analyze_plan.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

src/core/skills/sql-authoring/SKILL.md · 105 lines

How it starts

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

SQL Authoring

A query is correct, fast, and safe — in that order, none optional. Schema and index design belong to db-design; this skill is the query craft: how to express intent so the planner picks an index, how to read the plan when it doesn't, and how to never hand an attacker a string-built statement.

Read an EXPLAIN plan without eyeballing it: psql -c 'EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) <query>' | python3 scripts/analyze_plan.py

Always parameterize — no exceptions

# Wrong — SQL injection; one apostrophe in `name` and the query breaks or leaks
cur.execute(f"SELECT * FROM users WHERE name = '{name}'")

# Correct — the driver binds; the value never touches the SQL text
cur.execute("SELECT * FROM users WHERE name = %s", (name,))

String-built SQL is the #1 OWASP injection vector — the server-side rules are owned by security-web. The query-craft rule: values are always bind parameters; only identifiers you control (validated against an allow-list) are ever interpolated. An ORM gives you this for free until you reach for raw() — then it's on you.

Think in sets, not rows

-- Wrong — N+1: one query per order, 1000 orders = 1001 round trips
SELECT id FROM orders WHERE user_id = $1;          -- then, per row:
SELECT * FROM line_items WHERE order_id = $1;

-- Correct — one query, the join does the work
SELECT o.id, li.*
FROM orders o
JOIN line_items li ON li.order_id = o.id
WHERE o.user_id = $1;

N+1 is the most common real-world slowness. It hides behind ORM lazy-loading — for order in orders: order.items issues a query per iteration. Fix with a join, a prefetch/selectinload, or an IN (...) batch. Full recipes → references/query-patterns.md.

Index-aware querying (the query's half of the contract)

Index design is db-design's job; using one is yours. A query defeats its own index when it:

  • wraps the indexed column in a function: WHERE lower(email) = $1 skips an index on email (needs an index on lower(email));
  • leads with a wildcard: LIKE '%foo' cannot use a b-tree;
  • mismatches type: WHERE id = '42' (text vs int) may force a cast + seq scan;
  • ORs across columns the planner can't combine — often better as UNION.

Read the full file on GitHub · 105 lines

Files

What ships with it

5 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.

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. 5d ago First seen · 105 lines · 169 tokens per session scan A eecf33a1e897

Subscribe to this mod's changes

sql-authoring is a skill published in the GitHub repository kouroshez/coding-os (6 stars, last pushed yesterday), licensed Apache-2.0. It adds 169 tokens to every session and 1,559 once invoked, about $0.0008 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-09-03.

Related

Other skills, from other repositories

booboo-adapter

Feed data into a Booboo brain that the built-in postgres and json adapters do not cover — write a small config-driven adapter against the spec instead of forking the builder. Use when a source is Neo4j, an API, a CSV export, a proprietary store, or any shape the standard config cannot express.

jessymariau/booboo · 71 tokens

graph-mutation-plan

Cookbook for composing an applygraphmutations plan — stable entitykey patterns, the canonical label/edge vocabulary, evidence/invalidation/confidence discipline, and a worked example. Load this when building a non-trivial mutation plan.

potpie-ai/potpie · 51 tokens

potpie-cli

Use when the task is centered on running, explaining, configuring, or troubleshooting the potpie command: doctor, login, pot management, source registration, search, graph workbench reads/writes, and pot scope behavior.

potpie-ai/potpie · 50 tokens

potpie-change-timeline

Use when an agent needs recent or historical change context: what changed recently, regressions, merged PRs, tickets, docs, incidents, deployments, releases, and source-history ingestion.

potpie-ai/potpie · 43 tokens

potpie-infra-architecture

Use for project infra and architecture context: environments, adapters, runtime configuration, deployments, service dependencies, datastores, API contracts, ownership, incidents, and dependency blast radius.

potpie-ai/potpie · 43 tokens

gonavi-cli

Operate databases through the GoNavi headless CLI — the gonavi executable shipped in verified GitHub Release archives. Covers listing/adding/importing saved connections, running SQL queries against saved connections or ad-hoc connection files, exporting result sets to csv/json/md/html/xlsx, batch-executing SQL files…

Syngnat/GoNavi · 144 tokens