Fix SQL lint with the SQLFluff core rule pack
Install the SQLFluff core rule pack, point it at your warehouse dialect, and lint a fixture that fails on purpose: indentation, keyword capitalisation, SELECT star, and unused CTEs. You fix each finding while the passing fixture stays green, then wire the same lint run into CI.
At a glance
| When | Team SQL style drifts and review time burns on formatting; Legacy SQL debt needs fixing incrementally instead of one big reformat |
|---|---|
| Where | SQL |
| Why | Mechanical lint rules settle formatting and naming so review time goes to correctness. |
Learning objectives
- Configure SQLFluff for your warehouse dialect
- Fix L003, L010, L030, and L057 findings in real SQL
- Integrate SQLFluff into CI/CD pipelines
What you need
- Python >= 3.8 with pip
- pip install sqlfluff==3.0.0 sqlfluff-templater-dbt
- A .sql file or dbt project to lint
Steps
- Configure SQLFluff for your warehouse dialect. (from rule-pack-sqlfluff-core )
- L003 — Consistent indentation. (from rule-pack-sqlfluff-core )
- L010 — Keywords capitalisation policy (UPPER). (from rule-pack-sqlfluff-core )
- L030 — SELECT star usage. (from rule-pack-sqlfluff-core )
- L057 — Unused CTE detection. (from rule-pack-sqlfluff-core )
- Integrate SQLFluff into CI/CD pipelines. (from rule-pack-sqlfluff-core )
Check yourself
- sqlfluff lint flags the seeded violations in the failing fixture and returns nothing on the passing one.
- CI fails on style-severity findings and stays green on the passing fixture.
Worked example
Install SQLFluff 3.0.0 with the dbt templater — from rule-pack-sqlfluff-core
pip install sqlfluff==3.0.0 sqlfluff-templater-dbt
sqlfluff --version
Set dialect and templater for your project (.sqlfluff) — from rule-pack-sqlfluff-core
[sqlfluff]
dialect = snowflake # pack default - set to your warehouse dialect
templater = dbt # pack default - or jinja for plain SQL
Lint the failing fixture and keep the passing one green — from rule-pack-sqlfluff-core
sqlfluff lint tests/fixtures/style_fail.sql # flags the seeded violations
sqlfluff lint tests/fixtures/style_pass.sql # returns nothing
Sourced from
Security scan
Last sweep 2026-10-24: 0 finding(s), 0 marked as examples.
Common gotchas
- The pack defaults to the dbt templater and the snowflake dialect — set both to your project or findings mislead.
- L014 and L030 are warnings, not style errors — severity decides what blocks CI.
- Fix legacy SQL debt incrementally; a whole-repo reformat buries the real diff.
Production considerations
- Pin sqlfluff==3.0.0 with sqlfluff-templater-dbt so CI and local runs agree.
- Exclude rules deliberately via exclude_rules rather than ignoring findings inline.
Diagram
sqlfluff pass
|
|- install sqlfluff==3.0.0 + dbt templater
|
|- set dialect + templater --> lint fixture
|
|- L003 --> L010 --> L030 --> L057 --> fix each finding
|
|- lint in CI --> passing fixture stays green
Registry stats
| Verification | community · Oct 21, 2026 |
|---|---|
| Completeness | 81 |
| Trust multiplier | ×1.25 |
| Composite | 34.15 · adequate |
| Freshness | 3 days since last source check |
| Difficulty | beginner |
| Version | 0.1.0 |
| License | CC-BY-4.0 |
| Security flags | none |
Did this solve your problem?
Fix SQL lint with the SQLFluff core rule pack