sql-engineering
Skill11 starsChanged 8 days agoMITView on GitHub
Database-neutral SQL engineering guidance. Use when reading, writing, refactoring, reviewing, testing, or optimizing SQL queries, schemas, migrations, tables, views, functions, triggers, constraints, indexes, transactions, reporting queries, or data behavior before choosing a database-specific skill. Use api-design when SQL changes affect published contracts, observability-engineering for database telemetry, and PostgreSQL, MySQL/MariaDB, or SQLite skills for engine-specific behavior.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adversarial-reviewSkill
- api-designSkill
- architecture-reviewSkill
- behavior-driven-developmentSkill
- brainstormingSkill
- ci-release-engineeringSkill
- clean-architectureSkill
- code-reviewSkill
- container-engineeringSkill
- create-agent-skillSkill
- csharp-dotnet-engineeringSkill
- css-scss-stylingSkill
- data-platform-engineeringSkill
- dependency-supply-chain-reviewSkill
- digital-asset-managementSkill
- documentation-engineeringSkill
- domain-driven-designSkill
- domain-modelingSkill
- donsetch-web-researchSkill
- gherkinSkill
- git-commitSkill
- git-workflowsSkill
- hexagonal-architectureSkill
- impeccableSkill
- internationalization-localizationSkill
- javascript-typescript-engineeringSkill
- justfilesSkill
- mcp-server-engineeringSkill
- mysql-mariadb-sql-engineeringSkill
- observability-engineeringSkill
- onion-architectureSkill
- parallelism-engineeringSkill
- performance-reviewSkill
- playwright-e2eSkill
- postgresql-sql-engineeringSkill
- prompt-engineering-reviewSkill
- python-antipatternsSkill
- python-design-patternsSkill
- python-engineeringSkill
- random-data-identifiersSkill
- release-readinessSkill
- review-verification-protocolSkill
- root-cause-analysisSkill
- ruby-engineeringSkill
- rust-antipatternsSkill
- rust-async-webSkill
- rust-code-reviewSkill
- rust-design-patternsSkill
- rust-desktop-guiSkill
- rust-engineeringSkill
- rust-persistence-sqlSkill
- rust-testing-qualitySkill
- script-engineeringSkill
- security-review-evidenceSkill
- security-reviewSkill
- semantic-versioningSkill
- sqlite-sql-engineeringSkill
- suggest-lucide-iconsSkill
- svelte-sveltekit-engineeringSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
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
- Distinctive: line 8
Use this skill for database-neutral SQL work and as the first pass when the target engine is unknown or multiple engines are involved.
- Distinctive: line 22
Do not rely on this skill alone for PostgreSQL-specific features, MySQL/MariaDB- specific semantics, SQLite-specific semantics, …
- Distinctive: line 43
Read existing SQL in context: callers, migrations, constraints, indexes, transactions, tests, and production data assumptions.
- Distinctive: line 49
Verify against the target database engine, not mocks, when SQL semantics are the behavior being changed.
- Very specific: line 86
Use constraints for invariants the database must enforce: primary keys, foreign keys, NOT NULL, UNIQUE, CHECK, exclusion-like rules, and …
- Distinctive: line 102
Keep predicates sargable where practical and aligned with available indexes.
- Distinctive: line 103
Ensure joins do not accidentally multiply rows or turn required rows optional.
- Distinctive: line 106
Keep transactions scoped to one consistency boundary.
- Distinctive: line 109
Prefer set-based operations for bulk work.
- Distinctive: line 114
Use CTEs, window functions, lateral joins, recursive queries, upserts, partial indexes, generated columns, materialized views, or JSON …
- Distinctive: line 117
Check whether a technique is engine-specific before relying on it.
- Distinctive: line 124
Use BDD-style examples for observable data behavior such as duplicate prevention, authorization, lifecycle state, conflict responses, and …
- Distinctive: line 126
Use TDD for query bugs when practical: a fixture or integration test should fail on the old behavior for the expected reason.
- Distinctive: line 128
Test migrations and constraints against the actual engine.
- Distinctive: line 133
Before handoff, report the data behavior protected, checks run and their results, important checks skipped with reasons, and remaining …
≈ “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.
Files
SQL Engineering
Use this skill for database-neutral SQL work and as the first pass when the target engine is unknown or multiple engines are involved. Add PostgreSQL or SQLite specialist guidance when engine semantics matter.
Use When
- Reading, writing, refactoring, or reviewing SQL queries, schemas, migrations, tables, views, functions, triggers, constraints, indexes, transactions, reporting queries, data repair scripts, or query performance.
- Translating business rules into database constraints, transaction boundaries, or query behavior.
- Comparing SQL produced by ORMs/query builders with the behavior the database must enforce.
Do not rely on this skill alone for PostgreSQL-specific features, MySQL/MariaDB-
specific semantics, SQLite-specific semantics, SQLx/SeaQuery adapter code, or
ORM API usage with no SQL/schema behavior. Use
postgresql-sql-engineering,
mysql-mariadb-sql-engineering,
sqlite-sql-engineering, or
rust-persistence-sql as appropriate. Use
api-design when migrations or query outputs change a
published API/reporting contract.
For photo/video DAM catalog schema, compose with
digital-asset-management to establish
asset, rendition, metadata, edit, collection, and hierarchy invariants before
choosing SQL representations.
Workflow
- Identify the target engine, version, migration tool, schema source of truth, seed/fixture strategy, generated SQL, and CI database setup.
- State the data behavior before editing: invariants, cardinality, lifecycle, authorization, conflict handling, atomicity, retention, and rollback needs.
- Read existing SQL in context: callers, migrations, constraints, indexes, transactions, tests, and production data assumptions.
- Design schema/query changes with deploy order, data backfill, compatibility, rollback, lock/latency impact, and validation queries in mind.
- Implement with explicit columns, bound parameters, narrow transactions, meaningful constraints, and tested error mapping.
- Verify against the target database engine, not mocks, when SQL semantics are the behavior being changed.
Security Review Routing
Load security-review when SQL work touches
injection risk or dynamic SQL, privileges, roles, RLS/policies, tenant
isolation, audit logs, secret or sensitive-data handling, migration/backfill
exposure, data repair scripts, production-data access, imports/exports, or safe
error messages. Pair it with
security-review-evidence when findings
need sanitized queries, query plans, migration diffs, audit samples, dumps, or
other database artifacts.
API and Observability Routing
- Load
api-designwhen schema, migration, view, stored-procedure, reporting, outbox/event, or database error-mapping changes alter an external contract or compatibility promise. - Load
observability-engineeringwhen SQL work adds or changes query/migration telemetry, slow-query metrics, pool, lock, deadlock, replication, dashboard, alert, or runbook signals.
Reading and Refactoring SQL
- Trace each query from caller inputs to returned data and side effects.
- Confirm join cardinality, filtering order, aggregation level, grouping keys, window frames, CTE materialization assumptions, sort order, pagination, null behavior, collation, time zones, and numeric precision.
- Preserve behavior with characterization tests or before/after result checks before rewriting complex SQL.
- Separate readability refactors from semantic changes. Avoid reformatting or reordering large queries while changing behavior unless it is necessary for review.
Schema, Constraints, and Migrations
- Use constraints for invariants the database must enforce: primary keys, foreign
keys,
NOT NULL,UNIQUE,CHECK, exclusion-like rules, and valid state transitions where the engine supports them. - Migration plans should cover empty database, representative previous schema, backfill, validation, lock-heavy DDL, data loss, rollback, app/schema compatibility windows, and deployment order.
- Indexes require a query rationale. Match predicates, joins, ordering, uniqueness, and write cost to real access paths.
- Views, functions, and triggers need ownership, security, performance, error, testing, and migration stories. Do not hide core domain rules in triggers unless the repository intentionally treats the database as the rule owner.
Query and Transaction Checklist
- Select explicit columns unless the full row is the documented contract.
- Bind user-controlled values; never concatenate untrusted input into SQL.
- Keep predicates sargable where practical and aligned with available indexes.
- Ensure joins do not accidentally multiply rows or turn required rows optional.
- Make pagination stable under inserts/deletes; prefer keyset pagination for large ordered result sets.
- Keep transactions scoped to one consistency boundary. Name isolation, lock-ordering, idempotency, retry, and deadlock assumptions when writes are concurrent.
- Prefer set-based operations for bulk work; avoid row-at-a-time loops unless the domain truly needs per-row side effects.
Advanced Techniques
- Use CTEs, window functions, lateral joins, recursive queries, upserts, partial indexes, generated columns, materialized views, or JSON operations only when they simplify a real query or enforce a real invariant.
- Check whether a technique is engine-specific before relying on it. Document the target engine if portability is not a goal.
- For performance claims, compare plans or timings under comparable conditions and representative data. Do not infer performance from query appearance alone.
Testing and Review
- Use BDD-style examples for observable data behavior such as duplicate prevention, authorization, lifecycle state, conflict responses, and atomicity.
- Use TDD for query bugs when practical: a fixture or integration test should fail on the old behavior for the expected reason.
- Test migrations and constraints against the actual engine. Mocks and in-memory substitutes do not prove SQL semantics.
- Review security for injection, least privilege, RLS/policies when applicable, secret handling, audit logs, and safe error messages.
Before handoff, report the data behavior protected, checks run and their results, important checks skipped with reasons, and remaining migration, correctness, or performance risk.
Anti-Patterns
- Treating application validation as the only protection for critical data invariants.
- Adding indexes speculatively without query evidence and write-cost awareness.
- Claiming one database engine proves another engine's behavior.
- Hiding long or multi-domain transactions behind generic repository helpers.
- Storing relational facts in schemaless blobs because the first query was easy.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

