sql-review

sql-review is a skill for Claude Code, Codex from guyulong/cn-agent-skills. It costs 9 tokens per session (667 once invoked), scanned A, original, MIT.

A guide for reviewing SQL, the language used to query databases, and finding ways to make queries clearer and faster. It covers issues such as selecting unnecessary columns, missing filters, inefficient joins, and missing indexes.

In plain words
What is it for?
Use it to review SQL, diagnose slow database queries, improve pagination and batch inserts, and suggest indexes or query rewrites.
Why use it?
It helps identify queries that scan too much data or prevent the database from using indexes. It also explains common fixes and how to inspect a query plan with EXPLAIN.

Skill for Claude CodeCodex

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

Good fit Use it to review SQL, diagnose slow database queries, improve pagination and batch inserts, and suggest indexes or query rewrites.

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

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/sql-review/github.svg)](https://agentmods.dev/skills/guyulong/cn-agent-skills/sql-review)
Your own site
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/sql-review"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/sql-review/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-review

Your own site · 80×15
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/sql-review"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/sql-review.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 9 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 667 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.00009 $0.00667
Opus 5.5 $0.00004 $0.00267
Sonnet 5.5 $0.00002 $0.00133
Haiku 4.5 $0.00001 $0.00067

Measured 1mo ago against content hash 73654791111b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-review 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 1mo 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-review/SKILL.md · 94 lines

What it actually says

SQL审查与优化

使用场景

审查SQL语句,发现性能问题并提供优化建议。

审查规则

🔴 严重问题

  1. **SELECT ***

    • 问题:查询所有字段,浪费资源
    • 修复:只查询需要的字段
  2. 缺少WHERE条件

    • 问题:全表扫描
    • 修复:添加必要的过滤条件
  3. 隐式类型转换

    • 问题:字段类型不匹配导致索引失效
    • 示例:WHERE phone = 13800138000(phone是varchar)
    • 修复:WHERE phone = '13800138000'
  4. 前导通配符

    • 问题:LIKE '%keyword' 无法使用索引
    • 修复:考虑全文索引

🟡 性能问题

  1. N+1查询

    • 问题:循环中执行查询
    • 修复:使用JOIN或批量查询
  2. 子查询效率低

    • 问题:相关子查询
    • 修复:改用JOIN
  3. 缺少索引

    • 问题:WHERE/JOIN字段未建索引
    • 修复:添加合适索引
  4. 排序未使用索引

    • 问题:ORDER BY字段无索引
    • 修复:添加联合索引

🟢 优化建议

  1. 分页优化

    -- 慢:OFFSET大时性能差
    SELECT * FROM orders LIMIT 10 OFFSET 10000;
    
    -- 快:使用游标分页
    SELECT * FROM orders WHERE id > 10000 LIMIT 10;
    
  2. 批量操作

    -- 慢
    INSERT INTO users (name) VALUES ('张三');
    INSERT INTO users (name) VALUES ('李四');
    
    -- 快
    INSERT INTO users (name) VALUES ('张三'), ('李四');
    
  3. EXPLAIN分析

    EXPLAIN SELECT * FROM users WHERE phone = '13800138000';
    -- 查看 type、key、rows 字段
    

输出格式

SQL审查报告
━━━━━━━━━━━━━━━━━━━━━━━━
原始SQL: SELECT * FROM users WHERE phone = 13800138000

问题:
🔴 [严重] SELECT * - 建议只查询需要的字段
🔴 [严重] 隐式类型转换 - phone字段应使用字符串
🟡 [建议] phone字段建议添加索引

优化后:
SELECT id, name, phone FROM users WHERE phone = '13800138000';

建议索引:
CREATE INDEX idx_phone ON users(phone);
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. 1mo ago First seen · 94 lines · 9 tokens per session scan A 73654791111b

Subscribe to this mod's changes

sql-review is a skill published in the GitHub repository guyulong/cn-agent-skills (3 stars, last pushed 4mo ago), licensed MIT. It adds 9 tokens to every session and 667 once invoked, about $0.0000 per session on Opus 5.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-31.

Related

Other skills, from other repositories

relational-database-design

Designs or reviews a relational database schema for a given domain. Covers table structure, normalization, indexes, constraints, and migration strategy. Invoked when the user asks to design a schema, review a database structure, or optimize a data model.

soulcodex/agentic · 55 tokens

SQL Query Optimizer

Reviews SQL queries for performance issues and rewrites them with optimized execution plans.

Notysoty/openagentskills · 20 tokens

database-safety

A set of database-safety rules for schema changes, queries, and data updates, including rollback paths and safeguards for large tables.

Wade-DevCode/awesome-coding-skills-cn · 30 tokens

ascend-profiler-db-explorer

A SQL analysis skill for Ascend PyTorch Profiler and msprof database files. It turns questions about operator timing, communication, scheduling, or database tables into safe SQL queries and can look up official schema details.

little-planet/ascend-tune-lab · 82 tokens

triage-contributor-pr

Triage open pull requests from external contributors to prisma/orm and produce a per-PR verdict with evidence. Use when a maintainer asks to triage, evaluate, assess, or review the queue of incoming contributor PRs, to decide whether a fork PR is safe to run CI on, to check whether a PR is in scope for its version…

prisma/orm · 131 tokens

review-implement-phase

Implements triaged review actions, commits focused fixes, and posts Done plus resolves threads. Use when the user wants only the implementation phase of the review-framework workflow.

prisma/orm · 38 tokens