agentleFS
oberon-systemsoberon-systems/enggraph/skills/database/SKILL.md

database

Skill1 starsChanged 6 days agoMITView on GitHub

Design schemas, write migrations and write code that reads or writes a relational database - plain tables only, no foreign keys or cascades, new features in new tables, ALTER only to change a column's type or size and only with the user's explicit permission. Use before writing or reviewing any migration, DDL, or SQL in application code.

  • Deletes or force-pushes

31 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use monitoring, ci-cd and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • rogue-dev-studioSkill

    monitoring

    Claude monitoring and usage tracking tools (UV, claude-monitor, claude-usage-cli). Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `monitoring` work when listed in TEAM.yaml or explicitly requested.

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 4 projects that use this

  • klauswgSkill

    performance

    Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".

    Also in 6 projects that use this

  • 0xSeroSkill

    security

    Also in 11 projects that use this

  • JkudjoSkill

    incident

    Production incident response — structured triage, hypothesis tree, safe remediation, incident record

    Also in 3 projects that use this

  • mrgoonieSkill

    devops

    Deploy to Cloudflare (Workers, R2, D1), Docker, GCP (Cloud Run, GKE), Kubernetes (kubectl, Helm). Use for serverless, containers, CI/CD, GitOps, security audit.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 5

    Distinctive

    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 one list of every table and column that refers to a parent row, next to the code that deletes or renames the parent, and walk it there.

    line 45
  2. Distinctive:

    Delete the parent first and the dependent rows after, in separate statements, so rows a concurrent writer committed in between are seen.

    line 47
  3. Distinctive:

    Run it against a copy of real data before it reaches a live database: a fresh database proves the SQL, not the time or the data.

    line 63
  4. Distinctive:

    Run no query against a live database without the user's permission for that query.

    line 72
  5. Distinctive:

    Prefer reading the catalog and the statistics views to scanning tables.

    line 74

“Common” is measured: kept by at least 6 in 10 of the 22 edited versions of this file we could read. “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

A database here is a set of plain tables and nothing more. Every rule below exists because relations, cascades and in-place schema changes broke a production restore: rows a cascade should have taken outlived it, and the dump could not be loaded back under its own constraints.

Tables

  • No relations, ever. No REFERENCES, no FOREIGN KEY, no ON DELETE or ON UPDATE CASCADE, no triggers that write to other tables. Tables are tied by plain value columns (project, node_id, owner_id) that the code keeps consistent.
  • Inside one table, anything goes: primary keys, unique indexes, CHECK constraints, NOT NULL, defaults, any index.
  • A new feature is a new table. It holds the new columns and the value columns that tie it to existing rows. An existing table is never widened for a feature.
  • No file contents or other bulk text that lives elsewhere. Store a pointer to it - a path, a line range, a hash - and read it from its source.

ALTER

  • ALTER TABLE is allowed for one thing only: changing a column's data type or size (VARCHAR(64) to VARCHAR(255), INTEGER to BIGINT, a vector dimension).
  • Each such ALTER needs the user's explicit permission, asked for that statement and that migration. Approval of a plan or of an earlier ALTER is not permission.
  • Everything else ALTER could do is done another way: a new column or constraint means a new table; a renamed or reshaped table is copied into a new table under a new name, and the code moves to the new name: CREATE TABLE, INSERT ... SELECT, DROP TABLE.

Cleanup in code

What a cascade would have done, the code does explicitly, in the same transaction as the change that requires it.

  • Keep one list of every table and column that refers to a parent row, next to the code that deletes or renames the parent, and walk it there.
  • Delete the parent first and the dependent rows after, in separate statements, so rows a concurrent writer committed in between are seen.
  • A writer that adds a dependent row locks the parent row first (SELECT ... FOR KEY SHARE) and refuses when it is gone.
  • A test reads every table carrying a parent column from information_schema.columns and fails when one is missing from that list, and another asserts that a delete leaves no dependent row behind.
  • A test asserts that information_schema.table_constraints holds no FOREIGN KEY.

Migrations

  • One migration per change, numbered, never edited once applied.
  • It finishes in minutes on the smallest stack the project supports: no UPDATE over every row of a large table, no rebuild of a large vector index. Load a copied table first and build its indexes after.
  • Run it against a copy of real data before it reaches a live database: a fresh database proves the SQL, not the time or the data.
  • A whole-database backup is taken before every upgrade that applies one.
  • A repository that can host a pre-commit hook rejects REFERENCES, FOREIGN KEY and CASCADE in new migrations, and any ALTER TABLE other than a single column type change.

Live databases

  • Run no query against a live database without the user's permission for that query.
  • Prefer reading the catalog and the statistics views to scanning tables.

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.