moderator-page-migration

Migrate moderator pages from Next.js tRPC and Prisma to SvelteKit loads and Kysely.

7.2k|734|Updated Oct 11, 2022
One-click install
npx skills add https://github.com/civitai/civitai --skill moderator-page-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moderator-page-migration
Source: https://github.com/civitai/civitai/tree/main/.claude/skills/moderator-page-migration
Command: npx skills add https://github.com/civitai/civitai --skill moderator-page-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Porting a moderator page from the main Next.js app into the apps/moderator SvelteKit spoke is error-prone: child components hide extra tRPC mutations, mutations fan out to side effects like notifications and cache busts, and partial cutovers leave two disagreeing tools live. This Skill provides a structured process to inventory, port, cut over, and verify a complete page migration.

Core Features & Use Cases

  • Full slice inventory: Enumerates every procedure, child-component mutation, service function, and side effect a page touches before any code is written.
  • Side-effect classification: Buckets each mutation effect as port, delegate, defer, or equivalent, with a parity checklist so nothing is silently dropped.
  • Prisma-to-Kysely mapping: Maps tRPC procedures to SvelteKit loads and form actions, with guidance on index-predicate matching, timestamp handling, and shared @civitai/* packages.
  • Cutover and cleanup: Deletes the legacy page, registers redirects in MIGRATED_ROUTES, trims orphaned procedures and services, and runs three Svelte review passes.
  • Use Case: When asked to move /moderator/images or any /moderator/* page into the spoke app, follow the checklist-driven workflow to reach full functional parity and remove the legacy page in one unit of work.

Quick Start

Migrate the /moderator/<page> page from the main Next.js app into apps/moderator, porting its tRPC procedures and Prisma services to SvelteKit loads and Kysely, then cut over the route and trim the orphaned code.

Frequently Asked Questions about moderator-page-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate a Next.js tRPC page to SvelteKit?

Inventory every procedure and child-component mutation the page reaches, classify each mutation's side effects, then map tRPC queries to +page.server.ts loads and mutations to form actions backed by Kysely services. Finish by deleting the legacy page, adding a redirect, and trimming orphaned code.

How do I convert Prisma queries to Kysely without breaking indexes?

Match the literal shape of the Prisma-generated WHERE clause, including casts, because partial indexes only match their exact predicate form. Check which index the original query hit before rewriting, and prefer Kysely's builder with raw SQL reserved for bitmask, jsonb, and LATERAL cases.

Why does my migrated page miss mutations the original page had?

Child components like context menus and confirm dialogs import tRPC directly, so grepping the page file finds none of them. Grep the entire component tree referenced by the page to enumerate every mutation before porting.

What side effects get lost when porting moderation mutations?

Main-app moderation writes often fan out to notifications, email, Buzz, ClickHouse, Redis busts, search-index enqueues, and session invalidation. Classify each effect as port, delegate, defer, or equivalent and record deferred items in the side-effect parity checklist.

Why does a new SvelteKit moderator page return access denied for moderators?

New pages have no AppPageAccess row, so only moderator:admin can open them until grants are assigned on /admin. The route must also be registered in NAVIGATION in $lib/server/access.ts, otherwise it is unreachable for everyone.

When should a side effect be delegated instead of ported?

Delegate effects a moderator would notice, such as notifications, to an internal main-app endpoint the spoke calls. Defer only effects whose absence is recoverable, like analytics, and record them with a severity in the checklist.