Staff+ DBA SQL patterns targeting what Claude's defaults miss - multi-column statistics, operator classes, keyset pagination, silent performance anti-patterns.

MITAuto-check passedDatabases

Install Writing SQL

skills CLI
$ npx skills add rileyhilliard/claude-essentials --skill writing-sql -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rileyhilliard/claude-essentials writing-sql --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rileyhilliard/claude-essentials.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/ce/skills/writing-sql .claude/skills/writing-sql && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
writing-sql
GitHub stars
130
Token cost
~627 tokens
SKILL.md length
211 words
Files
5 (incl. references)
Skills in repo
17
Repo updated
First seen
Licence
MIT

At a glance

Staff+ DBA SQL patterns targeting what Claude's defaults miss - multi-column statistics, operator classes, keyset pagination, silent performance anti-patterns.

  • Writing complex SQL
  • SKILL.md covers Topic Navigation and Iron Rules
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Reviewing queries

What it does

Writing SQL is an agent skill from rileyhilliard/claude-essentials. Staff+ DBA SQL patterns targeting what Claude's defaults miss - multi-column statistics, operator classes, keyset pagination, silent performance anti-patterns. Use when writing complex SQL, reviewing queries, adding indexes, or optimizing slow queries.

Its SKILL.md is about 630 tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/aggregation-patterns.md`, `references/extended-statistics.md` and `references/index-internals.md`).

It sits in Databases, covering SQL, Statistics and Query optimization. It works with SQL. The licence is MIT.

When your agent uses it

  • Writing complex SQL
  • Reviewing queries
  • Optimizing slow queries

Example prompts

  • “/writing-sql”

What it can do on your machine

Read from SKILL.md and the folder at commit 3a67a01. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Writing SQL loads about 627 tokens when it runs, and up to ~6.8k if it reads all its reference files. Until then it costs about 66 tokens; SKILL.md has 211 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~66
When it runs · the whole SKILL.md, loaded when a task matches
~627
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rileyhilliard/claude-essentials at commit 3a67a01, republished under its MIT licence (© rileyhilliard). 211 words, ~627 tokens.

Download SKILL.mdSave it as .claude/skills/writing-sql/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
writing-sql
description
Staff+ DBA SQL patterns targeting what Claude's defaults miss - multi-column statistics, operator classes, keyset pagination, silent performance anti-patterns. Use when writing complex SQL, reviewing queries, adding indexes, or optimizing slow queries.

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

TaskLoad
Planner picking bad plans on multi-column WHEREextended-statistics.md
LIKE search not using index, text pattern matchingindex-internals.md
Composite index column ordering, INCLUDE clauseindex-internals.md
Type mismatch between param and column silently bypassing indexindex-internals.md
Conditional aggregation, pivot queries, subtotalsaggregation-patterns.md
GROUPING SETS, ROLLUP, CUBEaggregation-patterns.md
NULL edge cases in aggregates and window functionsaggregation-patterns.md
Paginating large result setsquery-anti-patterns.md
NOT IN returning zero rows unexpectedlyquery-anti-patterns.md
DISTINCT added to fix duplicate rowsquery-anti-patterns.md
Correlated subqueries in SELECT listquery-anti-patterns.md
Functions in WHERE bypassing indexesquery-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.

© rileyhilliard, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in plugins/ce/skills/writing-sql of rileyhilliard/claude-essentials.

  • SKILL.md
  • references/aggregation-patterns.md
  • references/extended-statistics.md
  • references/index-internals.md
  • references/query-anti-patterns.md

Open the folder on GitHubat commit 3a67a01

Compare with similar skills

Writing SQL next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Writing SQL compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Writing SQL this skillrileyhilliard/claude-essentials130—~627Automated safety check: PassMIT
SQL Optimization Patternsynulihao/AgentSkillOS61710 repos~3.3kAutomated safety check: PassNone
Query Engine Designrevfactory/claude-code-harness120—~474Automated safety check: PassNone
SQL Optimization Patternssickn33/agentic-awesome-skills47k1 repos~566Automated safety check: PassMIT
SQL Database Assistantborghei/Claude-Skills874—~1.5kAutomated safety check: PassMIT
SQL Optimization InterviewerPrepLabsAI/InterviewMentor112—~2.1kAutomated safety check: PassMIT

Similar skills

  • SQL Optimization Patterns

    ynulihao/AgentSkillOS

    Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.

    617 GitHub starsUsed in 10 repos~3.3k tokens
    DatabasesAuto-check passed
  • Query Engine Design

    revfactory/claude-code-harness

    SQL query engine design and implementation guide. An agent skill from revfactory/claude-code-harness.

    120 GitHub stars~474 tokensUpdated 7 mo ago
    DatabasesAuto-check passed
  • SQL Optimization Patterns

    sickn33/agentic-awesome-skills

    Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.

    47k GitHub starsUsed in 1 repo~566 tokens
    DatabasesAuto-check passed
  • SQL Database Assistant

    borghei/Claude-Skills

    This skill should be used when the user asks to "optimize SQL queries", "explore database schemas", "generate migration SQL", "analyze query performance", or "document database structure".

    874 GitHub stars~1.5k tokensUpdated yesterday
    DatabasesAuto-check passed
  • SQL Optimization Interviewer

    PrepLabsAI/InterviewMentor

    A Data Engineering interviewer focused on database performance.

    112 GitHub stars~2.1k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Query Optimize

    lazyFrogLOL/Harness_Engineering

    Guidance for SQL query optimization tasks. An agent skill from lazyFrogLOL/Harness_Engineering.

    128 GitHub stars~2.1k tokensUpdated 4 mo ago
    DatabasesAuto-check passed

More from rileyhilliard/claude-essentials

All 17 skills in this repo
  • Handling Errors

    rileyhilliard/claude-essentials

    Prevents silent failures and context loss in error handling.

    130 GitHub stars~632 tokensUpdated 1 mo ago
    Auto-check passed
  • Planning Products

    rileyhilliard/claude-essentials

    Defines product features from a PM perspective (JTBD, competitive research, scope negotiation) before technical planning.

    130 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Writing Tests

    rileyhilliard/claude-essentials

    Writes behavior-focused tests using Testing Trophy model with real dependencies.

    130 GitHub stars~999 tokensUpdated 1 mo ago
    Auto-check passed
  • Optimizing Performance

    rileyhilliard/claude-essentials

    Measure-first performance optimization that balances gains against complexity.

    130 GitHub stars~470 tokensUpdated 1 mo ago
    Auto-check passed
  • Architecting Systems

    rileyhilliard/claude-essentials

    Guides clean, scalable system architecture during the build phase.

    130 GitHub stars~713 tokensUpdated 1 mo ago
    Auto-check passed
  • Design

    rileyhilliard/claude-essentials

    Enforces precise, minimal design for dashboards and admin interfaces.

    130 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Categories

Questions about Writing SQL

What does Writing SQL do?

Staff+ DBA SQL patterns targeting what Claude's defaults miss - multi-column statistics, operator classes, keyset pagination, silent performance anti-patterns. Writing SQL is an agent skill from rileyhilliard/claude-essentials. Staff+ DBA SQL patterns targeting what Claude's defaults miss - multi-column statistics, operator classes, keyset pagination, silent performance anti-patterns.

When should I use Writing SQL?

Writing SQL fits situations like: writing complex SQL; reviewing queries; optimizing slow queries.

How do I install Writing SQL in Claude Code?

Run `npx skills add rileyhilliard/claude-essentials --skill writing-sql -a claude-code`. Or copy the skill folder (plugins/ce/skills/writing-sql in rileyhilliard/claude-essentials) into .claude/skills/writing-sql in your project. Claude Code loads it when a task matches its description.

How do I install Writing SQL in Codex?

Run `npx skills add rileyhilliard/claude-essentials --skill writing-sql -a codex`. Or copy the skill folder (plugins/ce/skills/writing-sql in rileyhilliard/claude-essentials) into .agents/skills/writing-sql in your project. Codex loads it when a task matches its description.

Can I use Writing SQL in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rileyhilliard/claude-essentials --skill writing-sql -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/writing-sql, .gemini/skills/writing-sql, .github/skills/writing-sql and .opencode/skills/writing-sql in your project.

What does Writing SQL need to run?

SKILL.md names no scripts, command-line tools or credentials: Writing SQL is instructions for the agent only.

Does Writing SQL access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Writing SQL safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Writing SQL use?

Writing SQL is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Writing SQL use?

About 627 tokens (SKILL.md is roughly 2.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 6.2k tokens, read only when the agent opens those files.

What are the alternatives to Writing SQL?

Skills that share tags, products or a category with Writing SQL: SQL Optimization Patterns (ynulihao/AgentSkillOS, 617 stars), Query Engine Design (revfactory/claude-code-harness, 120 stars), SQL Optimization Patterns (sickn33/agentic-awesome-skills, 47k stars) and SQL Database Assistant (borghei/Claude-Skills, 874 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Writing SQL?

rileyhilliard (a GitHub user) maintains it in rileyhilliard/claude-essentials, which has 130 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on August 18, 2026.

Source: rileyhilliard/claude-essentials on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.