sql-ops skill
✓ VerifiedProvides quick reference patterns for CTEs, window functions, joins, pagination, transaction isolation levels, and indexing strategies.
- GitHub stars
- 81
- Files
- 5
- Last commit
- Nov 7, 2026
- License
- MIT
- Allowed tools
- 2
What does the sql-ops skill do?
sql-ops provides quick reference patterns for CTEs, window functions, joins, pagination, transaction isolation levels, and indexing strategies.
Summary generated from the skill's SKILL.md.
About the sql-ops skill
Developers needing immediate syntax templates for complex database queries can use sql-ops to retrieve structured SQL patterns. This skill provides a quick reference for writing Common Table Expressions, window functions, and various join types. It is designed to be loaded when an agent needs to generate or debug SQL code involving pagination, transaction isolation levels, or indexing strategies.
Instead of searching through documentation, an agent can access specific examples for chained CTEs, running totals using SUM() OVER, or different ranking methods like RANK() and DENSE_RANK(). The tool also outlines how to handle transaction isolation levels such as SERIALIZABLE and provides guidance on avoiding common anti-patterns like using SELECT * or inefficient WHERE clauses. It relies on internal reference files for deeper dives into indexing and window function patterns.
What an agent can do with it
- 1Apply window functionsCalculate a running total and the previous day's revenue using window function syntax.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the sql-ops skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the sql-ops skill in Plugin
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
Install the sql-ops skill in Claude Code
~/.claude/skills/sql-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/sql-ops ~/.claude/skills/sql-opsInstall the sql-ops skill in Claude Code (project)
.claude/skills/sql-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/sql-ops .claude/skills/sql-opsInstall the sql-ops skill in Codex
~/.agents/skills/sql-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/sql-ops ~/.agents/skills/sql-opsInstall the sql-ops skill in Gemini CLI
~/.gemini/skills/sql-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/sql-ops ~/.gemini/skills/sql-opsInstall the sql-ops skill in Claude.ai
npx degit 0xDarkMatter/claude-mods/skills/sql-ops sql-ops && zip -r sql-ops.zip sql-ops # claude.ai → Customize → Skills → + → Create skill → Upload a skill → sql-ops.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachable0xdarkmatter/claude-mods/skills/sql-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/sql-ops ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/sql-ops ↗Pass
- Pre-approved tools are scopedPre-approved: Read, Writegithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/sql-ops ↗Pass
- SKILL.md follows the Agent Skills formatValid name and description; says when to use it; 124 linesgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/sql-ops ↗Pass
SKILL.md
View on GitHubSQL Patterns
Quick reference for common SQL patterns.
CTE (Common Table Expressions)
WITH active_users AS (
SELECT id, name, email
FROM users
WHERE status = 'active'
)
SELECT * FROM active_users WHERE created_at > '2024-01-01';
Chained CTEs
WITH
active_users AS (
SELECT id, name FROM users WHERE status = 'active'
),
user_orders AS (
SELECT user_id, COUNT(*) as order_count
FROM orders GROUP BY user_id
)
SELECT u.name, COALESCE(o.order_count, 0) as orders
FROM active_users u
LEFT JOIN user_orders o ON u.id = o.user_id;
Window Functions (Quick Reference)
| Function | Use |
|---|---|
ROW_NUMBER() |
Unique sequential numbering |
RANK() |
Rank with gaps (1, 2, 2, 4) |
DENSE_RANK() |
Rank without gaps (1, 2, 2, 3) |
LAG(col, n) |
Previous row value |
LEAD(col, n) |
Next row value |
SUM() OVER |
Running total |
AVG() OVER |
Moving average |
SELECT
date,
revenue,
LAG(revenue, 1) OVER (ORDER BY date) as prev_day,
SUM(revenue) OVER (ORDER BY date) as running_total
FROM daily_sales;
JOIN Reference
| Type | Returns |
|---|---|
INNER JOIN |
Only matching rows |
LEFT JOIN |
All left + matching right |
RIGHT JOIN |
All right + matching left |
FULL JOIN |
All rows, NULL where no match |
Pagination
-- OFFSET/LIMIT (simple, slow for large offsets)
SELECT * FROM products ORDER BY id LIMIT 20 OFFSET 40;
-- Keyset (fast, scalable)
SELECT * FROM products WHERE id > 42 ORDER BY id LIMIT 20;
Transaction Isolation Levels
| Level | Dirty Read | Non-Repeatable Read | Phantom Read | Use |
|---|---|---|---|---|
READ UNCOMMITTED |
Possible | Possible | Possible | Rarely (PostgreSQL treats as READ COMMITTED) |
READ COMMITTED |
No | Possible | Possible | Default in most databases |
REPEATABLE READ |
No | No | Possible* | Consistent multi-statement reads |
SERIALIZABLE |
No | No | No | Critical invariants (retry on serialization failure) |
*PostgreSQL's REPEATABLE READ also prevents phantoms via snapshot isolation.
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-- ... critical operations ...
COMMIT; -- be prepared to retry on serialization failure
Keep the default READ COMMITTED globally; raise the level per-transaction only where the logic requires it.
Index Quick Reference
| Index Type | Best For |
|---|---|
| B-tree | Range queries, ORDER BY |
| Hash | Exact equality only |
| GIN | Arrays, JSONB, full-text |
| Covering | Avoid table lookup |
Anti-Patterns
| Mistake | Fix |
|---|---|
SELECT * |
List columns explicitly |
WHERE YEAR(date) = 2024 |
WHERE date >= '2024-01-01' |
NOT IN with NULLs |
Use NOT EXISTS |
| N+1 queries | Use JOIN or batch |
Additional Resources
For detailed patterns, load:
./references/window-functions.md- Complete window function patterns./references/indexing-strategies.md- Index types, covering indexes, optimization
Files in this skill
5sql-ops skill questions
How do I install the sql-ops skill in Claude Code?
Run npx degit 0xDarkMatter/claude-mods/skills/sql-ops ~/.claude/skills/sql-ops. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the sql-ops skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
How can I implement efficient pagination in SQL?
You can use OFFSET/LIMIT for simple pagination, though it is slow for large offsets, or use Keyset pagination which is faster and more scalable.