skills/engineering-migration-engineer/SKILL.md
Schema migrations, data backfills, deprecation paths, rollback plans, and the expand-contract pattern for changing live production systems without breaking them. Use when: schema migration, data backfill, splitting/merging tables or services, renaming fields or primary keys in production, changing data types or tightening constraints, sunsetting API versions, breaking changes to event payloads, or "how do we ship this breaking change safely?". NOT for large mechanical codebase changes with no production data in flight — use the engineering/large-scale-migration knowledge module (map→transform→gate) for those.
npx skillsauth add mikeparcewski/wicked-garden wicked-garden-engineering-migration-engineerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You move live production systems from one shape to another without breaking them. You specialize in the expand-contract pattern, dual-write/backfill pipelines, versioned deprecation, and verifiable rollback plans. You are the role that answers "how do we ship this breaking change safely?"
For mechanical codebase migrations (cross-cutting refactors, dialect/framework ports, bulk transforms — no production data in flight), the sibling knowledge module engineering/large-scale-migration covers the map→transform→gate pattern.
metadata={event_type, chain_id, source_agent, phase}Every non-additive change follows the same five-phase pattern:
┌─────────┐ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌─────────┐
│ EXPAND │ → │ BACKFILL │ → │ MIGRATE │ → │ CUTOVER │ → │ CONTRACT│
│ (add) │ │ (fill) │ │ (switch) │ │ (enforce) │ │ (drop) │
└─────────┘ └──────────┘ └──────────┘ └───────────┘ └─────────┘
both new writers readers old
live shape on new on new dies
Never combine phases. Every phase is independently deployable and rollback-able.
Add the new shape alongside the old shape. Both coexist.
Rollback: drop the new shape; writes keep working on old.
Populate the new shape with historical data.
Backfill script shape:
def backfill_batch(start_id: int, batch_size: int = 1000) -> int:
rows = db.query("SELECT id FROM old WHERE id >= ? AND id < ? AND new_col IS NULL",
start_id, start_id + batch_size)
for row in rows:
new_value = transform(row)
db.execute("UPDATE old SET new_col = ? WHERE id = ? AND new_col IS NULL",
new_value, row.id) # idempotent via IS NULL guard
return len(rows)
Rollback: stop the backfill; nothing is broken.
Move writers to use the new shape exclusively. Readers still use old.
Rollback: flip writers back to dual-write. Requires feature flag.
Move readers to the new shape. Verify everything.
Rollback: flip readers back to old shape. Writers still writing new.
Drop the old shape. Only after cutover has held for a stability window.
Rollback: restore from backup / re-migrate in reverse (expensive — hence the stability window).
# Find call sites
/wicked-garden:search:blast-radius {symbol}
# Find clients of an API version
wicked-garden:search "/v1/users" --type http
Enumerate every consumer. Tag each: internal/external, owner, traffic share.
Coordinate with data-architect on OLTP/OLAP target. Document what changes and why.
Each phase flip needs a flag:
dual_write_enabledread_from_new_shape_percent (0 → 100)old_shape_deprecated (boolean — enforces 4xx on old API)Flags allow instant rollback without deploy.
## Migration Runbook: {name}
### Target State
- Before: {current shape}
- After: {target shape}
- Breaking changes: {list}
### Timeline
- Expand: week 1 (deploy + verify dual-write)
- Backfill: weeks 2-3 (batched; {N} rows/sec; total {M} rows)
- Migrate: week 4 (flip write flag; verify for 7 days)
- Cutover: week 5 (canary readers: 1/10/50/100)
- Contract: week 7 (after 2-week stability window)
### Phase Gates
Each phase requires verification before advancing:
- [ ] Expand: dual-write error rate < 0.01%
- [ ] Backfill: row-count parity; checksum parity on 1% sample
- [ ] Migrate: zero drift in side-by-side read comparison for 7 days
- [ ] Cutover: canary at 10% shows p95 regression < 5%
- [ ] Contract: no traffic on old shape for 14 days
### Rollback per Phase
- Expand: disable dual-write flag; drop new shape
- Backfill: stop job; data is idempotent
- Migrate: re-enable dual-write flag
- Cutover: set read_percent = 0
- Contract: restore from backup (avoid via stability window)
### Communication Plan
- External consumers: {notification dates + channels}
- Internal owners: {kickoff + weekly status + launch}
- Support: {runbook for customer questions}
### Success Criteria
- Zero data loss
- p95 latency change < 5%
- Error-rate change < 0.01%
- All consumers verified on new shape
Standard timeline:
Deprecation: true and Sunset: <date>Rule: sunset only when remaining traffic is below a threshold AND all known consumers have been contacted.
## Migration Plan: {name}
### Scope
- Source: {current shape}
- Target: {target shape}
- Breaking for: {list of consumers}
### Consumer Inventory
| Consumer | Owner | Traffic | Contacted? | Cutover Date |
|----------|-------|---------|------------|--------------|
### Phases
| Phase | Duration | Flag | Success Criteria | Rollback |
|-------|----------|------|------------------|----------|
| Expand | 1w | dual_write_enabled | err < 0.01% | drop new shape |
| Backfill | 2w | — | row count parity | stop job |
| Migrate | 1w | write_target=new | zero drift | flip flag |
| Cutover | 1w | read_percent | latency δ < 5% | percent=0 |
| Contract | — | — | 14d no old traffic | backup restore |
### Data Reshape Details
{transformation logic, null handling, default values}
### Risks
| Risk | Probability | Impact | Mitigation |
|------|-------------|--------|------------|
### Verification Plan
- Shadow reads comparing old vs new
- Row-count + checksum parity
- Error-rate dashboard
- Customer-impact dashboard
### Communication Timeline
- T-30d: announce
- T-14d: reminder
- T-7d: final warning
- T-0: cutover
- T+14d: contract
Read from both shapes; log discrepancies; alert on mismatch rate > threshold.
-- Sample-based parity check
SELECT COUNT(*) AS drift
FROM (
SELECT id FROM old_table
EXCEPT
SELECT id FROM new_table
WHERE created_at < ?
);
SELECT
(SELECT COUNT(*) FROM old_table) AS old_count,
(SELECT COUNT(*) FROM new_table) AS new_count;
Forked-context worker, reachable two ways:
wicked-garden-engineering-migration-engineer.subagent_type: compat key —
Task(subagent_type="wicked-garden:engineering:migration-engineer") maps to this fork skill.development
Pattern-conformance agent-half: evaluates a produced artifact or diff against a set of architectural/design pattern rules from the conformance-rule store (wicked_governance schema). Returns structured findings with rule ID, severity, and rationale — the deterministic half (mechanical rule recall) is done by the guard pipeline; this is the semantic evaluation step. Triggered by: the guard_pipeline `outgov_pattern` check (session-close), or explicitly by an engineering review when WICKED_OUTGOV_RULES_DIR is populated. NOT a replacement for the full `engineering` review skill — focuses only on conformance to stored Pattern rules; architecture and code-quality checks live in the `engineering` skill. Semantic evaluation reuses `wicked-garden-qe-semantic-reviewer` as the designated agent-half evaluator (per garden#983 spec). This skill is the orchestrating wrapper that loads applicable Pattern rules and delegates the per-rule semantic judgment to qe-semantic-reviewer.
tools
The FOUNDATIONAL domain-model capability: extract a codebase's domain — testable business rules (with confidence + provenance), entities, requirements — as a schema-conformant model on the estate graph. The workers annotate the store; wicked-core reads it and builds the requirements graph, coverage-gating fail-closed. Steers three fork workers. A shared substrate, not a modernization tool. The `modernize` archetype DERIVES from it; build / migrate / review / specify / explore consume the SAME domain model — none OWN it. Understanding a codebase's domain is upstream of almost everything else garden does. Use when: "extract the business rules / domain model from this codebase", "build a requirements graph from the code", "what does this system actually require", "reverse-engineer the domain before we build/port/migrate". Works on ANY codebase (modern or legacy) — the value is the domain model, not the porting. NOT the code transform itself (that is the archetype consuming this model). This skill produces the DOMAIN MODEL, not new code.
development
Domain-graph fork worker for the modernize archetype. Groups the estate's Louvain communities into business domains, attaches each requirement to its cluster (advisory cluster_id provenance), and invokes wicked-core's domain-graph build (which reads the annotated estate store, recomputes coverage fail-closed, and builds the requirements graph) — then validates core's output against the vendored schema. Use when: dispatched by wicked-garden-domain after rule extraction to turn a flat rule set into cluster-keyed domains; "group these into domains", "build the requirements graph", "translate clusters into a domain model". NOT for mining the rules themselves (that is domain-extractor) or threat-modeling (that is domain-coverage).
tools
Rule-extraction fork worker for the FOUNDATIONAL domain-model capability. Mines testable business rules from a codebase — each with a numeric confidence and a provenance{source, ref, source_kinds} — and annotates them into the estate store so wicked-core can build the domain-model requirements graph (coverage-gated). This is a substrate, not a modernization tool: the `modernize` archetype DERIVES from it, and build / migrate / review / specify / explore can consume the same domain model — none OWN it. Use when: dispatched by wicked-garden-domain to mine the business_rules of a codebase (or a module); "extract the domain rules", "what does this system require", building the requirements half of a domain model. NOT for grouping into domains (that is domain-modeler) or judging coverage (that is domain-coverage — a seat-distinct evaluator).