闲社服务运行正常AI智能体自动化平台
s

SQL格式化工具

技能标识:sql-formatter

Format, minify, and lint SQL queries from the command line. Formats SQL with proper indentation and keyword casing, minifies by removing whitespace and comments, and lints for common anti-patterns (SELECT *, inconsistent casing, missing semicolons, trailing whitespace). No external dependencies — pure Python. Use when formatting SQL queries, cleaning up SQL files, minifying SQL for production, or checking SQL quality.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

SQL格式化工具

SQL 格式化工具

零依赖地格式化、压缩和检查SQL代码。

命令

所有命令均使用 scripts/sql_format.py。

格式化SQL

bash
python3 scripts/sql_format.py format --sql SELECT id, name FROM users WHERE active = true
python3 scripts/sql_format.py format --input query.sql
python3 scripts/sql_format.py format --input query.sql --output formatted.sql
python3 scripts/sql_format.py format --input query.sql --indent 4 --lowercase
echo SELECT * FROM t | python3 scripts/sql_format.py format --input -

默认在主要子句(SELECT、FROM、WHERE、JOIN、ORDER BY等)前添加换行,缩进AND/OR/ON,并将关键字转换为大写。

压缩SQL

bash
python3 scripts/sql_format.py minify --sql SELECT id, name FROM users -- comment
python3 scripts/sql_format.py minify --input query.sql

去除注释,压缩空白,移除括号和逗号周围不必要的空格。

检查SQL

bash
python3 scripts/sql_format.py lint --input query.sql
python3 scripts/sql_format.py lint --sql SELECT * FROM users WHERE 1=1 --json

检查以下内容:SELECT *、多余空格、制表符、!= 与 <>、双逗号、WHERE 1=1、长行(超过120字符)、尾部空白、缺少分号、关键字大小写不一致。

支持的SQL

支持SELECT、INSERT、UPDATE、DELETE、CREATE、ALTER、DROP、WITH(CTE)、JOIN(所有类型)、子查询、字符串字面量、双引号标识符、单行和多行注释。

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 sql-formatter-1776104400 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 sql-formatter-1776104400 技能

通过命令行安装

skillhub install sql-formatter-1776104400

下载

⬇ 下载 sql-formatter v1.0.0(免费)

文件大小: 5.67 KB | 发布时间: 2026-4-17 16:13

v1.0.0 最新 2026-4-17 16:13
Initial release of SQL Formatter:

- Format, minify, and lint SQL queries directly from the command line.
- Provides formatting with indentation and configurable keyword casing.
- Minifies SQL by removing comments and collapsing whitespace.
- Lints for common SQL anti-patterns (e.g., SELECT *, missing semicolons, long lines).
- No external dependencies; implemented in pure Python.
- Supports major SQL statement types, including SELECT, INSERT, UPDATE, DELETE, CTEs, and various JOINs.
返回顶部