← 返回 Skills 市场
magicczc

SQL智能助手

作者 magicCzc · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
49
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install dbskiter-sql-master
功能描述
SQL智能助手,支持SQL执行、重写优化、质量分析、数据分析、智能补全、Schema查询、批量执行、数据导入导出。 使用场景: - 用户说"执行这个SQL" → execute 或直接 dbskiter sql "SELECT..." - 用户说"优化这个SQL" → rewrite - 用户说"分析SQL质量"...
使用说明 (SKILL.md)

SQL Master Skill

目标

帮助用户执行SQL、优化SQL、分析SQL质量、理解数据结构。

何时使用

当用户提到以下关键词时使用此skill:

用户说法 执行命令 说明
"执行SQL" / "跑一下这个SQL" dbskiter --output-mode=ai --database=\x3Cname> sql "\x3CSQL>"dbskiter --output-mode=ai --database=\x3Cname> sql execute "\x3CSQL>" 执行SQL语句
"优化SQL" / "重写SQL" dbskiter --output-mode=ai --database=\x3Cname> sql rewrite "\x3CSQL>" 重写SQL优化性能
"分析SQL" / "SQL质量" dbskiter --output-mode=ai --database=\x3Cname> sql analyze "\x3CSQL>" 分析SQL质量评分
"分析数据" / "数据统计" dbskiter --output-mode=ai --database=\x3Cname> sql data "\x3CSQL>" 分析查询结果数据特征
"SQL补全" / "自动完成" dbskiter --output-mode=ai --database=\x3Cname> sql complete "\x3C部分SQL>" 智能补全建议
"表结构" / "Schema" dbskiter --output-mode=ai --database=\x3Cname> sql schema --table=\x3C表名> 查看表结构
"有哪些表" dbskiter --output-mode=ai --database=\x3Cname> sql schema 列出所有表
"批量执行SQL文件" dbskiter --output-mode=ai --database=\x3Cname> sql batch \x3C文件> 批量执行文件中的SQL
"导出数据" dbskiter --output-mode=ai --database=\x3Cname> sql export --table=\x3C表名> --output=\x3C文件> 导出表数据
"导入数据" dbskiter --output-mode=ai --database=\x3Cname> sql import \x3C文件> --table=\x3C表名> 导入数据到表

核心命令(9个)

1. 执行SQL

dbskiter --output-mode=ai --database=\x3C数据库名> sql execute "\x3CSQL语句>"

参数

  • --params='{"key": "value"}':SQL参数(JSON格式)
  • --limit=100:限制返回行数

示例

# 基础查询
dbskiter --output-mode=ai --database=prod sql execute "SELECT * FROM users LIMIT 10"

# 带参数
dbskiter --output-mode=ai --database=prod sql execute "SELECT * FROM users WHERE age > %(age)s" --params='{"age": 18}'

# 限制返回行数
dbskiter --output-mode=ai --database=prod sql execute "SELECT * FROM orders" --limit=50

2. 重写SQL优化

dbskiter --output-mode=ai --database=\x3C数据库名> sql rewrite "\x3CSQL语句>"

功能

  • 展开 SELECT * 为具体字段
  • 优化 WHERE 条件
  • 推荐索引
  • 重写低效JOIN

示例

# 优化SELECT *
dbskiter --output-mode=ai --database=prod sql rewrite "SELECT * FROM users WHERE id = 1"
# 输出:SELECT id, name, email FROM users WHERE id = 1

# 优化复杂查询
dbskiter --output-mode=ai --database=prod sql rewrite "SELECT * FROM orders o JOIN users u ON o.user_id = u.id WHERE u.status = 'active'"

3. 分析SQL质量

dbskiter --output-mode=ai --database=\x3C数据库名> sql analyze "\x3CSQL语句>"

输出

  • 质量评分(0-100分)
  • 等级(A/B/C/D/F)
  • 问题列表
  • 优化建议

评分标准

  • 90-100分:A级(优秀)
  • 80-89分:B级(良好)
  • 70-79分:C级(一般)
  • 60-69分:D级(较差)
  • \x3C60分:F级(危险)

示例

dbskiter --output-mode=ai --database=prod sql analyze "SELECT * FROM users WHERE email = '[email protected]'"

4. 数据分析

dbskiter --output-mode=ai --database=\x3C数据库名> sql data "\x3C查询SQL>"

功能:分析查询结果的数据特征

  • 每列的数据类型
  • 空值数量
  • 唯一值数量
  • 数值列的统计(最小/最大/平均值)
  • 示例值

示例

# 分析订单数据
dbskiter --output-mode=ai --database=prod sql data "SELECT * FROM orders WHERE created_at > '2024-01-01'"

# 分析用户数据
dbskiter --output-mode=ai --database=prod sql data "SELECT age, city, status FROM users"

5. SQL智能补全

dbskiter --output-mode=ai --database=\x3C数据库名> sql complete "\x3C部分SQL>"

功能:根据部分SQL提供补全建议

  • 表名补全
  • 字段名补全
  • SQL关键字补全
  • 函数补全

示例

# 补全表名
dbskiter --output-mode=ai --database=prod sql complete "SELECT * FROM "

# 补全字段
dbskiter --output-mode=ai --database=prod sql complete "SELECT id, name, "

# 补全WHERE条件
dbskiter --output-mode=ai --database=prod sql complete "SELECT * FROM users WHERE "

6. Schema查询

# 列出所有表
dbskiter --output-mode=ai --database=\x3C数据库名> sql schema

# 查看指定表结构
dbskiter --output-mode=ai --database=\x3C数据库名> sql schema --table=\x3C表名>

输出

  • 所有表名列表
  • 表字段详情(名称、类型、是否可空、默认值)
  • 索引信息

示例

# 列出所有表
dbskiter --output-mode=ai --database=prod sql schema

# 查看users表结构
dbskiter --output-mode=ai --database=prod sql schema --table=users

# 查看orders表结构和索引
dbskiter --output-mode=ai --database=prod sql schema --table=orders

7. 导出数据

# 导出表数据
dbskiter --output-mode=ai --database=\x3C数据库名> sql export --table=\x3C表名> --output=\x3C文件路径> --format=\x3C格式>

# 导出查询结果
dbskiter --output-mode=ai --database=\x3C数据库名> sql export --query="\x3CSQL>" --output=\x3C文件路径> --format=\x3C格式>

参数

  • --table: 表名(与--query二选一)
  • --query: SQL查询语句(与--table二选一)
  • --output, -o: 输出文件路径(必需)
  • --format, -f: 导出格式(csv/json/sql,默认csv)
  • --where: WHERE条件(仅table模式)
  • --limit: 限制导出行数

示例

# 导出users表为CSV
dbskiter --output-mode=ai --database=prod sql export --table=users --output=users.csv

# 导出为JSON格式
dbskiter --output-mode=ai --database=prod sql export --table=users --output=users.json --format=json

# 导出查询结果
dbskiter --output-mode=ai --database=prod sql export --query="SELECT * FROM orders WHERE status='pending'" --output=pending_orders.csv

# 只导出前1000行
dbskiter --output-mode=ai --database=prod sql export --table=users --output=users.csv --limit=1000

8. 导入数据

dbskiter --output-mode=ai --database=\x3C数据库名> sql import \x3C文件路径> --table=\x3C表名> --format=\x3C格式>

参数

  • --table, -t: 目标表名(必需)
  • --format, -f: 文件格式(csv/json/sql,默认csv)
  • --columns: 指定列名(逗号分隔,CSV格式用)
  • --batch-size: 批量插入大小(默认1000)

示例

# 从CSV导入
dbskiter --output-mode=ai --database=prod sql import users.csv --table=users

# 从JSON导入
dbskiter --output-mode=ai --database=prod sql import users.json --table=users --format=json

# 从SQL文件导入
dbskiter --output-mode=ai --database=prod sql import users.sql --format=sql

# 指定列名导入
dbskiter --output-mode=ai --database=prod sql import data.csv --table=users --columns=id,name,email

# 调整批量大小
dbskiter --output-mode=ai --database=prod sql import large_data.csv --table=users --batch-size=500

9. 批量执行SQL文件

dbskiter --output-mode=ai --database=\x3C数据库名> sql batch \x3C文件路径>

功能:批量执行文件中的SQL语句

示例

# 批量执行SQL文件
dbskiter --output-mode=ai --database=prod sql batch queries.sql

AI决策流程

场景1:用户说"执行这个SQL"

步骤1:提取用户提供的SQL
步骤2:执行 dbskiter --output-mode=ai --database=\x3Cname> sql execute "\x3CSQL>"
步骤3:展示结果(最多50行)
步骤4:告知总行数和耗时

场景2:用户说"优化这个SQL"

步骤1:提取用户提供的SQL
步骤2:执行 dbskiter --output-mode=ai --database=\x3Cname> sql rewrite "\x3CSQL>"
步骤3:展示优化后的SQL和解释
步骤4:如果质量评分\x3C80,建议进一步优化

场景3:用户说"查看表结构"

步骤1:提取表名
步骤2:执行 dbskiter --output-mode=ai --database=\x3Cname> sql schema --table=\x3C表名>
步骤3:展示表结构和索引信息
安全使用建议
This skill looks like a sensible SQL helper, but it depends on an external tool ('dbskiter') and will run arbitrary SQL and file import/export commands. Before installing: 1) verify the skill's source/trustworthiness and where 'dbskiter' comes from; 2) confirm how database credentials are supplied (env vars, ~/.dbskiter, system keychain) and avoid exposing production credentials — prefer a read-only or sandbox DB user; 3) be aware batch/import commands can read local files and export can write arbitrary paths; 4) if you don't control or trust the dbskiter binary, don't enable the skill or run it against sensitive data. Ask the author to declare the required binary, how credentials/config are used, and any filesystem expectations before using in production.
功能分析
Type: OpenClaw Skill Name: dbskiter-sql-master Version: 1.0.0 The skill bundle provides a comprehensive interface for database management using a CLI tool named `dbskiter`, including capabilities for SQL execution, data export/import, and schema modification. While these features are consistent with the 'SQL Master' description in `SKILL.md`, they constitute high-risk operations that could be abused for data exfiltration or unauthorized database changes. No explicit malicious intent or obfuscated code was identified, but the reliance on an unverified binary for sensitive database operations warrants a suspicious classification.
能力评估
Purpose & Capability
The SKILL.md explicitly requires running the external CLI 'dbskiter' for all functionality (execute, rewrite, analyze, import/export, batch, schema, etc.), but the skill metadata declares no required binaries, no install steps, and no primary credential. That mismatch (calling a specific CLI while not declaring it) is an incoherence: a consumer would reasonably need the dbskiter binary and database credentials to use this skill.
Instruction Scope
Runtime instructions tell the agent to execute arbitrary SQL (including batch files and imports) and to read/write files (export/import, batch <file>). Those actions are within the stated SQL-assistant purpose, but the instructions do not specify where database credentials/config are read from or any limits on file paths. This leaves open the possibility that the skill will access local files or privileged DBs in ways the user didn't expect.
Install Mechanism
No install spec or code is provided (instruction-only skill), so nothing will be written to disk by the skill installer itself. This is lower risk, but it shifts attention to the external CLI 'dbskiter' which the instructions rely on being present.
Credentials
The skill declares no required environment variables or credentials, yet its commands require a --database argument and implicitly depend on whatever credentials/config the 'dbskiter' CLI uses (env vars, config files, or system keychains). The absence of any declared credential requirements is disproportionate and ambiguous: the agent running these commands could end up using existing local DB credentials or config without the user realizing.
Persistence & Privilege
Flags show always:false and standard model invocation allowed. The skill does not request persistent presence or modifications to other skills. Autonomous invocation is allowed (default) — that is normal but combined with the other concerns increases potential impact.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install dbskiter-sql-master
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /dbskiter-sql-master 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of sql-master skill. - Provides intelligent SQL execution, rewriting/optimization, quality analysis, data profiling, and auto-completion. - Supports schema exploration, batch SQL execution, and data import/export. - Detailed command usage and examples included for each core feature. - Designed to assist users with SQL queries, optimization, and database structure understanding.
元数据
Slug dbskiter-sql-master
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

SQL智能助手 是什么?

SQL智能助手,支持SQL执行、重写优化、质量分析、数据分析、智能补全、Schema查询、批量执行、数据导入导出。 使用场景: - 用户说"执行这个SQL" → execute 或直接 dbskiter sql "SELECT..." - 用户说"优化这个SQL" → rewrite - 用户说"分析SQL质量"... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 49 次。

如何安装 SQL智能助手?

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

SQL智能助手 是免费的吗?

是的,SQL智能助手 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

SQL智能助手 支持哪些平台?

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

谁开发了 SQL智能助手?

由 magicCzc(@magicczc)开发并维护,当前版本 v1.0.0。

💬 留言讨论