agentleFS
leroyguillaumeleroyguillaume/claude/sql-conventions/SKILL.md

sql-conventions

Skill7 starsChanged 2 days agoMITView on GitHub

SQL linting and formatting with sqlfluff. TRIGGER when: creating or editing a `.sql` file (queries, migrations, seeds); adding SQL to a repo; setting up pre-commit for a project with SQL; user asks about SQL linting or sqlfluff. SKIP when: no SQL is involved.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep non-trivial SQL in .sql files rather than inline string literals, so the linter sees it and the code stays readable.

    line 61

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SQL conventions

Always lint SQL with sqlfluff. Any repo that contains .sql files must have the sqlfluff pre-commit hook. Add it to .pre-commit-config.yaml, pinned to an explicit rev:

- repo: https://github.com/sqlfluff/sqlfluff
  rev: <latest tag SHA>  # frozen: <latest tag>
  hooks:
    - id: sqlfluff-lint
  • Lint every .sql file, not just some — query files and migrations (and seeds, fixtures, …). The hook matches \.sql$, so this is automatic.
  • Add a .sqlfluff at the repo root with at least the dialect and a raw templater (plain SQL, no Jinja/dbt):

    [sqlfluff]
    dialect = postgres
    templater = raw
    max_line_length = 100

    Set dialect to the project's actual database.

  • Follow sqlfluff's style, don't fight it. Reformat the SQL to satisfy the rules rather than disabling them. In practice that means: single spaces (no column alignment in CREATE TABLE — sqlfluff's layout defaults to single spacing, and its opt-in spacing_before = align stays off), one SELECT target per line when there is more than one, and consistent keyword casing.
  • Only exclude_rules for deliberate, justified cases, with a comment saying why. The common one: using reserved-ish words as identifiers — e.g. a user table or a role column — trips RF04 (keywords as identifiers) and RF06 (unnecessary quoting, a false positive when the quotes are required). Exclude those, never silence spacing/layout rules to avoid reformatting:

    # We deliberately use the reserved words `user`/`role` as identifiers,
    # quoting `"user"` where Postgres requires it.
    exclude_rules = RF04, RF06
  • Prefer sqlfluff fix to reformat in bulk when adopting it on an existing codebase, then commit the result; keep sqlfluff-lint as the gate.

Externalising queries (when the language allows it)

Keep non-trivial SQL in .sql files rather than inline string literals, so the linter sees it and the code stays readable. In Rust with sqlx, load them with include_str!("../queries/<entity>/<op>.sql") — it stays a &'static str (so sqlx 0.9's anti-injection guard is satisfied) and the compiler tracks each file for rebuilds. See rust-build-conventions for the sqlx specifics.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.