feat: add rtk sqlfluff lint with JSON filter (~75% token reduction)#253
Open
TheGlitching wants to merge 1 commit intortk-ai:masterfrom
Open
feat: add rtk sqlfluff lint with JSON filter (~75% token reduction)#253TheGlitching wants to merge 1 commit intortk-ai:masterfrom
TheGlitching wants to merge 1 commit intortk-ai:masterfrom
Conversation
…ction) Adds `rtk sqlfluff lint` for SQL linting workflows, particularly dbt projects. Discovered as a savings opportunity via `rtk discover`. - Injects `--format json` automatically; passes through if user sets it - Groups violations by rule (top N) and by file with per-file breakdown - Shows fixable count and suggests `sqlfluff fix` when relevant - Passes fix/format/version/parse subcommands through unchanged - Preserves exit codes for CI/CD compatibility - dbt-aware path compaction: keeps models/, macros/, seeds/ prefixes Real-world tested on a production dbt project. Discovered that sqlfluff v3+ uses `start_line_no`/`start_line_pos` field names (not `line_no`); fixed and covered with a regression test using real command output. 13 tests: happy path, edge cases, JSON parse fallback, real schema regression, and token savings assertion (≥60% verified).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
Found
sqlfluff lintas a missed opportunity usingrtk discoveron aproduction dbt project — commands unhandled. This adds
rtk sqlfluff lintfollowing the same pattern as
rtk ruff.How it works
--format jsonautomatically so output is structuredsqlfluff fixwhen relevantfix,format,versionsubcommands pass through unchangedmodels/,macros/,seeds/prefixesReal-world discovery
While testing, I found that sqlfluff v3+ uses
start_line_no/start_line_posin its JSON output (not
line_no/line_posas older docs suggest). Fixed andcovered with a regression test using actual command output.
Tests
13 tests: happy path, edge cases, JSON parse fallback, real schema
regression fixture, and token savings assertion (≥60% verified).
Example output
Before (
sqlfluff lint models/):~3,000 tokens of raw text with per-line violations
After (
rtk sqlfluff lint models/):SQLFluff: 10 violations in 3 files (2 fixable)
═══════════════════════════════════════
Top rules:
RF01 (4x)
LT09 (3x)
LT12 (2x)
Top files:
models/staging/stg_customers.sql (5 violations)
RF01 (2)
LT09 (2)
LT12 (1)
...
💡 Run
sqlfluff fixto auto-fix 2 violations