agentleFS
TiagoGranelliTiagoGranelli/slopproof/.agents/skills/database-change/SKILL.md

database-change

Skill2 starsChanged 20 days agoMITView on GitHub

Change the Postgres schema of this repo with Drizzle. Use when adding or changing a table, column, index or constraint in src/server/db/schema, or when writing or reviewing a migration in drizzle/.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are 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.

  • 2

    Very specific

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

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

    Run pnpm db:generate --name <slug>.

    line 14
  2. Very specific:

    Run pnpm check:drift migrations and pnpm check:migrations (squawk: no statement that blocks a busy table).

    line 20

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

Steps

  1. Edit src/server/db/schema/*.ts. src/server/db/schema/auth.ts is application code: edit it by hand and keep timestamps timestamptz (the auth-change skill says how to find what Better Auth needs). An id column carries its brand from src/contract/ids.ts: uuidv7Id().$type<PostId>() for the table's own id, and authorId() is already a UserId. A foreign key to another table gets .$type<ThatId>() too.
  2. Run pnpm db:generate --name <slug>. It writes a new SQL file and updates drizzle/meta/.
  3. Review the new SQL in drizzle/. Only this new file may be adjusted by hand, and only before it is committed. A type change that must convert data gets its USING clause there, as in 0004_auth_timestamptz.sql. An index on a large table is built by hand CONCURRENTLY (docs/operations.md).
  4. Apply it: pnpm db:up, then pnpm db:migrate.
  5. Run pnpm check:drift migrations and pnpm check:migrations (squawk: no statement that blocks a busy table). Waive one statement only with -- squawk-ignore <rule> under a comment line giving the reason.
  6. A new or changed repository query gets a query budget in tests/db/<feature>-query-budget.test.ts, then pnpm test:db (read tests/db/AGENTS.md).

Rules

  • Migrations already in the journal at HEAD are frozen: databases may have applied them, so tests/unit/repo-policy.test.ts rejects an edit. Change the schema and generate a new migration instead.
  • drizzle/meta/** is written by pnpm db:generate only.

Done when

pnpm check:drift migrations, pnpm check:migrations, pnpm check:drift database (needs Postgres) and pnpm check pass, and the schema, the SQL file and drizzle/meta/ are in one commit.

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.