vercel/workflow/migrating-workflow-v4-to-v5

Claude Code and agent skill by vercel/workflow

Trust tier 4
  • vendor
Source check pending

Checking that the SKILL.md file is still in the repository.

Upgrades an app from Workflow SDK 4.x to 5.0. Use when bumping the `workflow` / `@workflow/*` dependencies to v5, or when hitting removed v4 APIs — `runStep`, `stepEntrypoint`, `workflow/internal/private`, `@workflow/core/private`, `writeToStream` / `closeStream` / `readFromStream` on a World, `world.steps.get` without a runId, `hook.getConflict()` returning `{ runId }`, `hook.metadata` read synchronously off a `getHookByToken()` result, `experimental_setAttributes`, `createLocalWorld` / `creat…

Install

npx vskill@latest install vercel/workflow/migrating-workflow-v4-to-v5

SKILL.md

The same SKILL.md was published earlier as vercel/workflow/migrating-workflow-v4-to-v5.

Migrating Workflow SDK 4.x to 5.0

Workflow SDK 5.0 keeps the programming model from 4.x. "use workflow" / "use step", start(), getRun(), hooks, webhooks, streams, sleep(), retries, and the event log are unchanged, so most application code compiles as-is.

The breaking changes are concentrated in three places:

  1. Runtime entrypoints (workflow/api, workflow/runtime) — two exports removed.
  2. The `World` interface — only relevant if the app implements a custom World or calls getWorld() directly.
  3. Build integrations — @workflow/nest subpaths, and private compiler subpaths that were never public.

Do not rewrite workflow or step bodies. If you find yourself restructuring business logic, you have gone outside this migration.

Intake

Before editing, establish:

  1. Which packages are installed. Read package.json for workflow and every @workflow/* dependency.
  2. Whether the app touches the runtime. Grep for getWorld, createWorld, getWorldHandlers, writeToStream, readFromStream, closeStream, listStreamsByRunId, getStreamChunks, world.steps, listByCorrelationId, runStep, stepEntrypoint, internal/private, core/private.
  3. Whether the app implements a custom World. Grep for implements World, : World, createLocalWorld, createVercelWorld, startWorkflowWorld.
  4. Which framework integration is in use. @workflow/next, @workflow/nest, @workflow/nitro, @workflow/sveltekit, @workflow/vite, @workflow/nuxt, @workflow/astro, or the CLI.
  5. Whether `hook.getConflict()` is used. Grep for getConflict.
  6. Whether hook metadata is read outside a workflow. Grep for getHookByToken and resumeHook, then for .metadata on their results.
  7. Whether the app calls the compiler directly. Grep for mode: 'client', transformSync, swc-plugin-workflow. Only custom build integrations do this.
  8. Whether `experimental_setAttributes` is used. Grep for experimental_setAttributes.

Report anything in 2–8 that the app does not use as "not applicable" rather than silently skipping it.

Step 1 — bump the dependencies

Move every workflow and @workflow/* dependency to ^5.0.0. They are released together and must not be mixed across majors — a 4.x @workflow/next against a 5.x workflow will fail at build time.

json
{
"dependencies": {
"workflow": "^5.0.0",
"@workflow/next": "^5.0.0"
}
}

Then reinstall and rebuild so the compiler regenerates the workflow/step bundles and the generated routes under .well-known/workflow/v1/. Never hand-edit generated output.

Node requirements are unchanged: ^18 || ^20 || ^22 || ^24.

Step 2 — apply the mechanical rewrites

Apply each rule only where the pattern actually appears.

getWorld() and createWorld() are async
ts
// v4
const world = getWorld();
// v5
const world = await getWorld();

This also applies to getWorldHandlers(). Awaiting was already correct in 4.x, so this edit is safe to make before the dependency bump. Propagate async up the call chain rather than wrapping in .then() chains.

createLocalWorld() and createVercelWorld() removed

First-party World packages now expose a single createWorld() factory. The arguments are unchanged — this is a rename only.

ts
// v4
import { createLocalWorld } from '@workflow/world-local';
const world = createLocalWorld({ dataDir });
// v5
import { createWorld } from '@workflow/world-local';
const world = createWorld({ dataDir });

The same applies to createVercelWorld from @workflow/world-vercel.

runStep removed from workflow/api

Call the step function directly. The compiler routes the call through the step runtime.

ts
// v4
import { runStep } from 'workflow/api';
const result = await runStep(chargeCard, [orderId]);
// v5
const result = await chargeCard(orderId);
stepEntrypoint removed from workflow/runtime

Framework integrations generate step routes themselves — delete hand-written step routes that existed only to call stepEntrypoint. For a custom host, serve the handlers from getWorldHandlers() instead.

workflow/internal/private and @workflow/core/private removed

These subpaths were never public API. Remove the imports; if generated build output still references them, it is stale — reinstall and rebuild rather than restoring the imports.

Stream methods moved to world.streams.* with runId first
v4v5
world.writeToStream(name, runId, chunk)world.streams.write(runId, name, chunk)
world.writeToStreamMulti(name, runId, chunks)world.streams.writeMulti(runId, name, chunks)
world.closeStream(name, runId)world.streams.close(runId, name)
world.readFromStream(name, startIndex?)world.streams.get(runId, name, startIndex?)
world.getStreamChunks(name, runId, options?)world.streams.getChunks(runId, name, options?)
world.listStreamsByRunId(runId)world.streams.list(runId)

The argument order flipped, so a rename alone silently passes a stream name where a run ID is expected. Swap the arguments at every call site. readFromStream had no runId parameter at all — streams.get requires one, so thread the owning run ID through to the call.

Application code that uses getWritable() inside a workflow or reads run.readable is unaffected; this rule is only for direct World access.

world.steps.get() requires a runId

The first parameter was string | undefined and is now string. Pass the run ID that owns the step.

ts
// v4
const step = await world.steps.get(undefined, stepId);
// v5
const step = await world.steps.get(runId, stepId);
events.listByCorrelationId() requires a runId

A correlation ID identifies a step, hook or wait within its run, not across runs. The lookup is scoped to one run, so pass the run that owns the ID.

analytics.events.listByCorrelationId() took the same runId, and is deprecated on top of it: with a runId required it is a special case of analytics.events.list({ runId, correlationId }), and it goes away in the next major. Add the runId for now and move the call to list while you are in the file. The storage events.listByCorrelationId() is not deprecated.

ts
// v4
const events = await world.events.listByCorrelationId({ correlationId });
// v5
const events = await world.events.listByCorrelationId({ runId, correlationId });
hook.getConflict() resolves with a Run

The resolved value is now the conflicting run handle rather than { runId }. conflict.runId still reads the same, so existing code keeps working — but the round trip through a step to fetch the run can be deleted.

ts
// v4
const conflict = await hook.getConflict();
if (conflict) {
const run = await fetchRun(conflict.runId); // "use step" wrapper around getRun()
return { dedupedTo: await run.returnValue };
}
// v5
const conflict = await hook.getConflict();
if (conflict) {
return { dedupedTo: await conflict.returnValue };
}

await conflict.status and await conflict.cancel() are available on the same handle. Do not remove the if (conflict) null check — getConflict() still resolves null when the token was claimed cleanly.

hook.metadata is a Promise

On the hook returned by getHookByToken() and resumeHook(), metadata is now a getter that returns a memoized Promise, the same shape as run.returnValue. Looking a hook up by token is a single read; hydrating the metadata can add network round trips, and those are paid only by code that awaits it.

ts
// v4
const hook = await getHookByToken(token);
if (hook.metadata?.allowedUserId !== userId) {
return new Response('Forbidden', { status: 403 });
}
// v5
const hook = await getHookByToken(token);
const metadata = (await hook.metadata) as { allowedUserId?: string } | undefined;
if (metadata?.allowedUserId !== userId) {
return new Response('Forbidden', { status: 403 });
}

Awaiting it on a hook that stored no metadata resolves undefined with no I/O, so the await needs no guard. { ...hook } and JSON.stringify(hook) no longer carry metadata, so a handler that forwarded the whole hook object must forward the awaited value explicitly. hook.runId, hook.token, and the other fields are unchanged, and world.hooks.getByToken() still returns the raw Hook record. Under TypeScript the old shape fails the build; in plain JavaScript hook.metadata.allowedUserId reads undefined off a Promise, so a check like the one above silently rejects every request.

experimental_setAttributes renamed to setAttributes
ts
// v4
import { experimental_setAttributes } from 'workflow';
// v5
import { setAttributes } from 'workflow';

The old name was removed in v5, so this rewrite is required. ExperimentalSetAttributesOptions is likewise now SetAttributesOptions. The attributes option on start() is unchanged.

mode: 'client' removed from the SWC transform

Only relevant to a custom build integration that calls the compiler itself. The client mode merged into step, which now absorbs hoisted variable references and dead-code elimination. Pass mode: 'step'.

NestLocalBuilder moved out of the @workflow/nest root
ts
// v4
import { NestLocalBuilder } from '@workflow/nest';
// v5
import { NestLocalBuilder } from 'workflow/nest/builder';

NestVercelBuilder lives at workflow/nest/vercel-builder. WorkflowModule still comes from @workflow/nest; the split keeps the build toolchain out of the runtime bundle, so do not re-export the builder from a module that runtime code imports.

Step 3 — flag the behavior changes that need a decision

These are not code edits. Report each one that applies, and do not "fix" them silently.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 24 Nov 2026.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
2,412
Repository forks
361
7-day trend score
39

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill CERTIFIED badge
[![vskill CERTIFIED](https://verified-skill.com/api/v1/skills/vercel/workflow/migrating-workflow-v4-to-v5/badge)](https://verified-skill.com/skills/vercel/workflow/migrating-workflow-v4-to-v5)

Something wrong with this skill or its page? Tell us.