add-db-migration

add-db-migration is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 65 tokens per session (1,359 once invoked), scanned A, original, Apache-2.0.

A guide for changing a database schema, the definition of stored tables, columns, indexes, and rules, through a migration.

In plain words
What is it for?
Use it to add or change tables and columns, indexes, constraints, or backfills, with reversible and scale-conscious migration steps.
Why use it?
It reduces the risk of data loss, locked tables, downtime, or code that cannot work with the changed database.

Skill for Claude CodeCodex

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

Good fit Use it to add or change tables and columns, indexes, constraints, or backfills, with reversible and scale-conscious migration steps.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/add-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 tmj-90/gaffer --skill add-db-migration
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

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 add-db-migration

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/add-db-migration/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/add-db-migration)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/add-db-migration"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/add-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 add-db-migration

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/add-db-migration"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/add-db-migration.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,359 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.00065 $0.01359
Opus 5.5 $0.00026 $0.00544
Sonnet 5.5 $0.00013 $0.00272
Haiku 4.5 $0.00006 $0.00136

Measured 21d ago against content hash b5a0daa62116, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

add-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 21d 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.

runner/skills/add-db-migration/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Add a database migration

During a rolling deploy the old code and the new code run against the same schema at the same time, and a migration that takes a strong lock on a busy table stalls every query behind it. So every migration must be compatible with the code on both sides of the deploy, take only brief locks, and be reversible or explicitly justified.

Steps

  1. Read the conventions. Call search_lore for the tool (Flyway, Liquibase, Alembic, Prisma, Knex, Django, Active Record, golang-migrate), naming and numbering, whether migrations run in a transaction, and any zero-downtime ADR. Generate the file with the repo's generator; never edit a migration that may already have been applied elsewhere, add a new one.
  2. Classify the change.
    • Additive and safe: new table, nullable column, column with a constant default on engines that store it as metadata (PostgreSQL 11+, MySQL 8 instant), a new index built online.
    • Needs expand/contract: rename or retype a column or table, add NOT NULL, split or merge columns, drop anything still read by deployed code.
    • Destructive or high-risk: dropping data, narrowing a type, rewriting a large table, a backfill that cannot be undone. Call mark_ticket_blocked with the specifics and the safe plan you propose; a human decides. (On a resumed delivery mark_ticket_blocked is refused — raise it with request_decision, the ticket_id and severity human_required instead, and do not commit the destructive migration: the runner still submits what is committed.)
  3. Use expand → migrate → contract (parallel change) for anything not purely additive, one phase per ticket or deploy:
    • Expand: add the new column/table; the code writes both old and new and still reads old.
    • Migrate: backfill; switch reads to new; verify.
    • Contract: stop writing old; tell the ORM to ignore it; drop it in a later deploy. This ticket delivers only its phase. State in the evidence which phase this is and what the next one must do.
  4. Keep locks short. Set a lock_timeout (a few seconds) so a blocked DDL fails instead of queueing all traffic behind it. On PostgreSQL: CREATE INDEX CONCURRENTLY (outside a transaction); foreign keys and CHECK constraints added NOT VALID then VALIDATE CONSTRAINT separately; NOT NULL via a validated CHECK first; unique constraints from a concurrently built unique index. On MySQL prefer ALGORITHM=INSTANT/INPLACE, LOCK=NONE. Never change a column type in place on a large table.
  5. Backfill in batches, outside the schema transaction. Iterate by primary-key range (e.g. 1,000–10,000 rows), commit per batch, make it idempotent and resumable (WHERE new_col IS NULL), and throttle. New writes must already populate the new column (expand phase) so the backfill converges.
  6. Write the down migration that restores the previous schema, or a comment stating why a true rollback is impossible and how to recover (e.g. restore from the old column still present).
  7. Apply it against the database the repo's test setup creates (the runner scrubs *_URL variables such as DATABASE_URL; never point a migration at a shared or production database): run up, down, then up again, on a database that contains representative rows (an empty table hides NOT NULL, unique and type-cast failures).
  8. Test the schema's behaviour per AC. A test that exercises each AC's own behaviour: the constraint rejects bad rows, the default applies, the backfill fills every row and is safe to run twice, the old and new code paths both work during the expand phase. Run the suite (the run-tests skill).
  9. Evidence with the record-evidence skill: the migration file, the up/down/up output, the phase, and the test results.

Read the full file on GitHub · 94 lines

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. 21d ago Changed · +46 lines b5a0daa62116
  2. 1mo ago First seen · 48 lines · 65 tokens per session scan A 7b13cfd5cb32

Subscribe to this mod's changes

add-db-migration is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 21d ago), licensed Apache-2.0. It adds 65 tokens to every session and 1,359 once invoked, about $0.0003 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

Other skills, from other repositories

bulwark-brainstorm

Role-based brainstorming with dual modes: --scoped (sequential Task tool, 5 roles) and --exploratory (Agent Teams peer debate, 4 roles). Use for feasibility assessment and idea validation.

QBall-Inc/the-bulwark · 50 tokens

plan-creation

Create structured implementation plans via a 4-role scrum team (Product Owner, Architect, Eng/Delivery Lead, QA/Critic) with optional Agent Teams peer debate mode.

QBall-Inc/the-bulwark · 38 tokens

anthropic-validator

Validates Claude Code assets (skills, hooks, agents, commands, MCP servers, plugins) against official Anthropic standards. Fetches latest docs dynamically and produces structured validation reports.

QBall-Inc/the-bulwark · 40 tokens

code-review

Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.

QBall-Inc/the-bulwark · 61 tokens

create-subagent

Generates single-purpose Claude Code sub-agents for use via the Task tool. Use when creating dedicated sub-agents, scaffolding agent definitions, or generating agents with diagnostics and permissions setup.

QBall-Inc/the-bulwark · 42 tokens

test-audit

Audit test suites for T1-T4 violations using AST analysis, mock detection, and multi-stage synthesis. Invoke when user asks to audit tests, check test quality, find mock violations, review test effectiveness, or inspect test suites for over-mocking. Triggers automatic rewrites when quality gates fail.

QBall-Inc/the-bulwark · 0 tokens