sql-best-practices

sql-best-practices is a skill for Claude Code, Codex from Omar-Obando/qwen-orchestrator. It costs 41 tokens per session (1,466 once invoked), scanned A, original, MIT.

A guide to writing SQL that is readable, secure, and efficient across database systems.

In plain words
What is it for?
Use it for query formatting, parameterized queries, index-friendly conditions, joins, aggregation, pagination, and preventing N+1 queries.
Why use it?
It helps prevent slow query patterns, repeated database requests, unsafe input handling, and hard-to-maintain formatting.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for query formatting, parameterized queries, index-friendly conditions, joins, aggregation, pagination, and preventing N+1 queries.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/omar-obando/qwen-orchestrator/sql-best-practices
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 Omar-Obando/qwen-orchestrator --skill sql-best-practices
Clone the repo
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator

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-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/omar-obando/qwen-orchestrator/sql-best-practices/github.svg)](https://agentmods.dev/skills/omar-obando/qwen-orchestrator/sql-best-practices)
Your own site
<a href="https://agentmods.dev/skills/omar-obando/qwen-orchestrator/sql-best-practices"><img src="https://agentmods.dev/badge/skills/omar-obando/qwen-orchestrator/sql-best-practices/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-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/omar-obando/qwen-orchestrator/sql-best-practices"><img src="https://agentmods.dev/badge/skills/omar-obando/qwen-orchestrator/sql-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,466 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.00041 $0.01466
Opus 5 $0.00020 $0.00733
Sonnet 5 $0.00008 $0.00293
Haiku 4.5 $0.00004 $0.00147

Measured 9d ago against content hash 4ffe2f0a6451, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

sql-best-practices 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 9d 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-best-practices/SKILL.md · 248 lines

How it starts

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

SQL Best Practices — Every Query a Masterpiece

This skill enforces SQL quality standards: proper indentation, N+1 prevention, parameterized queries, index-friendly patterns, and security.

SQL Indentation Standard

EVERY SQL query MUST be properly indented:

-- ✅ CORRECT: Properly formatted
SELECT
    u.id,
    u.name,
    u.email,
    u.created_at,
    r.name  AS role_name,
    d.name  AS department_name
FROM
    users u
    INNER JOIN roles r
        ON r.id = u.role_id
    LEFT JOIN departments d
        ON d.id = u.department_id
WHERE
    u.deleted_at IS NULL
    AND u.status = 'active'
    AND u.created_at >= '2024-01-01'
ORDER BY
    u.created_at DESC
LIMIT 20
OFFSET 0;
-- ❌ WRONG: No formatting
select id,name,email from users where deleted_at is null and status='active' order by created_at desc limit 20;

Formatting Rules

  1. Keywords: UPPERCASE (SELECT, FROM, WHERE, JOIN, etc.)
  2. Indentation: Each clause on its own line, indented
  3. Columns: One per line in SELECT
  4. JOIN conditions: Indented under the JOIN
  5. WHERE conditions: Aligned AND/OR
  6. Commas: Leading or trailing — pick one, be consistent

N+1 Prevention Patterns

Detection Pattern

If you see a LOOP containing a QUERY, it's likely N+1.
Count queries: 1 (initial) + N (loop) = N+1 problem.

Solution: Eager Loading

-- ❌ N+1: One query per order for items
SELECT * FROM orders WHERE user_id = 123;
-- Then for EACH order:
SELECT * FROM order_items WHERE order_id = ?;

-- ✅ Single query with JOIN
SELECT
    o.id           AS order_id,
    o.total        AS order_total,
    o.status       AS order_status,
    oi.id          AS item_id,
    oi.product_name,
    oi.quantity,
    oi.unit_price
FROM
    orders o
    INNER JOIN order_items oi
        ON oi.order_id = o.id
WHERE
    o.user_id = 123
    AND o.deleted_at IS NULL
ORDER BY
    o.created_at DESC,
    oi.id ASC;

Solution: Batch with IN

-- ❌ N+1: Loop over IDs
SELECT * FROM products WHERE id = 1;
SELECT * FROM products WHERE id = 2;
SELECT * FROM products WHERE id = 3;

-- ✅ Batch: Single query
SELECT
    id,
    name,
    sku,
    price,
    stock_quantity
FROM
    products
WHERE
    id IN (1, 2, 3)
    AND deleted_at IS NULL;

Read the full file on GitHub · 248 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. 9d ago First seen · 248 lines · 41 tokens per session scan A 4ffe2f0a6451

Subscribe to this mod's changes

sql-best-practices is a skill published in the GitHub repository Omar-Obando/qwen-orchestrator (49 stars, last pushed 2mo ago), licensed MIT. It adds 41 tokens to every session and 1,466 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-09-03.