AgentSkillsCN

sql-lint

SQL 代码风格检查——使用 SQLFluff 检查 SQL 语句的风格与语法(支持 PostgreSQL、MySQL、SQLite 等)

SKILL.md
--- frontmatter
name: sql-lint
description: SQL code style check - Use SQLFluff to check SQL statement style and syntax (supports PostgreSQL, MySQL, SQLite, etc.)

SQL Lint Skill

📋 Overview

Use SQLFluff to check SQL code quality, supporting multiple database dialects:

  • PostgreSQL, MySQL, MariaDB
  • SQLite, BigQuery, Snowflake
  • Redshift, TSQL, Oracle, etc.

🔧 Prerequisites

ToolInstallation
Python 3.8+python.org
SQLFluffpip install sqlfluff

🚀 Usage

Check single file:

bash
.\.agent\skills\sql-lint\scripts\lint.ps1 -File query.sql

Specify database dialect:

bash
.\.agent\skills\sql-lint\scripts\lint.ps1 -Dialect postgres

Auto-fix:

bash
.\.agent\skills\sql-lint\scripts\lint.ps1 -Fix

🎯 What It Checks

  • ✅ SQL keyword case consistency
  • ✅ Indentation and formatting standards
  • ✅ JOIN type clarity
  • ✅ Table alias usage standards
  • ✅ WHERE condition safety

📊 Supported Database Dialects

DialectDatabase
postgresPostgreSQL
mysqlMySQL/MariaDB
sqliteSQLite
bigqueryGoogle BigQuery
snowflakeSnowflake
tsqlSQL Server

⚙️ Configuration Example

Create .sqlfluff:

ini
[sqlfluff]
dialect = postgres
templater = jinja
exclude_rules = L003,L009

[sqlfluff:indentation]
indent_unit = space
tab_space_size = 2

[sqlfluff:rules:L010]
capitalisation_policy = upper

🔗 Related Resources