agentleFS
alexderzalexderz/agentic-toolbox/skills/lang-sql/SKILL.md

lang-sql

Skill5 starsChanged 46 days agoMITView on GitHub

use this when writing, reviewing, or migrating SQL — *.sql, schema files, embedded queries in host code. postgres-shaped defaults; name the dialect if it is not postgres. load with the host language skill when the query lives in application code.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    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. Distinctive:

    Run the migration against a disposable database when one exists.

    line 20
  2. Very specific:

    Check rowcount when a write must touch exactly N rows.

    line 38
  3. Distinctive:

    Avoid long transactions that hold row locks across user think-time.

    line 45
  4. Distinctive:

    Every user-influenced value is a bind parameter.

    line 57
  5. Distinctive:

    Do not edit a migration that has already run.

    line 60

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Parameterize or do not ship. No scripts/. Process skills that may load with this one: load-with list. SQL beside its host language: Algorithm.

Iron law

Parameters, never string concatenation. Migrations are forward-only and reversible, or explicitly one-way.

Tooling / verify

  • Host-language tests cover the bind path (this is the real test).
  • EXPLAIN the new query before adding an index "for speed."
  • Run the migration against a disposable database when one exists.

Name the dialect in the PR if it is not Postgres.

Idioms a linter misses

  • Bound parameters ($1, ?, named) from the host. Always.
  • Name columns. No SELECT * in application queries.
  • Transactions around multi-statement writes.
  • timestamptz for instants (Postgres). Money: integer cents or numeric, not float.
  • Indexes for predicates you actually use, not every column.
  • NOT NULL when absence has no meaning.

Errors

  • Constraint failures are data errors, not "retry until it works" unless the operation is documented idempotent.
  • Check rowcount when a write must touch exactly N rows.

Concurrency

  • Know the isolation level the app already uses.
  • SELECT … FOR UPDATE only with a transaction and a short critical section.
  • Avoid long transactions that hold row locks across user think-time.

Testing

  • Fixture data in the test DB or transaction-per-test as the project already does.
  • Assert on the rows, not only "no exception."
  • Migration tests: apply on empty and on a snapshot of prod-shaped data when the project has that harness.

PR review

  • Every user-influenced value is a bind parameter.
  • Destructive DDL has an expand-contract plan.
  • New index: EXPLAIN evidence, or do not add it.
  • Do not edit a migration that has already run.

Security

  • Least-privilege role for the app (no owner role at runtime).
  • No SECURITY DEFINER functions unless the project already uses them and the body is reviewed.
  • Views / RLS: do not assume the app layer is the only client.

Always

  • Binds. Named columns. Transactions on multi-writes.

Ask first

  • DROP COLUMN / DROP TABLE / type change of a shipped column.
  • Dialect switch (MySQL / SQLite / SQL Server).
  • New extension or SECURITY DEFINER.

Never

  • String-built SQL with user input (including "it's an int").
  • Interpolating identifiers (table/column names) from user input.
  • LIKE patterns from user text without escaping % and _.
  • Float for money.
  • Re-editing applied migrations.
  • SELECT * in app code.

Red flags

  • "I'll just interpolate, it's an int"
  • "SELECT * is fine"
  • "We'll add the index if it's slow"
  • "The ORM will escape it" without checking the generated SQL

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.