← Back to Skills Marketplace
shenghoo123-png

sql-explain

by shenghoo123-png · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
148
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install sql-explain
Description
Analyze and explain SQL query execution plans with optimization suggestions for PostgreSQL, MySQL, and SQLite databases.
README (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
Usage Guidance
This skill appears to be a local, self-contained Python tool for formatting, basic syntax checking, NL→SQL templates, and parsing EXPLAIN text (mostly PostgreSQL-style). Before installing or running: (1) review the Python source provided (sql_explain.py and cli.py) yourself if you can — they are short and readable; (2) be aware the EXPLAIN parser is regex-based and may not fully support all MySQL/SQLite EXPLAIN variants despite the documentation claiming partial support; (3) the README/SKILL.md mention paid tiers and history saving, but no persistence/telemetry code is present — if you expect Pro features, ask the publisher how data/history are stored; (4) install only the dependency 'sqlparse' from PyPI and avoid running untrusted SQL on production databases. Overall the package is coherent and does not request extra privileges or secrets.
Capability Analysis
Type: OpenClaw Skill Name: sql-explain Version: 1.0.0 The skill bundle is a legitimate SQL utility tool for formatting, syntax checking, and analyzing SQL execution plans. The code (sql_explain.py and cli.py) performs local string manipulation using the standard 'sqlparse' library and regex-based pattern matching without any network requests, file system modifications, or shell execution. There is no evidence of data exfiltration, obfuscation, or prompt injection; the instructions in SKILL.md are strictly aligned with the stated purpose of helping users optimize SQL queries.
Capability Assessment
Purpose & Capability
Name/description match the contained code: the Python files implement formatting, simple syntax checks, NL→SQL templates, structure analysis, and parsing of EXPLAIN text. Minor mismatch: SKILL.md mentions using 'sqlean' explain module or broader DB EXPLAIN formats (Postgres/MySQL/SQLite), but the shipped implementation only uses sqlparse and regex-based parsing of EXPLAIN text (primarily PostgreSQL-style). The README/SKILL.md also mention saving history / Pro features, but no persistence or telemetry exists in the code.
Instruction Scope
Runtime instructions and SKILL.md limit actions to parsing/formatting/analysis of user-provided SQL or EXPLAIN text; code does not read unrelated files, environment variables, or make network calls. CLI offers local execution only.
Install Mechanism
No install spec in registry (instruction-only). The included code is pure Python and requires only the well-known 'sqlparse' package; no downloads, URLs, or archive extraction are present in the manifest.
Credentials
The skill requires no environment variables, credentials, or config paths. The requested surface is proportional to the stated functionality.
Persistence & Privilege
always is false and the skill does not modify other skills or system-wide settings. There is no code that writes persistent credentials or enables permanent background behavior.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install sql-explain
  3. After installation, invoke the skill by name or use /sql-explain
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
sql-explain 1.0.0 – Initial release - Explain and analyze SQL execution plans for PostgreSQL, MySQL, and SQLite. - Provide SQL optimization suggestions based on common performance issues. - Generate SQL queries from natural language business requirements. - Format messy SQL code into clean, readable syntax. - Check SQL syntax and offer correction advice. - No external API usage; all processing done locally.
Metadata
Slug sql-explain
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is sql-explain?

Analyze and explain SQL query execution plans with optimization suggestions for PostgreSQL, MySQL, and SQLite databases. It is an AI Agent Skill for Claude Code / OpenClaw, with 148 downloads so far.

How do I install sql-explain?

Run "/install sql-explain" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is sql-explain free?

Yes, sql-explain is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does sql-explain support?

sql-explain is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created sql-explain?

It is built and maintained by shenghoo123-png (@shenghoo123-png); the current version is v1.0.0.

💬 Comments