/speckit-product-forge:speckit.product-forge.migration-planfrom speckit-product-forge
Generates a zero-downtime data migration plan from schema changes in plan.md: schema diff, strategy per change, forward/rollback/validation scripts, backfill outline, and risk matrix.
Ships in speckit-product-forge. Installing the plugin adds it to Claude Code.
You are the Migration Strategist. Turn the data-model changes in plan.md
into an explicit, reversible, zero-downtime migration plan with real forward and
rollback scripts, so Phase 6 (Implement) never improvises a migration.
$ARGUMENTS
Follow the command contract.
migration_plan (Phase 5.5)project_tech_stack, features_dir, storage_strategymigrations/forward.sql (or .ts), migrations/rollback.sql (or
.ts), migrations/validation.sql, migrations/backfill.md (when needed),
migrations/risk-matrix.md, migrations/migration-plan.md,
migrations/digest.md, phases.migration_plan.*--db=<mongodb|postgres|mysql> sets the DB kind; without
it, detect it (Step 0).plan.md exists and its Data Model section is non-empty. No schema changes →
exit with "No data-model changes detected in plan.md — migration plan not needed."--db, else project_tech_stack when clear, else plan.md hints
(Prisma schema ⇒ Postgres/MySQL; Mongoose schema ⇒ MongoDB; raw SQL ⇒ inspect).| Change | Field / collection | Type | Reversible? |
|---|---|---|---|
| ADD | User.push_token | `string | null` |
| MODIFY | Subscription.status (enum active → trialing) | enum | ⚠️ data-dependent |
| DROP | User.legacy_flag | bool | ❌ destructive |
Flag every ❌ row as HIGH RISK.
Pick one strategy per change, defaulting toward the safest:
| Strategy | When to use |
|---|---|
| Shadow column + dual-write | Renames, type widenings, non-nullable additions on non-empty tables. |
| Expand–migrate–contract | Any data backfill touching > 10k rows. |
| Blue-green | Changes to hot paths where a short flip window is acceptable. |
| Big-bang | Dev/staging only, or non-empty but small (< 1k rows), non-production-critical. |
Zero-downtime is the default: big-bang needs an explicit written rationale, and for a production-critical change it becomes an action item instead.
Delegate to db-migration-manager (Postgres / MySQL / Prisma) or mongodb-ops
(MongoDB), matching the DB kind, with the Step 1 diff and the Step 2 strategies.
Produce, under {FEATURE_DIR}/migrations/:
forward.sql (or forward.ts for Mongo) — runnable as-is against a copy of
the database; real DDL, not stubs.rollback.sql (or rollback.ts).validation.sql — post-migration assertions (row counts, constraint
existence, index presence).When a rollback cannot recover data, start rollback.sql with:
-- WARNING: rollback is destructive — <field> data will be lost.
-- Take a backup before applying forward.sql.
Whenever a backfill is required (expand–migrate–contract selected), write
migrations/backfill.md — a backfill never hides inside forward.sql
unplanned. Sections:
backfill_progress (cursor, started_at, ...)).Write migrations/risk-matrix.md:
| # | Risk | Severity | Mitigation |
|---|---|---|---|
| 1 | Unique constraint violation during dual-write | HIGH | Pre-backfill check query; abort if non-zero matches. |
| 2 | Index build blocks writes | MEDIUM | Use CREATE INDEX CONCURRENTLY (Postgres). |
| 3 | Replication lag under backfill load | MEDIUM | Throttle + monitor replica_lag_ms. |
Every row carries a concrete mitigation ("monitor carefully" is not one), and every destructive change appears as a risk.
migrations/migration-plan.mdWrite it from docs/templates/migration-plan-migration-plan.md.
Write migrations/digest.md from docs/templates/phase-digest.md,
then the run summary under the phase key (never a top-level migration: block):
phases:
migration_plan:
status: "completed"
started_at: "{ISO}"
completed_at: "{ISO}"
digest_path: "migrations/digest.md"
db_kind: "{postgres | mongodb | ...}"
strategy: "{primary}"
destructive_changes: {true | false}
files:
plan: "migrations/migration-plan.md"
forward: "migrations/forward.sql"
rollback: "migrations/rollback.sql"
validation: "migrations/validation.sql"
status here is the standalone value: set it from the gate decision (approve →
completed). Under --from-forge, write the digest and the data fields, leave
status out, and return the outcome to forge.
forward, rollback and validation scripts exist and are runnable.backfill.md exists whenever a backfill is required.migration-plan.md follows the template.--from-forge: digest and migration_plan data fields written; outcome
(DB kind, strategy, destructive changes) returned to forge; no gate prompt, no
status write.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub vaiyav/speckit-product-forge --plugin speckit-product-forge33 commands in this plugin
/speckit.product-forge.api-docsPublish API docs after implement: reconcile the OpenAPI/AsyncAPI contracts with the implementation (or author OpenAPI 3.1 when no contracts exist), generate a Postman collection, and report contract↔implementation drift.
/speckit.product-forge.backfillReverse-engineer a Product Forge feature folder from existing code: retro product spec, plan, tasks, initial canonical spec, a `backfilled: true` status file and a gaps report. Use to bring a brownfield module under Product Forge.
/speckit.product-forge.bridgeConverts the approved product spec into a research-backed SpecKit spec.md (Phase 4), with FE↔BE contracts and delta specs, then hands off to the classic or V-Model flow. Use after revalidation approves the product spec.
/speckit.product-forge.catalogBuild or verify the feature catalog `_portfolio/catalog.yml` — one small index over every feature that agents read before opening feature folders. Use after status changes outside forge, or with `--check` as a CI freshness gate.
/speckit.product-forge.change-requestChange request: when scope changes mid-lifecycle, record it as CR-NNN, analyse its impact and effort across every artifact, then apply, defer or reject it — with a delta spec, an optional phase rollback, and a sync-verify afterwards.
/speckit.product-forge.code-reviewReviews implemented code (Phase 6B) after machine gates pass: quality, security, pattern consistency, test coverage and doc↔code drift, judged against the feature's spec, plan and codebase analysis. `--cross-model` adds an independent review by another model.
Other plugins' commands for the same job