Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add dirtybits/agent-skills --skill guarded-db-migrationgit clone --depth 1 https://github.com/dirtybits/agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/dirtybits/agent-skills/guarded-db-migration)<a href="https://agentmods.dev/skills/dirtybits/agent-skills/guarded-db-migration"><img src="https://agentmods.dev/badge/skills/dirtybits/agent-skills/guarded-db-migration.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00101 | $0.01531 |
| Opus 5 | $0.00051 | $0.00766 |
| Sonnet 5 | $0.00020 | $0.00306 |
| Haiku 4.5 | $0.00010 | $0.00153 |
Grade A, and why
guarded-db-migration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Guarded DB Migration
Why this skill exists
The two classic agent-caused database incidents are: (1) risky DDL placed in a request-time schema initializer, so the first failure takes down every route that touches the table; and (2) a migration script pointed at the wrong database — a legacy project, a teammate's branch, production instead of staging — because the connection string was ambient. Both are fully preventable with three habits: the additive/guarded split, the expected-host guard, and a rehearsal on a disposable copy of production.
1. The additive/guarded split (decide where the DDL lives)
Runtime schema initializers (code that runs CREATE TABLE IF NOT EXISTS on boot or first request) may contain only additive, race-tolerant, cannot-fail-on-live-data statements:
CREATE TABLE IF NOT EXISTS,CREATE INDEX IF NOT EXISTS(non-unique),ADD COLUMN IF NOT EXISTS- Idempotent backfills that tolerate concurrent execution
Everything that can fail on live data goes in a guarded one-shot script — never in the initializer:
CREATE UNIQUE INDEX(fails on existing duplicates)DROPanything,ALTER ... DROP CONSTRAINT, primary-key swaps- Backfills that assume exclusive access or specific data shape
- Anything requiring a duplicate scan or data repair first
Rule of thumb: if the statement could throw because of the data (not just the schema), it is one-shot-script material.
2. The guarded one-shot script pattern
Write the migration as a standalone script (e.g. scripts/<name>-migration.ts) with two subcommands:
<script> preflight # read-only: reports duplicates/violations/row counts; exit nonzero if migrate would fail
<script> migrate # performs the DDL, in order, inside the smallest safe transaction scope
Non-negotiable guards in migrate:
- Expected-host guard. The script takes
EXPECTED_DATABASE_HOST(or equivalent) and refuses to run unless it matches the host parsed fromDATABASE_URL. This converts "wrong ambient connection string" from an incident into an error message. Never default it; never allow a bypass flag. - Preflight-first.
migratere-runs the preflight checks internally before DDL — the world may have changed since you ranpreflightmanually. - Idempotence or a clear refusal. Running
migratetwice must either be a no-op or fail loudly before touching anything. - Print everything. Target host, database, each statement as it runs, and a post-run verification summary. The transcript is the evidence.
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 7d ago First seen · 87 lines · 101 tokens per session scan A 298197ca10a4
guarded-db-migration is a skill published in the GitHub repository dirtybits/agent-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 101 tokens to every session and 1,531 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
database-patterns
Database design and migration patterns for Alembic migrations, schema design (SQL/NoSQL), and database versioning. Use when creating migrations, designing schemas, normalizing data, managing database versions, or handling schema drift.
Drizzle ORM Testing
Testing patterns for Drizzle ORM covering migration testing, query builder testing, transaction testing, and database integration testing with PostgreSQL, SQLite, and MySQL.
forgetful-cli-setup
Set up the Forgetful CLI and connect from a terminal — install, local or remote mode, auth, and verification. Use when connecting a human or headless agent via shell, wiring CI with token auth, or operating a local server (serve, database selection, feature flags, re-embedding). Also covers the machine contract…
srtd-cli
This skill should be used when the user mentions "srtd", "sql templates", "migrations-templates", "live reload sql", "supabase functions", when working with files in supabase/migrations-templates/, when .buildlog.json or srtd.config.json is detected, or when writing Postgres functions/views/triggers for Supabase.
neon
Use when you have picked Neon (serverless Postgres) and need to connect correctly from a serverless or edge runtime, wire database branching into dev, preview and CI, or stop being burned by scale-to-zero cold starts and pooler limits — including choosing HTTP versus WebSocket connections and pooled versus direct…
postgresdb
Use when PostgreSQL engine behaviour decides the answer — schema and type design, index choice, reading EXPLAIN on a slow query, zero-downtime DDL and backfills, or ops (roles, RLS, pooling, vacuum, partitioning, PITR). PG16, ORM-agnostic. NOT portable query logic (that is sql), NOT a managed provider's platform…