Tenant migration playbook (orchestrator)
Drive a full Movemental tenant migration from Stitch wireframes to a production, Supabase-backed tenant site. This skill is the hub — it never hardcodes a tenant; it reads the manifest and delegates each phase to a discrete sub-skill.
Run it for: $ARGUMENTS — typically a phase/slice scope, e.g. homepage,
content cluster, backend, full, or a tenant slug to migrate.
This skill is self-contained and portable — the full tenant-agnostic process
(runbook, master playbook, route index, and the manifest / checklist templates) ships
inside this skill under references/stitch-migration/. It can bootstrap the process
into any project that doesn't have it yet.
Step 0 — Locate or bootstrap the process docs
The process lives in the target repo at docs/build/stitch-migration/ (older
repos may use docs/build/prompts/stitch-migration/ — accept either; prefer the
former). Glob both before deciding it's missing.
If the doc set already exists, use it as-is.
If it's missing (a fresh project), scaffold it from this skill's bundled copy:
- Copy
references/stitch-migration/*→ the target repo'sdocs/build/stitch-migration/. (Use the skill's own directory as the base — the bundle travels with the skill/plugin, so it works in any project.) - Fork the two templates in place:
TENANT_MANIFEST.template.md→TENANT_MANIFEST.mdCOMPONENT_CHECKLIST.template.md→COMPONENT_CHECKLIST.md
- Fill every
{{VAR}}inTENANT_MANIFEST.mdfrom the target tenant (slug, org id, design theme, reference repos, pathways, feature flags, leak grep patterns). If a value is unknown, ask the user — never invent a tenant value.
Step 0.5 — Load the tenant contract (mandatory)
Read, in the target repo (under whichever stitch-migration/ directory resolved above):
TENANT_MANIFEST.md— the source of every{{VAR}}(tenant slug, org id, design theme, reference repos, pathways, feature flags, leak grep patterns, branch naming). Never substitute a tenant value that isn't in the manifest.MASTER_PLAYBOOK.md— phase pipeline.COMPONENT_CHECKLIST.md— living route → status matrix.
If a value the prompts call {{REFERENCE_REPO}} / {{STITCH_PROMPTS_HTML}} resolves
to a sibling repo path, confirm the path exists before relying on it.
Pipeline (delegate, don't reimplement)
Phase A Stitch generation (human + Stitch — not automated here)
Phase B Frontend: Stitch → React (00–10)
Phase C Backend: type-safety + tenant parity (11–16)
Phase D Optional structural code port from the reference repo
| Phase / step | Delegate to skill | Outcome |
|---|---|---|
| Charter + scope | this skill (Step 1) | Branch, scope, manifest read confirmed |
| 01 Intake + gap audit | stitch-intake-audit |
Cached screens, screen↔route map, gap report |
| 02 Token bridge | stitch-token-bridge |
Wireframe grayscale → tenant semantic tokens |
| 03–09 Chrome + page clusters | stitch-page-port |
L4 sections + L5 pages per route cluster |
| 10 UI validation gate | stitch-migration-validate |
Build/leak/token gates, checklist update |
| 11–16 Backend parity | tenant-backend-parity |
Org identity, six-layer chain, config alignment |
| Deep code parity (optional) | tenant-structural-port |
Course player / route normalization from reference |
For the per-screen HTML→React conversion mechanics inside stitch-page-port, the
underlying primitive is the existing stitch-react skill. Backend phases lean on
tenant-migrate, type-safety-chain, tenant-check, and validate.
Step 1 — Charter and guardrails (run before any code)
Emit, before writing code:
- Branch name from the manifest convention —
slice/Sxx-stitch-<topic>,slice/Sxx-backend-<topic>, orslice/Sxx-migration-<topic>. Never commit tomain. - Stitch screen id(s) / cached
.stitch/designs/paths in scope. - Routes and layers touched, and which numbered prompts (01–16) the slice covers.
- Blockers: missing Stitch screens, MCP auth, zero DB content for an enabled feature.
Non-negotiables (enforce in every delegated phase):
- Types flow downstream only: schema → zod → services → routes → hooks → UI. Never modify Drizzle schema for UI convenience.
- Never hand-edit generated
simplified/files — fix the generator and rerun. - No tenant strings in components; use
tenantConfig/useTenant(). - Don't restyle
src/components/ui/*; fix L1 tokens or L4 section classes. - Never add
"use client"tosrc/app/layout.tsx. - Archive existing
page.tsx→page-old.tsxbefore replacing (stitch-react Archive Protocol). pnpmonly. Never shipdangerouslySetInnerHTMLdumps or raw wireframe hex (#111/#666).- Incomplete template policy: if a Stitch screen omits a required section,
synthesize it from the reference repo's structure + tenant tokens + manifest copy
slots. Never leave IA holes; mark the row
PARTIALwith aStitch gap:note.
Wait for confirmation if a slice touches >12 new component files or needs new API routes.
Step 2 — Sequence the slice
Use TodoWrite to track the slice. Typical orders:
- New tenant, full run: intake → token-bridge → page-port (chrome → home → clusters) → validate → backend-parity → validate. Structural-port only if validate flags hook/data gaps.
- Single cluster (e.g. courses): page-port (that cluster) → validate; add backend-parity if the cluster needs live data.
- Backend-only slice: backend-parity → validate.
Run phases as discrete delegated steps; after each, update COMPONENT_CHECKLIST.md
and REFERENCE_PAGE_COMPARISON.md. For large fan-out (many independent routes), each
route conversion can run as its own stitch-page-port invocation.
Definition of "migration complete"
| Layer | Criterion |
|---|---|
| IA | All in-scope routes match L5 section order + checklist |
| UI | No PlaceholderPage, no dangerouslySetInnerHTML, semantic tokens only |
| Types | pnpm validate:all green |
| Tenant | pnpm verify:tenant-org green; no source-tenant leaks in src/ |
| Features | features.* matches org content counts in Supabase |
| Docs | REFERENCE_PAGE_COMPARISON.md + checklist updated |
Related skills
stitch-intake-audit · stitch-token-bridge · stitch-page-port ·
stitch-migration-validate · tenant-backend-parity · tenant-structural-port ·
stitch-react · tenant-migrate · tenant-check · type-safety-chain · validate
Install into another project (Claude plugin)
This skill and its six phase sub-skills ship as the movemental-tenant-migration
plugin, defined in my-skills/.claude-plugin/marketplace.json. To run the process in a
project that doesn't already have the skills:
/plugin marketplace add /home/josh/dev/01-Movemental-Core/my-skills
/plugin install movemental-tenant-migration
Then invoke tenant-migration-playbook; Step 0 bootstraps the process docs from the
bundled references/stitch-migration/ into the target repo.
External conversion primitives (stitch-react, tenant-migrate) are not bundled —
they resolve from the manifest paths {{STITCH_REACT_SKILL}} / {{TENANT_MIGRATE_SKILL}}
(typically a sibling reference repo). Confirm those paths exist during Step 0.5.