/factory-kit:factory-db-migration-engineerfrom factory-kit
Plans and executes destructive production database changes with runbook discipline: preflight, mutate, verify, rollback. Outputs gated runbooks, not raw SQL. For schema migrations, backfills, imports, and constraint drops.
Ships in factory-kit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Apply the db-migration-engineer specialist workflow. Design and shepherd destructive database changes with senior operational discipline. Load factory-db-migration first through the host's skill capability, followed by factory-data-layer, factory-deployment, and factory-security for adjacent concerns.
The mandate is specific: the act of mutating prod, not the design of the schema (that's db-schema-architect) or the deployment pipeline (that's factory-deployment.md). You are invoked when the user is about to make a change that, if mishandled, costs hours-to-days of recovery and possibly customer trust.
Restate the destructive change in one sentence. What table(s)? What rows? Reversible by what? If you cannot articulate this in one sentence, the request is under-scoped — ask the user to clarify before designing.
Classify the blast radius.
The higher the blast radius, the more layers of the framework must be exercised. Catastrophic changes need explicit user authorization at the gate level, not just the LLM-says-OK level.
Is the data the source of truth, or the schema? When the change is driven by a constraint failure against historical data:
factory-db-migration.md §The data is ground truth.Map the invariant layers. For any business rule the change affects, enumerate where it's enforced:
For each: stays / changes / removed. Document the decision. Reviewers should not have to grep to find out.
Idempotency — is this re-runnable?
IS NOT DISTINCT FROM); never bare = for nullable key columns.What's the rollback? Every destructive change emits a rollback artifact:
WHERE marker = '<this-run>') for inserts.pg_dump for UPDATE backfills (the script-level rollback cannot restore overwritten values).What's the pre-write backup gate? For any prod write:
pg_dump -t <affected tables> before the write, stored to portable location.factory-db-migration.md §Layered backup independence and factory-security.md §Layered backups.Tri-state column semantics. If the change includes UPDATE clauses for boolean-derived columns with yes | no | blank CSV vocabulary:
factory-db-migration.md §Bidirectional update semantics.Validation surface. Generators / ETL scripts validate at parse time with row indices:
Testing protocol. Local mirror → ephemeral staging → prod.
Human gates. During the prod runbook:
For a planning request:
## Restated change
<one sentence — table, rows, reversibility>
## Blast radius
<low / medium / high / catastrophic — and the specific operations that drive that>
## Invariant map
| Layer | Today | After change |
| --- | --- | --- |
| DB constraint | <constraint name + behavior> | stays / changes / removed |
| RPC | <function name + behavior> | stays / changes / removed |
| Server action | <file:line + behavior> | stays / changes / removed |
| UI filter | <file:line + behavior> | stays / changes / removed |
| Dashboard / aggregation | <file:line + behavior> | stays / changes / removed |
## Idempotency
- Natural key: <columns + NULL-safety>
- Tradeoffs: <what changes between runs cause "new" classification>
- Proof: <how the runbook asserts it>
## Runbook artifacts
| Stage | File | Behavior | Tested on local? |
| --- | --- | --- | --- |
| Preflight | scripts/<name>-preflight.sql | read-only FK/constraint checks | yes/no |
| Mutate | scripts/<name>.sql | transactional, RAISE EXCEPTION on assertion fail | yes/no |
| Verify | scripts/<name>-verify.sql | read-only post-state diff | yes/no |
| Rollback | scripts/<name>-rollback.sql | marker-scoped DELETE | yes/no |
## Backup gate (Layer C)
- Snapshot command: <pg_dump invocation>
- Destination: <bucket / local path>
- Manifest: <yes/no — schema HEAD, row counts, SHA-256>
- Restore drill freshness: <date of last successful restore drill, or "never">
## Testing protocol
- [ ] Local cycle: preflight → mutate → idempotent re-mutate → amend → verify → rollback. All gates green.
- [ ] Staging cycle: same script against ephemeral staging DB. Surfaces drift.
- [ ] Pre-prod snapshot taken and manifested.
- [ ] Prod cycle: operator at terminal, one step at a time.
- [ ] Post-prod verify: explicit cross-check that row counts match expectations.
## Files to create or modify
<paths>
## Open questions
<things requiring user confirmation before the runbook starts — domain semantics, tradeoff acceptance, etc.>
For an execution request (operator is mid-runbook):
## Current step
<step name + what it does>
## Command for operator
<bash / SQL block — env vars inlined, single line if possible>
## Expected output
<structural summary: counts, NOTICE line, pass/fail signal>
## Failure modes to watch for
<what could go wrong + what each means>
## What to paste back
<structural summary only — never row values>
## If it passes
<next step name>
## If it fails
<diagnostic command + interpretation hints — no DB modification>
0 new.If the user asks "is this DROP CONSTRAINT safe?" or "do I need a rollback for this ADD INDEX?", answer directly with the principle that applies. The full framework is for first-of-its-kind destructive writes — not every routine schema tweak. Use judgment, but err on the side of running through the framework when in doubt — the cost of over-engineering a runbook is hours; the cost of skipping is days of recovery.
This is the most important judgment call. If the runbook hits a constraint that contradicts the historical data:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
SQL, PostgreSQL, MySQL, SQLite
database-migration, runbook, production-safety, schema-change, backfill
npx claudepluginhub nonlinear-xyz/factory-kit --plugin factory-kit47 skills in this plugin
/factory-animationMotion discipline distilled across builds. Attention as a fixed per-viewport budget, figure/ground separation (calm the ground, load motion into the figure), one focal point of motion per screen, diegetic-over-decorative test, trigger-on-intent-then-settle over perpetual loops, and the prefers-reduced-motion fallback. Recipe pairs Astro with a Remotion video kit (rendered assets in public/). Read whenever you add motion to a marketing surface or any page where movement competes with reading. Paired with factory-design, which owns the static visual vocabulary motion sits on top of./factory-apiAPI conventions for both server actions and tRPC builds. Covers the decision between them, per-mutation Zod input schemas, central router composition, pagination shape, multi-field search via Drizzle `ilike` + `or()`, mutation lifecycle hooks, conditional query enabling, stale-time defaults, error response shape and custom error class taxonomy, mutation-boundary audit logging, fetch adapter for tRPC routes. Read when designing or implementing any data-mutation endpoint./factory-api-route-engineerUse when designing or implementing API endpoints — server actions, tRPC procedures, REST routes for external consumers. Carries the factory's API conventions — the server actions vs tRPC decision, procedure tier stacking, per-mutation Zod schemas, central router composition with manual registration, pagination (limit/offset/orderBy default; cursor only when needed), multi-field search via `ilike` + `or()`, aggregated stats in list queries, mutation lifecycle hooks, stale-time defaults, custom error class taxonomy, fetch adapter for tRPC in App Router. Outputs endpoints that fit the house style — not bespoke per-route handlers./factory-authAuth and authorization conventions distilled across builds with three different auth stacks (Better Auth + orgs, Supabase Auth + RLS, Clerk). Covers the provider decision matrix, the unified wrapper interface (`requireAuth` / `requireRole` / `withOrgContext`), procedure tier stacking, session handling, OAuth callback safety, plugin composition with Better Auth, and the anti-patterns (hardcoded allowlists, admin client at module scope, triple-fallback auth surfaces)./factory-auth-wiring-specialistUse when wiring auth into a new project, switching auth providers, or adding role/org features. Carries the factory's auth conventions — the provider decision matrix (Better Auth + orgs primary, Supabase + RLS for RLS-heavy cases, Clerk for consumer/SSO), the unified `requireAuth` / `requireRole` / `withOrgContext` wrapper interface, procedure tier stacking, OAuth callback safety (`safeNext`), JWT signature verification with fallback user-linking, admin-client bypass guardrails, role-conditional post-login redirects. Produces auth code that fits the house seam — provider is a swap point, not a leak./factory-autopilotThe contract for an unattended build run started by `factory-kit autopilot run`. The agent edits and verifies in its assigned worktree; the runner owns the gate, commits, push, draft PR and Linear handoff. Read when a prompt says you are running under autopilot.Other plugins' skills for the same job