← 返回 Skills 市场
shenghoo123-png

sql-explain

作者 shenghoo123-png · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
112
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install sql-explain-kay
功能描述
解析并解读 PostgreSQL、MySQL、SQLite 的 SQL 执行计划,提供性能问题识别与优化建议。
使用说明 (SKILL.md)

SQL Query Explain / SQL解释器

身份与目标

你是 SQL Expert,专门帮助开发者理解和优化 SQL 查询。

触发词

  • "explain sql"
  • "sql解释"
  • "分析sql"
  • "sql优化建议"
  • "这个sql怎么写"
  • "sql query explanation"
  • "explain this query"

核心功能

1. SQL EXPLAIN 解析

使用 sqleanexplain 模块(或 Python sqlparse + 内置规则)分析 SQL 查询的执行计划。

支持的数据库: PostgreSQL, MySQL, SQLite, MySQL兼容

分析维度:

  • 表扫描方式(Seq Scan / Index Scan / Index Only Scan / Full Table Scan)
  • 索引使用情况
  • 连接类型(Hash Join / Nested Loop / Merge Join)
  • 估计行数 vs 实际行数
  • 昂贵操作识别
  • 优化建议

2. 自然语言转 SQL

根据用户描述的业务需求,生成标准 SQL。 支持:SELECT / INSERT / UPDATE / DELETE / CREATE TABLE

3. SQL 格式化

输入凌乱的 SQL,输出格式化的结果。 支持关键字大写、缩进、分行。

4. SQL 语法检查

检查 SQL 语法错误,提供修正建议。


工作流程

  1. 识别意图: 判断是解释/生成/格式化/检查
  2. 解析SQL: 使用 sqlparse 解析语法树
  3. 执行分析: 对 EXPLAIN 输出进行结构化分析
  4. 输出结果: 结构化报告 + 优化建议

输出格式

EXPLAIN 解析结果

📊 查询计划分析

🎯 总成本: {cost}
📦 预计返回: {estimated_rows} 行

🔍 扫描分析:
  - 类型: {scan_type}
  - 表: {table}
  - 条件: {conditions}

⚠️ 性能关注点:
  - {issue_1}
  - {issue_2}

💡 优化建议:
  1. {suggestion_1}
  2. {suggestion_2}

定价

  • Free: 10次/天
  • Pro (¥19/月): 100次/天,保存历史记录
  • Team (¥49/月): 无限制,团队共享

技术实现

  • Python + sqlparse(SQL解析)
  • Python 内置规则库(EXPLAIN计划解读)
  • 无外部API依赖,完全本地运行
  • 支持 PostgreSQL / MySQL / SQLite EXPLAIN格式

限制

  • 暂不支持复杂存储过程
  • 暂不支持 DDL 语句的 EXPLAIN
安全使用建议
This skill appears to be a local, coherent SQL explain/format/check tool. Before installing or running: (1) verify the source (the README's curl URL is a placeholder—avoid running downloaded scripts from unknown repos), (2) prefer installing the dependency via pip (pip install sqlparse) and review sql_explain.py if you plan to run it, (3) run the included tests (pytest) in a sandbox to confirm behavior, and (4) note minor documentation mismatches (references to 'sqlean' and an "AI API" in docs) — these are likely harmless but worth clarifying with the publisher if you need certainty. No credentials or network access are required by the code as provided.
功能分析
Type: OpenClaw Skill Name: sql-explain-kay Version: 1.0.0 The skill bundle provides a set of local tools for SQL formatting, syntax checking, and execution plan analysis using the 'sqlparse' library. The code in 'sql_explain.py' and 'cli.py' is well-structured, lacks any network or sensitive file system access, and contains no evidence of malicious intent or prompt injection vulnerabilities.
能力评估
Purpose & Capability
Name/description match the provided code and SKILL.md. The code implements formatting, basic syntax checks, structure analysis, NL->SQL templates, and parsing of EXPLAIN output using sqlparse and regex — all coherent with 'sql-explain'. No unrelated environment variables, binaries, or cloud credentials are requested.
Instruction Scope
SKILL.md and README keep scope to parsing/analysis/formatting/generation of SQL and EXPLAIN outputs. Minor inconsistencies: SKILL.md mentions using the 'sqlean' explain module OR sqlparse+rules, but the included code uses only sqlparse/regex. README also contrasts an "AI Skill" that may rely on an AI API with the local CLI, yet the skill declares no external API keys; these are documentation mismatches rather than evidence of out-of-scope behavior. The runtime instructions do not tell the agent to read unrelated files, env vars, or transmit data externally.
Install Mechanism
No install spec in the registry; the package is instruction-only for the agent and the repository provides Python scripts. The README suggests pip install sqlparse or curling a raw GitHub file (a placeholder URL). No automated remote downloads or obscure URLs are included in the skill metadata/install spec.
Credentials
The skill declares no required environment variables, no credentials, and no config paths. The code does not read environment variables or attempt to access external secrets; requested resources are proportional to a local parsing/analysis tool.
Persistence & Privilege
always is false and the skill does not request persistent system-level presence. The CLI optionally suggests creating a symlink for convenience, but there is no code that modifies other skills, system-wide agent settings, or stores cross-skill credentials.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install sql-explain-kay
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /sql-explain-kay 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug sql-explain-kay
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

sql-explain 是什么?

解析并解读 PostgreSQL、MySQL、SQLite 的 SQL 执行计划,提供性能问题识别与优化建议。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 112 次。

如何安装 sql-explain?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install sql-explain-kay」即可一键安装,无需额外配置。

sql-explain 是免费的吗?

是的,sql-explain 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

sql-explain 支持哪些平台?

sql-explain 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 sql-explain?

由 shenghoo123-png(@shenghoo123-png)开发并维护,当前版本 v1.0.0。

💬 留言讨论