scaffold-alembic-migration

scaffold-alembic-migration is a command for Claude Code from kumaran-is/claude-code-onboarding. It costs 13 tokens per session (1,182 once invoked), scanned A, original, MIT.

A command that creates an Alembic database migration, which is a tracked change to a database schema, using a design-first workflow with SQLAlchemy models and Pydantic schemas.

In plain words
What is it for?
Use it to plan and apply changes such as adding or modifying tables and fields in a Python service, then validate the migration and related tests.
Why use it?
It helps keep database documentation, entity diagrams, application models, and schema changes aligned, with a human review before implementation continues.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions CLAUDE.md.

Good fit Use it to plan and apply changes such as adding or modifying tables and fields in a Python service, then validate the migration and related tests.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/kumaran-is/claude-code-onboarding/scaffold-alembic-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.

Clone the repo
git clone --depth 1 https://github.com/kumaran-is/claude-code-onboarding

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 scaffold-alembic-migration

README.md
[![agentmods](https://agentmods.dev/badge/commands/kumaran-is/claude-code-onboarding/scaffold-alembic-migration.svg)](https://agentmods.dev/commands/kumaran-is/claude-code-onboarding/scaffold-alembic-migration)
Your own site
<a href="https://agentmods.dev/commands/kumaran-is/claude-code-onboarding/scaffold-alembic-migration"><img src="https://agentmods.dev/badge/commands/kumaran-is/claude-code-onboarding/scaffold-alembic-migration.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,182 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.00013 $0.01182
Opus 5 $0.00006 $0.00591
Sonnet 5 $0.00003 $0.00236
Haiku 4.5 $0.00001 $0.00118

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

Security

Grade A, and why

scaffold-alembic-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 4d 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/commands/scaffold-alembic-migration.md · 141 lines

How it starts

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

/scaffold-alembic-migration

Generate a new Alembic database migration following the design-first workflow.

Usage

/scaffold-alembic-migration <description>

Example: /scaffold-alembic-migration add_user_table

Prerequisites

Before running, identify the project's Alembic configuration:

  • Alembic config file location (typically alembic.ini under the shared services directory)
  • SQLAlchemy models directory
  • Pydantic schemas directory

Check the project's CLAUDE.md for the canonical paths.

Full Workflow

Step 1 — Design Doc Update (human reviews before code)

Update the design docs to reflect the planned change:

# Read current schema docs (adjust paths to your project)
cat docs/database/entity-model.md
cat docs/database/entity-erd.md
  • Add/modify the entity definition in the schema docs
  • Add/modify the Mermaid ERD
  • Present the doc diff to the human — do NOT proceed until approved

Step 2 — Update SQLAlchemy Model (source of truth)

Locate the shared models directory for this project and update the relevant model file.

Rules:

  • Use Mapped[] type annotations (SQLAlchemy 2.0+ async)
  • Import and extend the project's Base and any shared mixins (e.g. TimestampMixin, UUIDMixin)
  • Add proper foreign keys with ForeignKey() constraints
  • Add relationship back-references where needed
  • Export the new model in the models __init__.py

Step 3 — Update Pydantic Schemas

Locate the shared schemas directory and update the relevant schema file:

  • Create/update request and response schemas matching the model
  • Export in schemas/__init__.py

Step 4 — Generate Migration (autogenerate)

# Adjust the -c path to match the project's alembic.ini location
uv run alembic -c <path/to/alembic.ini> revision --autogenerate -m "$ARGUMENTS"

Step 5 — Self-Review Migration (AI blind spot check)

Read the generated migration file and check for these known autogenerate problems:

Problem Detection Fix
Column rename → shows as drop+add op.drop_column + op.add_column for same data Rewrite as op.alter_column(table, old_name, new_column_name=new_name)
Enum value addition PostgreSQL enums need ALTER TYPE ... ADD VALUE Add op.execute("ALTER TYPE enum_name ADD VALUE 'new_val'") manually
Enum value removal Autogenerate ignores this entirely Write manual migration — PostgreSQL can't remove enum values in-place
Data loss risk Any op.drop_column or op.drop_table Flag with # WARNING: DATA LOSS — requires human approval comment
Missing index New FK column without index Add op.create_index() for expected query patterns
pgvector column Vector columns need special handling Ensure from pgvector.sqlalchemy import Vector is imported
Nullable mismatch Default nullable doesn't match model intent Verify nullable=True/False matches Optional[] in model

Read the full file on GitHub · 141 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. 4d ago First seen · 141 lines · 13 tokens per session scan A bfdf8b8e52b9

Subscribe to this mod's changes

scaffold-alembic-migration is a command published in the GitHub repository kumaran-is/claude-code-onboarding (35 stars, last pushed 2mo ago), licensed MIT. It adds 13 tokens to every session and 1,182 once invoked, about $0.0001 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-09-03.