This skill helps migrate Express or Fastify apps to Encore.ts by converting routes, requests, and middleware into Encore API patterns.
npx playbooks add skill encoredev/skills --skill migrate
This skill guides migrating any existing backend application to Encore, one migration unit at a time. It supports any source language or framework and targets both Encore.ts and Encore Go. A migration-plan.md summary file and migration-plan/ directory of per-unit detail files are created at the Encore project root to track progress across sessions. This skill contains no Encore code examples — it delegates all Encore-specific implementation to the appropriate language-specific skills.
Before doing anything, determine which phase to enter:
migration-plan.md exists in the Encore project directory → Start at Phase 1: DISCOVERmigration-plan.md exists but no migration-plan/ directory → Resume at Phase 2: PLAN (discovery done, detail files not yet written)migration-plan/ directory exists with pending units (any unit in the summary with status pending or in progress) → Resume at Phase 3: MIGRATEmigrated, skipped, or manual validation needed → Go to Phase 4: COMPLETEThe confirmation stops in this workflow (confirming units in Phase 1, approving the first unit in Phase 2, picking each next unit in Phase 3) are the default. If the user asks to run the migration through without stopping ("just migrate it", "do them all", "don't ask"), skip those stops:
## Decisions section of migration-plan.md so it can be revisitedmigratedWhen migration-plan.md and migration-plan/ exist with pending units:
migration-plan.md (summary only — do NOT read all detail files)Ask the user for:
Read the source codebase and inventory all entities:
| Category | What to look for |
|----------|-----------------|
| Services / modules / domains | Distinct bounded contexts, separate deployable units, route groupings |
| API endpoints | Method, path, handler function, request/response shapes |
| Databases | Type (Postgres, MySQL, etc.), tables, schemas, migration files |
| Pub/Sub topics and subscriptions | Topic names, publishers, subscribers, message shapes |
| Cron jobs / scheduled tasks | Schedule expressions, handler functions |
| Auth middleware / handlers | Authentication strategies, token validation, session management |
| Secrets / environment variables | All referenced env vars and secrets, noting which are sensitive |
| Global HTTP behavior | CORS settings, global path prefixes, global middleware, custom error filters / error response bodies |
| Existing tests | Test files, which entities they cover, test framework used |
| Frontend code | React/Vue/Angular components, static HTML, CSS, client-side JS — these are out of scope |
Full-stack repos and monorepos often mix backend and frontend code. The migration targets backend only — frontend code is out of scope.
Detect frontend directories and mark them as out of scope. Common indicators:
| Pattern | Examples |
|---------|----------|
| Dedicated frontend directories | frontend/, client/, web/, app/ (when it contains React/Vue/Angular), src/components/, public/ |
| Frontend config files | next.config.js, vite.config.ts, nuxt.config.ts, angular.json, .svelte-kit/, remix.config.js |
| Package dependencies | react, vue, @angular/core, svelte in package.json |
**Flag framework server-side code that should be migrated.** Some frontend frameworks embed backend logic that contains API endpoints, database queries, or server-side business logic:
| Framework | Server-side locations | What to look for |
|-----------|----------------------|-----------------|
| Next.js | pages/api/, app/*/route.ts | API route handlers — these are backend endpoints |
| Remix | app/routes/*.tsx (loader/action exports) | loader and action functions contain server logic |
| Nuxt | server/api/, server/routes/ | Server API routes |
| SvelteKit | src/routes/+server.ts, +page.server.ts | Server endpoints and load functions |
| Astro | src/pages/*.ts (non-.astro) | API endpoints |
When framework server-side code is found, ask the user what to do with it. Not all server-side code should move to Encore — sometimes a thin backend layer (BFF, auth proxy, SSR data fetching) should stay in the frontend framework alongside an Encore backend.
Present the user with what was found and ask:
> "I found <N> server-side routes in your <framework> app (e.g., pages/api/users.ts, app/billing/route.ts). These contain backend logic that could be migrated to Encore, but some teams prefer to keep a thin server layer in their frontend framework for things like SSR data fetching or BFF proxying. Would you like to:
> 1. Migrate all server-side routes to Encore
> 2. Migrate some — I'll list them and you pick which ones move
> 3. Keep all in <framework> — only migrate the standalone backend code"
Based on the user's choice:
Report to the user: List all detected frontend directories and the decision made about framework server-side code. Example: "I found a Next.js frontend in app/ — the React components are out of scope. You chose to migrate 8 of the 12 API routes from pages/api/ to Encore and keep 4 thin proxy routes in Next.js."
Some choices affect every unit. Surface them before planning, and record the answers in the ## Decisions section of migration-plan.md:
api() endpoints always return errors as {code, message, details}, and request validation failures are always HTTP 400. If clients depend on a different error body (e.g. {"errors": {...}}) or status (e.g. 422), the options are: accept Encore's format (field errors can go in details), or use api.raw for the affected routes, which gives up typed requests and generated clients. Ask which the user prefers.global_cors in encore.app rather than leaving it to Encore's defaults.Group the discovered entities into migration units using these heuristics in priority order:
/users/, /billing/)Chunk sizing: Aim for 5-15 endpoints per migration unit. If a group exceeds ~15 endpoints, suggest splitting it further (e.g., users-crud and users-admin). If a group has fewer than 3 endpoints, consider merging it with a related chunk.
Cross-cutting concerns get their own migration units: auth, secrets, and standalone infrastructure (pub/sub topics, cron jobs not tightly coupled to one service) are separate units since they follow different dependency tiers.
For monoliths with no clear boundaries: Fall back to URL path prefix grouping, then ask: "These groupings are based on URL paths — would you like to reorganize them by domain?"
Present the migration units to the user as a summary table:
| Unit | Endpoints | DB Tables | Other | Complexity |
|------|-----------|-----------|-------|------------|
Include total counts (e.g., "7 migration units covering 42 endpoints, 3 databases"). For each unit, assess overall migration complexity:
Offer to show the detail of any unit if the user wants to inspect what's inside before confirming.
For 2-3 representative entities (pick a mix of simple and complex from different units), show a short "before and after" preview of what the source code looks like now and what the Encore version will look like. Use the appropriate language-specific skill to inform the preview. Keep previews brief — one endpoint, one query, or one topic declaration is enough per preview.
Ask the user to confirm the migration units are correct. Specifically ask:
If the user identifies missing entities or wants to adjust chunk boundaries, update the units and re-present the summary table. Repeat until the user confirms the migration units are accurate.
Check if an Encore project already exists at the target path (look for encore.app file). If yes, confirm with the user that this is the correct project. If no, help create one by invoking the encore-getting-started skill (or encore-go-getting-started for Go).
Ask the user for:
http://localhost:4000)Order migration units based on dependencies. Follow this tier order:
Within each tier, suggest the simplest unit first (fewest endpoints, smallest schema, least complexity).
Write the migration-plan.md summary file to the Encore project root using the template in the "migration-plan.md Format" section below. Fill in all migration units with status pending.
Create a migration-plan/ directory at the Encore project root. Write one detail file per migration unit using the template in the "Detail File Format" section below. Each file is named migration-plan/<unit-name>.md.
Propose the first migration unit, explaining why it should go first based on the dependency order. Wait for user approval before proceeding to Phase 3.
Read migration-plan.md (summary only) and identify the next pending migration unit based on the dependency order.
Suggest the next unit to migrate and explain why this one is next (e.g., "This unit has no dependencies on unmigrated units" or "The database must exist before we can migrate the service that uses it"). Ask the user if they want to proceed with this unit or pick a different one.
Read the detail file for the chosen unit (migration-plan/<unit-name>.md). Do NOT read detail files for other units.
For each entity in the unit:
Invoke the appropriate language-specific skill based on the entity type and target language:
| Migrating... | Encore.ts skill | Encore Go skill |
|---|---|---|
| Service structure | encore-service | encore-go-service |
| API endpoints | encore-api | encore-go-api |
| Auth | encore-auth | encore-go-auth |
| Database + migrations | encore-database | encore-go-database |
| Pub/Sub topics & subscriptions | encore-pubsub | encore-go-pubsub |
| Cron jobs / scheduled tasks | encore-cron | encore-go-cron |
| Object storage / file uploads | encore-bucket | encore-go-bucket |
| Caching (Redis) | encore-cache | encore-go-cache |
| Secrets / API keys / credentials | encore-secret | encore-go-secret |
| Webhooks (Stripe, GitHub, etc.) | encore-webhook | encore-go-webhook |
| Tests | encore-testing | encore-go-testing |
If the source entity has associated tests, migrate them using the appropriate testing skill (encore-testing or encore-go-testing). Adapt test assertions to match Encore API patterns. If the source entity has no tests, note this in the detail file.
Three validation layers are applied to each entity before it can be marked as migrated. Every entity must go through all applicable layers.
encore-testing skill (or encore-go-testing for Go) to implement the testsmigratedWhen both systems are running locally, call the same endpoint on both the source system and the Encore app, then compare:
Skip this layer when:
If a request to either system fails to connect, ask the user to start the app before retrying. Do not silently skip — the user may have simply forgotten to start it.
Always ask the user before making any HTTP call that could have side effects.
If the source system cannot practically be run (unavailable database engine, toolchain too old to install, external dependencies), or the behavior target intentionally diverges from the source, HTTP comparison against the source is not meaningful. If the API has an external contract test suite (Hurl, Postman/Newman, Bruno, Schemathesis against an OpenAPI spec, a consumer's integration tests), run it against the Encore app instead:
hurl --test --continue-on-error --report-json) so every failing assertion is visible, not only the first per fileNote in the plan why HTTP comparison against the source was skipped.
Before marking ANY entity as migrated, the agent MUST have fresh evidence from the current session:
Rules:
manual validation needed, not migratedUpdate the entity's status in the unit's detail file (migration-plan/<unit-name>.md) and record validation evidence in that file's Validation Log table.
When all entities in a unit are complete, update the unit's status in migration-plan.md to migrated. If some entities are pending, set the unit status to in progress.
After completing a unit, ask "What would you like to migrate next?" and suggest the next unit based on dependency order.
The default is one unit at a time. If the user says "keep going", "do them all", or similar, batch multiple units but still validate each entity individually before marking it as migrated.
When all units in migration-plan.md are migrated, skipped, or manual validation needed:
migration-plan.md:manual validation needed — read those specific detail files and list the entities that need attention with reasonsencore-frontend skill to reconnect the frontend to the new Encore backend (generate a typed API client, configure CORS, update base URLs)migration-plan.md and migration-plan/ from the project once the user is satisfied with the migrationAsk the user before acting when:
The source system must never be modified during migration. Follow these rules:
-
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.