# Ali Review Sql

Reviews SQL/DDL statements against the 'Ali SQL Specification' to identify violations of the MySQL rules from the 'Alibaba Java Development Manual', providing a numbered and severity-rated list of issues with remediation suggestions.

**Canonical URL:** https://skillshunter.net/skills/discovered-96b47c558040272a19c42c25a1d8e65eb6a12a2a49c5f6a8

**JSON URL:** https://skillshunter.net/api/public/v1/skills/discovered-96b47c558040272a19c42c25a1d8e65eb6a12a2a49c5f6a8

**Markdown URL:** https://skillshunter.net/skills/discovered-96b47c558040272a19c42c25a1d8e65eb6a12a2a49c5f6a8.md

**Instructions download URL:** https://skillshunter.net/skills/discovered-96b47c558040272a19c42c25a1d8e65eb6a12a2a49c5f6a8/download

**Category:** Software & Development

**Source URL:** https://github.com/aihua/codex/blob/02559b92ce1609c87c080a1c6d3a5c17ea0ef924/plugins/ali-spec-plugin/skills/ali-review-sql/SKILL.md

**Source commit:** 02559b92ce1609c87c080a1c6d3a5c17ea0ef924

**Listing approved at:** 2026-11-30

**Created at:** 2026-11-29T10:55:46.000000Z

**Updated at:** 2026-11-30T06:51:23.000000Z

## Catalog information

The following descriptions are catalog information. Listing approval does not mean the skill has been tested or is safe for every environment.

### Editor's note

The skill requires the user to provide either a file path or a code snippet for review. If neither is provided, the skill will prompt the user to specify the object to be reviewed. The review process involves loading rules from specific files in the ali-sql-spec and related references, and the output includes a detailed report with statistics, conclusions, coverage, and version information of the rules used.

### When to use it

- Reviewing SQL scripts for compliance with the Alibaba MySQL development standards
- Checking DDL statements for adherence to the 'Ali SQL Specification'
- Identifying and fixing issues in database schema design
- Generating compliance reports with severity levels and remediation suggestions

## Skill instructions

---
name: ali-review-sql
description: 对指定 SQL/DDL 执行《阿里巴巴Java开发手册》MySQL 规约走查，逐条比对规则并输出带编号与严重级的违规清单。用户要求 review/检查/走查 SQL、数据库脚本、建表语句时使用。
---

# MySQL 规约评审

对 SQL 语句、建表 DDL、索引设计、数据订正脚本 执行 ali-sql-spec 所载规约的逐条走查，输出带规则编号与严重级（P0/P1/P2）的违规清单与修复建议。本技能不复制规则，规则全文以 ali-sql-spec 的 references 为单一事实源。

## 评审流程（五步）

1. 确定范围：用户给文件路径则读取文件；给代码片段则直接评审；两者皆无则先询问要评审的对象。
2. 加载规则：读取 ../ali-sql-spec/references/ 下相关规则文件全文（按下方「规则来源」选择章节）；涉及前后端接口契约时加读 ../../shared-references/http-json-api.md。涉及分页与排序参数时联动手册安全规约-4 与索引规约-5/7、SQL 语句-5（见 http-json-api.md 编者注索引）。
3. 逐条比对：按 建表-1…建表-15、索引-1…索引-11、SQL-1…SQL-11 顺序逐条检查（37 条）；与本次变更无关的范围可跳过，但不得遗漏已涉及范围。
4. 定位引用：每处违规给出规则编号、等级、原文依据（引用规则关键原文，不凭空发挥）。
5. 输出报告：按下方「输出报告模板」输出，并附修复建议与统计结论。

## 规则来源（跨目录引用，单一事实源）

| 文件 | 内容 | 加载时机 |
| --- | --- | --- |
| ../ali-sql-spec/references/01-建表规约.md | 建表规约 15 条规则全文（含说明、正反例） | 按评审对象涉及范围选择 |
| ../ali-sql-spec/references/02-索引规约.md | 索引规约 11 条规则全文（含说明、正反例） | 按评审对象涉及范围选择 |
| ../ali-sql-spec/references/03-SQL语句.md | SQL 语句 11 条规则全文（含说明、正反例） | 按评审对象涉及范围选择 |
| ../ali-java-spec/references/14-ORM映射.md | ORM 映射 7 条（含 ORM-1：查询禁用 select *） | 评审对象含 iBATIS/MyBatis XML 或出现 select * 时 |
| ../ali-sql-spec/SKILL.md | 规则速查索引（编号 → 摘要 → 全文位置） | 定位规则编号时 |
| ../../shared-references/http-json-api.md | HTTP JSON API 规范（响应信封、分页协议、排序参数） | 评审对象涉及 API 设计或接口字段时 |

## 严重级映射

- 手册等级【强制】→ P0 阻断：违反即生产事故高危项，必须修复后才能提交。
- 手册等级【推荐】→ P1 警告：强烈建议本次修复。
- 手册等级【参考】→ P2 提示：视情况选择，报告末尾汇总即可。
- 共享参考 common.md 的等级裁决：同一规则语言规约已有等级的以语言规约为准（如 CSS/HTML 缩进按「推荐」→ P1）。

## 输出报告模板

评审报告以 Markdown 表格输出，字段固定（多次评审结果可比较、可归档）：

| 位置 | 规则编号 | 等级 | 违规说明 | 修复建议 |
| --- | --- | --- | --- | --- |
| （文件名:行号 或 片段序号） | （源规约编号，可溯源） | （P0/P1/P2） | （违反了哪条规则，引用规则关键原文） | （给出符合规约的具体改法） |

报告尾注必含四项：

1. 统计：P0 / P1 / P2 各多少处。
2. 结论：是否存在 P0（存在则明确「阻断提交」，修复后可申请复审）。
3. 覆盖：本次走查覆盖的规则范围（如「建表 15 条 + 索引 11 条」），未覆盖范围说明原因。
4. 依据版本：规则来源与版本（手册终极版 1.3.0 / f2e-spec 对应规约）。

## 与规约技能的分工

- 编码/写文档场景 → ali-sql-spec（先读规则再动手）。
- 评审/走查场景 → 本技能（ali-review-sql，五步流程 + 标准化报告）。
- 典型评审对象：字段类型与命名、主键与索引设计、count/join/in 写法、深分页、数据订正。

