360 Secure SkillHub
360 安全技能中心

Sql Formatter

该 Skill 通过 scripts/sql_format.py 提供三个子命令:format 按主要子句换行、缩进 AND/OR/ON 并统一关键字大小写;minify 去除注释与多余空白;lint 检查 SELECT *、多余空格、制表符、!= 与 <>、重复逗号、WHERE 1=1、超长行、行尾空白、缺少分号及关键字大小写不一致。支持从参数、文件或标准输入读取,可输出到文件,纯 Pytho…

分类:效率
johnnywang2001
johnnywang2001
热度 34.15
最近更新 2026-05-11 17:33:53

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add johnnywang2001/sql-formatter
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
sql-formatter
description
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.

SQL Formatter

Format, minify, and lint SQL with zero dependencies.

Commands

All commands use scripts/sql_format.py.

Format SQL

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 -

Adds line breaks before major clauses (SELECT, FROM, WHERE, JOIN, ORDER BY, etc.), indents AND/OR/ON, and uppercases keywords by default.

Minify SQL

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

Strips comments, collapses whitespace, removes unnecessary spaces around parentheses and commas.

Lint SQL

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

Checks for: SELECT *, multiple spaces, tabs, != vs <>, double commas, WHERE 1=1, long lines (>120 chars), trailing whitespace, missing semicolons, inconsistent keyword casing.

Supported SQL

Handles SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, WITH (CTEs), JOINs (all types), subqueries, string literals, double-quoted identifiers, single-line and multi-line comments.