agentleFS
AL-JANEFAL-JANEF/janef-forge/skills/engineering/database-integrity/SKILL.md

database-integrity

Skill1 starsChanged 53 days agoMITView on GitHub

Schema design, migrations, transactions, indexes, query behavior, backfills, and tenant isolation or RLS. Treats every schema or migration change as high risk because deployed data already exists. Use for SQL, ORMs, data models, migration strategy, query performance, or data-integrity questions.

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

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep transactions short; define isolation needs and lock ordering for concurrent writes.

    line 25
  2. Distinctive:

    Avoid N+1 access and unbounded reads.

    line 26
  3. Distinctive:

    Test constraints, concurrent edge cases, upgrade and rollback/forward-fix paths.

    line 39

≈ “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

Database Integrity

Schema and migration changes are high risk because deployed data already exists and cannot be re-run. Put durable invariants in constraints when the database can enforce them.

Model and invariants

  • Choose types, nullability, defaults, keys, and uniqueness from domain meaning, not sample data.
  • Preserve constraints, foreign keys, uniqueness, nullability semantics, transactions, and least privilege.
  • Make tenant or ownership boundaries explicit in every access path. In multi-tenant systems a missing tenant scope is a critical finding; where RLS exists, never bypass it with a privileged role to make a query work.

Queries and transactions

  • Parameterize every query. Treat ORM convenience as syntax, not proof of correct query count or transaction behavior.
  • Inspect plans with representative cardinality before adding indexes; account for write amplification and maintenance cost.
  • Keep transactions short; define isolation needs and lock ordering for concurrent writes.
  • Avoid N+1 access and unbounded reads; paginate with stable ordering.

Migrations

  • Design expand → migrate → contract phases for mixed application versions.
  • Separate schema change, backfill, validation, and cleanup when locks or data volume matter. Backfills need batching, idempotent retries, progress tracking, and production-load awareness.
  • Make migrations deploy-compatible, observable, and recoverable; define rollback or forward-fix.
  • Destructive migrations (drop, truncate, type narrowing, data deletion) require explicit authorization and staging. Never claim one is safe without backup and restore evidence appropriate to the environment.
  • Audit-log sensitive data changes (security-logging).

Verification

  • Apply the migration from zero and against representative data; run representative queries afterwards.
  • Test constraints, concurrent edge cases, upgrade and rollback/forward-fix paths.
  • Confirm explain plans and lock impact for performance-sensitive production queries.
  • For RLS, tenant scoping, or privilege changes: run a real database check that a cross-tenant or unprivileged access is denied, and show that removing the control makes that test fail.

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.