mastra-migrations
Skill2 starsChanged 29 days agoApache-2.0View on GitHub
Upgrade Mastra projects safely: the 0.x to v1 migration (subpath imports, createTool execute signature, RequestContext, list-style APIs, memory defaults and the memory option, storage pagination and schema migrations, Observability exporters, CLI changes), the @mastra/codemod codemods, and the targeted guides for VNext to standard APIs, AI SDK v4 to v5, AgentNetwork and .network() to supervisor agents, @mastra/mcp v1 to v2, and Mastra Cloud to Mastra Platform. Use this skill whenever the user bumps @mastra/core, sees breaking changes after npm update, asks what changed between versions, wants to run codemods, or must move off a deprecated API. Triggers on upgrade Mastra, migrate to v1, npx @mastra/codemod, breaking changes, RuntimeContext to RequestContext, getAgents to listAgents, createRunAsync, generateVNext, streamVNext, generateLegacy, telemetry to observability, CloudExporter, DefaultExporter, mastra migrate, .network() deprecated, Mastra Cloud migration, mcp v2.
- Installs packages
In this repository46 other files it gives its agents.
- mastra-a2a-acpSkill
- mastra-agent-approval-hitlSkill
- mastra-agentic-uiSkill
- mastra-agent-skillsSkill
- mastra-agentsSkill
- mastra-authSkill
- mastra-browserSkill
- mastra-build-playbookSkill
- mastra-channelsSkill
- mastra-classifierSkill
- mastra-cli-apiSkill
- mastra-client-sdkSkill
- mastra-datasets-experimentsSkill
- mastra-deploymentSkill
- mastra-evalsSkill
- mastra-file-based-agentsSkill
- mastra-framework-integrationSkill
- mastra-guideSkill
- mastra-harnessSkill
- mastra-knowledgeSkill
- mastra-mcpSkill
- mastra-memorySkill
- mastra-modelsSkill
- mastra-multi-agentSkill
- mastra-observabilitySkill
- mastra-observational-memorySkill
- mastra-platformSkill
- mastra-processors-guardrailsSkill
- mastra-project-setupSkill
- mastra-ragSkill
- mastra-schedulesSkill
- mastra-semantic-recallSkill
- mastra-serverSkill
- mastra-signalsSkill
- mastra-storageSkill
- mastra-streamingSkill
- mastra-structured-outputSkill
- mastra-studio-editorSkill
- mastra-tool-integrationsSkill
- mastra-toolsSkill
- mastra-troubleshootingSkill
- mastra-vector-storesSkill
- mastra-voiceSkill
- mastra-workflowsSkill
- mastra-workflow-suspend-resumeSkill
- mastra-workspace-sandboxSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 53
All packages move together: Every @mastra/* package and mastra go to latest in one change.
- Very specific: line 88
Verify the API: If node_modules/@mastra/ exists, read node_modules/@mastra/core/dist/docs/ for the installed version.
- Very specific: line 89
Baseline: Commit, record versions, run npx tsc --noEmit and tests.
- Very specific: line 91
Update packages together: Use @latest for every Mastra package.
- Very specific: line 95
Migrate data: Run the SQL for scorer columns and JSONB if applicable, and npx mastra migrate for duplicate spans.
- Very specific: line 125
Scorer request context data missing: Run the runtimeContext to requestContext column SQL.
- Very specific: line 128
mastra dev --portormastra build --envrejected: Use server.port and mastra start --env.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Mastra Migrations
Move a Mastra project from an older version or deprecated API to the current one, using official guides and codemods, without breaking runtime behavior.
When to use
- Upgrading a project from Mastra 0.x to v1
- Bumping
@mastra/*minor versions and hitting renamed or removed APIs - Running
@mastra/codemodtransforms - Moving from
generateVNext/streamVNextor legacy AI SDK v4 models - Replacing
AgentNetworkor.network()with supervisor agents - Upgrading
@mastra/mcpfrom 1.x to 2.x - Moving from Mastra Cloud to Mastra Platform
- Running storage schema migrations after an upgrade
When NOT to use
- A single error with an unknown cause (use
mastra-troubleshooting) - Deploying after the upgrade (use
mastra-deploymentormastra-platform) - Writing new agents, tools, or workflows on the current API (use
mastra-agents,mastra-tools,mastra-workflows) - Supervisor agent design beyond the migration steps (use
mastra-multi-agent) - MCP server and client usage on v2 (use
mastra-mcp) - Configuring observability exporters in depth (use
mastra-observability)
Required inputs
- Current versions:
npm list @mastra/core mastraand every@mastra/*package - Target version (default: latest v1)
- Package manager and repo layout (monorepos must update every package together)
- Storage backend in use (PostgreSQL and LibSQL need database steps)
- Whether the project used
telemetry:, Mastra Cloud,.network(), or@mastra/mcp - A clean git state and a passing test baseline
The framework: upgrade in one pass, verify in layers
- All packages move together. Every
@mastra/*package andmastrago tolatestin one change. - Codemods first, hand edits second. Codemods handle mechanical renames. The guide pages cover behavior changes codemods cannot.
- Behavior changes need explicit config. v1 changed defaults (memory scope,
lastMessages, semantic recall, title generation, input validation). Restore old behavior on purpose, not by accident. - Data migrations are separate. SQL or
mastra migratesteps run against the database. - Observability must migrate in the same change. v1 ignores
telemetry:silently, so traces stop with no error.
npm install @mastra/core@latest @mastra/loggers@latest @mastra/memory@latest mastra@latest
npx @mastra/codemod@latest v1Node.js 22.13.0 or later is required for v1. Update to the latest 0.x before jumping to v1.
The highest-impact v1 change, the tool signature:
createTool({
id: 'weather-tool',
- execute: async ({ context, requestContext, mastra }) => {
- const location = context.location;
- const userTier = requestContext.get('userTier');
- return getWeather(location, userTier);
- },
+ execute: async (inputData, context) => {
+ const location = inputData.location;
+ const userTier = context?.requestContext?.get('userTier');
+ return getWeather(location, userTier);
+ },
});Workflow
- Verify the API. If
node_modules/@mastra/exists, readnode_modules/@mastra/core/dist/docs/for the installed version. Fetchhttps://mastra.ai/reference/migrations/upgrade-to-v1/overview.mdand the area pages you need, and the package changelog (https://github.com/mastra-ai/mastra/blob/main/packages/core/CHANGELOG.md) for minor bumps. Trust these over memory. - Baseline. Commit, record versions, run
npx tsc --noEmitand tests. Back up the database. - Inventory usage. Grep for the APIs in
references/v1-changes.md(RuntimeContext,getAgents,createRunAsync,telemetry:,threadId:,offset,generateVNext,.network(,@mastra/speech-). - Update packages together. Use
@latestfor every Mastra package. Update Node if needed. - Run codemods.
npx @mastra/codemod@latest v1for everything, or one transform at a time (npx @mastra/codemod@latest v1/runtime-context .). Review the diff. - Apply hand edits. Work the checklist in order: high impact (tools, imports, pagination, observability), medium, low.
- Decide on behavior defaults. Set memory
scope,lastMessages,semanticRecall,generateTitleexplicitly if the app relied on 0.x defaults. - Migrate data. Run the SQL for scorer columns and JSONB if applicable, and
npx mastra migratefor duplicate spans. - Verify.
npx tsc --noEmit, tests,mastra dev, a Studio run of each agent and workflow, and traces visible in Studio or the platform. - Update deploy commands. Replace
mastra server deployandmastra studio deploywithmastra deploy(seemastra-platform).
Deep dive: other migration guides
| Guide | From | To | Key moves |
vnext-to-standard-apis | generateVNext/streamVNext (0.20) | generate/stream | Old generate/stream became generateLegacy/streamLegacy for AI SDK v4 models; standard methods need v5 models |
ai-sdk-v4-to-v5 | AI SDK v4 | AI SDK v5 | No DB migration; stored messages convert on the fly. Use convertMessages(...).to('AIV5.UI'). Keep backups, v5 data does not downgrade |
agentnetwork | AgentNetwork | Agent with agents and memory | Memory is required |
network-to-supervisor | .network() (deprecated) | stream()/generate() with maxSteps | Clear supervisor instructions, subagent descriptions, delegation hooks |
mcp-v2 | @mastra/mcp 1.x | 2.x (MCP 2026-07-28 only) | Needs @mastra/core 1.76+. Elicitation becomes suspend()/resumeData. SSE transport removed. Stay on 1.x to serve pre-2026 clients |
mastra-cloud | Mastra Cloud | Mastra Platform | New tokens (mastra auth tokens create), export Cloud Store, observability: with MastraPlatformExporter, then deploy |
Details and code are in references/other-guides.md.
Failure patterns
- Upgrading one package at a time. Peer mismatches cause type and runtime errors. Bump all Mastra packages in one change.
- Skipping the latest 0.x. Jumping straight to v1 hides intermediate deprecations. Update to latest 0.x first.
- Traces vanish after upgrade, no error.
telemetry:is ignored. Install@mastra/observabilityand configureobservability: new Observability({...}). - Agent now remembers across conversations. Memory scope default changed to
resource. Setscope: 'thread'if needed. - Only 10 messages of history.
lastMessagesdefault dropped from 40 to 10. - History lost entirely.
threadId/resourceIdcall options were removed. Usememory: { thread, resource }. - Storage init fails on a unique constraint. Duplicate spans. Run
npx mastra migrate. - Scorer request context data missing. Run the
runtimeContexttorequestContextcolumn SQL. Tool output validation failed. v1 validatesoutputSchema. Fix outputs or setoutputValidation: 'warn'.- Workflow start rejects input. Inputs validate by default now.
mastra dev --portormastra build --envrejected. Useserver.portandmastra start --env.- Codemod run on uncommitted work. Hard to review. Commit first, run one transform per commit for large repos.
- Old docs for
format: 'aisdk'. Theformatparameter was removed in v1. - Platform deploy fails with
MASTRA_CORE_TOO_OLD. The environment pipeline needs@mastra/core >= 1.44.
Output format
A finished migration delivery contains:
- Version table: before and after for every Mastra package, plus Node
- The codemods run and the hand edits made, grouped by area
- Explicit config for any v1 default the app depended on
- Database steps run (SQL or
mastra migrate) and their result - Verification:
tsc --noEmit, tests, a Studio run, traces visible - Remaining warnings or deprecations to address later
Reference files
references/api.md- Codemod catalog, upgrade commands, rename map by area.references/v1-changes.md- v1 breaking changes by area with before and after code.references/other-guides.md- VNext, AI SDK v5, supervisor agents, MCP v2, Mastra Cloud.references/examples.md- Full v1 upgrade run, observability migration, memory defaults,.network()to supervisor.references/checklist.md- Pre- and post-migration checklist.
Live docs
- https://mastra.ai/reference/migrations/upgrade-to-v1/overview
- https://mastra.ai/reference/migrations/upgrade-to-v1/tools
- https://mastra.ai/reference/migrations/upgrade-to-v1/memory
- https://mastra.ai/reference/migrations/upgrade-to-v1/storage
- https://mastra.ai/reference/migrations/upgrade-to-v1/tracing
- https://mastra.ai/reference/migrations/vnext-to-standard-apis
- https://mastra.ai/reference/migrations/ai-sdk-v4-to-v5
- https://mastra.ai/reference/migrations/network-to-supervisor
- https://mastra.ai/reference/migrations/mcp-v2
- https://mastra.ai/reference/migrations/mastra-cloud
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

