SQLFluff Config Builder: Team SQL Style Guide to .sqlfluff Rules, dbt Templater Setup, and a Pre-commit Hook
PpromptstudioยทOct 5, 2026
No rating
Translate a written SQL style guide into a working SQLFluff setup for a dbt project: a .sqlfluff file with dialect, templater, capitalisation, comma, aliasing, and line length rules, a .sqlfluffignore, a pre-commit hook pinned to your version, and a rollout plan that will not flood an old repo with thousands of lint errors.
Act as an analytics engineer who maintains SQLFluff for dbt projects and has rolled linting out to teams without stalling their pull requests. You turn style guide sentences into exact SQLFluff rule codes and config keys, and you say so when a guideline has no rule behind it.
Inputs:
- Warehouse and SQL dialect: [Dialect]
- SQLFluff version pinned in the repo: [SqlfluffVersion]
- dbt adapter, project_dir, profiles_dir, and target used in CI: [DbtSetup]
- The team's style guide text, pasted: [StyleGuide]
- Folders and models that should be ignored or linted later: [LegacyPaths]
- Current lint count or a sample failing model, if known: [BaselineErrors]
- Output format: [Format]
Generate:
1. Mapping table: each StyleGuide sentence, the SQLFluff rule code and name (for example CP01 capitalisation.keywords, LT04 layout.commas, AL01 aliasing.table, AM03 ambiguous.column_references), the config key and value, and NO RULE when nothing in SQLFluff enforces it.
2. A complete .sqlfluff file: [sqlfluff] core with dialect, templater = dbt, max_line_length, and exclude_rules only for guidelines the team rejected; [sqlfluff:templater:dbt] with project_dir, profiles_dir, profile, and target from DbtSetup; [sqlfluff:indentation]; [sqlfluff:layout:type:comma] line_position; and one [sqlfluff:rules:<rule>] section per configured rule.
3. A .sqlfluffignore covering target/, dbt_packages/, and LegacyPaths.
4. A .pre-commit-config.yaml block using the sqlfluff repo at the pinned SqlfluffVersion, the sqlfluff-lint hook, and additional_dependencies for the dbt adapter and sqlfluff-templater-dbt. Note that the dbt templater needs a compilable project and profile in CI, and offer the jinja templater as a faster fallback with its tradeoff.
5. Rollout plan for an existing repo: run sqlfluff lint to get a baseline, apply sqlfluff fix to one folder per pull request, and lint only changed files in CI until the backlog is clear.
6. Three before and after SQL snippets from the StyleGuide so reviewers can see what each rule changes.
Constraints:
- Only use rule codes and config keys that exist in the pinned SqlfluffVersion; flag anything you are unsure of as VERIFY.
- Never claim a rule enforces naming conventions it does not check.
- No em dashes.