guarded-db-migration

guarded-db-migration is a skill for Claude Code, Codex from dirtybits/agent-skills. It costs 101 tokens per session (1,531 once invoked), scanned A, original, MIT.

A cautious workflow for changing the structure of a production database, such as adding tables, columns, or indexes. A database migration is a planned change to that structure.

In plain words
What is it for?
Use it to plan, guard, rehearse, and verify schema migrations, especially when working with live data or a disposable copy of a production database.
Why use it?
It helps avoid running risky changes against the wrong database and separates safe startup changes from one-time operations that may fail on existing data.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to plan, guard, rehearse, and verify schema migrations, especially when working with live data or a disposable copy of a production database.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dirtybits/agent-skills/guarded-db-migration
Install

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.

Any agent
npx skills add dirtybits/agent-skills --skill guarded-db-migration
Clone the repo
git clone --depth 1 https://github.com/dirtybits/agent-skills

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for guarded-db-migration

README.md
[![agentmods](https://agentmods.dev/badge/skills/dirtybits/agent-skills/guarded-db-migration/github.svg)](https://agentmods.dev/skills/dirtybits/agent-skills/guarded-db-migration)
Your own site
<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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for guarded-db-migration

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,531 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00101 $0.01531
Opus 5.5 $0.00040 $0.00612
Sonnet 5.5 $0.00020 $0.00306
Haiku 4.5 $0.00010 $0.00153

Measured 3mo ago against content hash 298197ca10a4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 3mo 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.

skills/guarded-db-migration/SKILL.md · 87 lines

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)
  • DROP anything, 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:

  1. Expected-host guard. The script takes EXPECTED_DATABASE_HOST (or equivalent) and refuses to run unless it matches the host parsed from DATABASE_URL. This converts "wrong ambient connection string" from an incident into an error message. Never default it; never allow a bypass flag.
  2. Preflight-first. migrate re-runs the preflight checks internally before DDL — the world may have changed since you ran preflight manually.
  3. Idempotence or a clear refusal. Running migrate twice must either be a no-op or fail loudly before touching anything.
  4. Print everything. Target host, database, each statement as it runs, and a post-run verification summary. The transcript is the evidence.

Read the full file on GitHub · 87 lines

Files

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.

Changes

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.

  1. 3mo ago First seen · 87 lines · 101 tokens per session scan A 298197ca10a4

Subscribe to this mod's changes

guarded-db-migration is a skill published in the GitHub repository dirtybits/agent-skills (2 stars, last pushed 2mo ago), licensed MIT. It adds 101 tokens to every session and 1,531 once invoked, about $0.0004 per session on Opus 5.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.

Related

guarded-db-migration compared with skills from other repositories

guarded-db-migration next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
guarded-db-migrationdirtybits/agent-skillsSkill22mo agoMITA101Claude Code, Codex
postgresdbericrisco/rsc-harnessSkill6825d agoMITA91Claude Code, Codex
neonericrisco/rsc-harnessSkill6825d agoMITA93Claude Code, Codex
Drizzle ORM TestingPramodDutta/qaskillsSkill25227d agoMITA36Claude Code, Codex
srtd-clit1mmen/srtdSkill10526d agoMITA75Claude Code
banco-de-dados-opsricneves-ai/flowgrammers-skillsSkill1182mo agoMITA55Claude Code, Codex
supabasemartineserios/thebranaSkill39d agoMITA58Claude Code