db-migration

db-migration is a skill for Claude Code from nikandr-surkov/ai-saas-starter. It costs 34 tokens per session (391 once invoked), scanned A, original, MIT.

A guided procedure for changing a PostgreSQL database structure safely. It updates the schema definition, generates a migration, reviews the resulting SQL, applies it locally, and runs tests.

In plain words
What is it for?
Use it for changes under src/db/, such as adding or changing tables, columns, foreign keys, timestamps, money fields, or enums.
Why use it?
It prevents edits to the database's permanent migration history and helps catch accidental data loss, missing indexes, or incorrect types before applying a change.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions AGENTS.md.

Good fit Use it for changes under src/db/, such as adding or changing tables, columns, foreign keys, timestamps, money fields, or enums.

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

Made for: Claude Code.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/nikandr-surkov/ai-saas-starter/db-migration"><img src="https://agentmods.dev/badge/skills/nikandr-surkov/ai-saas-starter/db-migration.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 391 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.00034 $0.00391
Opus 5 $0.00017 $0.00196
Sonnet 5 $0.00007 $0.00078
Haiku 4.5 $0.00003 $0.00039

Measured 9d ago against content hash 0f06f9feb133, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

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 9d 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.

.claude/skills/db-migration/SKILL.md · 38 lines

What it actually says

Database migration

Applied migrations are immutable history. This skill exists so nobody ever "just edits the SQL file".

Steps

  1. Ask the user first. Schema changes are on the ASK FIRST list in AGENTS.md. Describe the change and why.
  2. Edit src/db/schema.ts only. Conventions:
    • Every foreign key gets an index.
    • Timestamps: createdAt with defaultNow(), timezone-aware.
    • Money in integer cents; credits in integers.
    • Enums via pgEnum, named <table>_<column>.
  3. Generate: pnpm db:generate. Never write migration SQL by hand.
  4. Read the generated file in drizzle/. Confirm: no unintended DROP, correct column types/defaults, indexes present. Column renames often generate drop+create — if data must survive, say so and write the migration plan out for the user before applying.
  5. Apply locally: pnpm db:migrate (Postgres running via docker compose up -d).
  6. Run pnpm test — the ledger suite will catch schema drift in credit tables.
  7. Commit src/db/schema.ts and the new drizzle/ files together.

Never

  • Edit or delete an existing file in drizzle/.
  • Run drizzle-kit push against anything but a throwaway local DB — this repo uses generated, committed migrations.
  • Touch credit_transactions semantics (signed integer amounts, UNIQUE idempotencyKey) without reading .claude/rules/billing.md.
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. 9d ago First seen · 38 lines · 34 tokens per session scan A 0f06f9feb133

Subscribe to this mod's changes

db-migration is a skill published in the GitHub repository nikandr-surkov/ai-saas-starter (19 stars, last pushed 1mo ago), licensed MIT. It adds 34 tokens to every session and 391 once invoked, about $0.0002 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-30.

Related

Other skills, from other repositories

optimize-a-query

Diagnose and fix a slow Postgres query in the builders-stack — read its EXPLAIN plan, find the missing index or the ORM N+1, and confirm the fix. Use when a page or endpoint is slow, a query times out, or pgstatstatements shows a hot query. Pairs with design-a-schema for the index itself.

lonormaly/builders-stack · 77 tokens

run-lean-on-neon

Keep Postgres fast under load and inside Neon's free tier. Use when choosing a connection string, worrying about "the DB crashes at load", deciding a session strategy, or trying to stay under Neon's free limits (storage / compute-hours). Corrects the common mistake of reaching for postgresql.conf / PgTune — most of…

lonormaly/builders-stack · 80 tokens

laravel-vector-search

Use when implementing semantic/vector search in Laravel 13 with PostgreSQL + pgvector.

fusengine/codex · 22 tokens

prisma-database-setup

Guides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing databases, or troubleshooting connection issues. Triggers on "configure postgres", "connect to mysql", "setup mongodb", "sqlite setup".

IvanTsxx/AI-Nextjs-Monorepo-Starter · 67 tokens

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens

postgresql-table-design

Use this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features.

wshobson/agents · 37 tokens