sql-review
Skill8 starsChanged 28 days agoApache-2.0View on GitHub
Scan codebase for table schemas (DDL) and SQL statements, create a PolarDB-X test instance with mock data, analyze index usage via EXPLAIN, and provide index optimization recommendations. Works with any language/framework. Use when user says "sql review", "SQL审查", "索引分析", "索引推荐", "index review", "SQL优化", "检查索引", "review sql", "分析SQL", "explain分析", "慢查询分析", "sql performance".
- Installs packages
10 other projects use a version of this.
Adopted by
Most recently taken up by
- Smaui94/ClaudeSkillCollectiontheir own version, first seen Nov 8, 2026
- Lanqiao-Luca/ai-java-workflowtheir own version, first seen Nov 8, 2026
- z-Zihan/Evirtheir own version, first seen Oct 13, 2026
- analyticsengineering/ae-toolkittheir own version, first seen Oct 12, 2026
- GabrielHenriqueCA/cortex-aitheir own version, first seen Oct 11, 2026
- kyle-chalmers/streamsnowtheir own version, first seen Oct 11, 2026
Used with
Projects with it also use code-review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 4 projects that use this
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- Lanqiao-Luca/ai-java-workflow★ 220same name
- kyle-chalmers/streamsnow★ 17same name
- z-Zihan/Evir★ 11same name
- analyticsengineering/ae-toolkit★ 3same name
- gmanch94/claude-code-aidlc-template★ 2same name
- Jiplet/transformation-os★ 2same name
- dennisrongo/claude-skills★ 1same name
- GabrielHenriqueCA/cortex-ai★ 1same name
- bt2go/claude-skills★ 0same name
- Smaui94/ClaudeSkillCollection★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- polardbx-cciSkill
- polardbx-cclSkill
- polardbx-online-ddlSkill
- polardbx-opsSkill
- polardbx-paginationSkill
- polardbx-plan-analysisSkill
- polardbx-sqlSkill
- polardbx-standardSkill
- polardbx-ttl20Skill
- polardbx-zeroSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 5 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
If mysql is not available, prompt the user to install it (brew install mysql-client / apt install mysql-client / scoop install mysql)
- Very specific: line 19
If user chooses Aliyun instance mode, aliyun CLI must be available and configured with valid credentials (aliyun configure list)
- Very specific: line 20
All temporary files use the sql_review_ prefix.
- Distinctive: line 26
After scanning each mapper/table (Step 2): append that table's SQL inventory immediately.
- Distinctive: line 27
After EXPLAIN analysis per table (Step 5): append that table's EXPLAIN results and recommended DDL immediately.
- Distinctive: line 30
Rule: Never batch multiple tables before saving.
- Distinctive: line 42
If user selects Aliyun instance: skip code scanning, execute the Aliyun collection path instead.
- Very specific: line 49
Verify aliyun CLI availability, collect instance info from user, retrieve DDL from the instance, fetch SQL insight statistics (DAS API), …
- Distinctive: line 67
Run EXPLAIN on each query (and each variant for multi-path queries).
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQL Review - Index Analysis & Recommendations
Scan codebase for DDL and SQL queries, create tables on a PolarDB-X test instance, populate mock data, analyze index usage via EXPLAIN, and output optimization recommendations.
Prerequisites
curlmust be available (for PolarDB-X Zero API calls to create/destroy instances)mysqlCLI client must be available (to connect and execute SQL)- If
mysqlis not available, prompt the user to install it (brew install mysql-client / apt install mysql-client / scoop install mysql) - If user chooses Aliyun instance mode,
aliyunCLI must be available and configured with valid credentials (aliyun configure list) - All temporary files use the
sql_review_prefix.$TMPDIRin this document refers to a writable temp directory — determine the appropriate path for the current OS (e.g./tmpon Linux/macOS,%TEMP%on Windows)
Progress File
Critical for long sessions: Initialize $TMPDIR/sql_review_progress.md at the start of Step 2 and append incrementally throughout the entire workflow.
- After scanning each mapper/table (Step 2): append that table's SQL inventory immediately.
- After EXPLAIN analysis per table (Step 5): append that table's EXPLAIN results and recommended DDL immediately.
- In Step 6 (Report): read the progress file as the single source of truth to assemble the final report.
Rule: Never batch multiple tables before saving. Process one table, save results, then move to the next. This prevents loss of work if the agent session runs out of context.
Workflow
Track progress on the following steps. Each step has a dedicated reference file — Read it when starting the step, then discard after completion.
Step 1-2: Confirm Scope & Scan Codebase
Confirm scan scope and database edition with the user, detect framework (MyBatis auto-detection), then collect all DDL and SQL statements via multi-round search. For MyBatis projects, extract SQL from XML mapper tags and generate multi-path variants for dynamic WHERE queries.
Scan scope options: Full repository, Specific module/directory, Recent Git commits, or Aliyun instance (collect SQL insights and slow queries via aliyun CLI, no codebase needed).
- If user selects Aliyun instance: skip code scanning, execute the Aliyun collection path instead.
- Otherwise: proceed with standard code scanning.
Read references/step-scan.md for detailed instructions.
Step 2: Aliyun Data Source Collection (Aliyun mode only)
Verify aliyun CLI availability, collect instance info from user, retrieve DDL from the instance, fetch SQL insight statistics (DAS API), slow query records, and optionally SQL audit logs (SLS API). Merge and deduplicate results, save to progress file with execution frequency and latency metrics.
Read references/step-aliyun.md for detailed instructions.
Step 3: Name Anonymization
Build randomized name mapping for all tables, columns, indexes (and MyBatis statement IDs). Persist mapping file. Transform all SQL to use anonymous names.
Read references/step-anonymize.md for detailed instructions.
Step 4: Test Instance Setup
Analyze data characteristics from code, create PolarDB-X test instance, create tables with anonymized DDL, and populate mock data via stored procedures.
Read references/step-instance.md for detailed instructions.
Step 5: EXPLAIN Analysis
Run EXPLAIN on each query (and each variant for multi-path queries). For problematic queries, explore multiple candidate indexes via CREATE -> EXPLAIN -> DROP cycles. Cross-validate indexes against all variants.
Read references/step-explain.md for detailed instructions.
Step 6: Report & Cleanup
Map anonymous names back to real names. Generate sql-review-report.md with 7 sections (overview, schema, inventory, query analysis, index recommendations, security notes, caveats). Clean up test instance and temp files.
Read references/step-report.md for detailed instructions.
Reference Documents
| Document | Content |
| references/index-design.md | EXPLAIN metrics, composite index principles, index exploration method, common patterns, mock data rules |
| references/mybatis.md | MyBatis dynamic SQL tag expansion rules, multi-path analysis algorithm, parameter placeholders |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

