migrating-to-moc-2
БесплатноБез исполняемых скриптовНе проверенMove a Motoko project from moc 1 to moc 2 — toolchain bump, removed compiler flags, and the fix for every new error. Load when bumping the moc toolchain to a…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
Migrating to moc 2
moc 2 is a major release of the Motoko compiler. It changes four things:
- Persistence. Actors are persistent by default. Enhanced orthogonal persistence (EOP) is the only memory model and the incremental GC the only collector.
- Strictness. Warnings for code that traps or silently does not do what it says are now errors, and a pattern must fit the type it matches.
- Syntax. A few moc 1 forms no longer parse (
a ??b, a branch glued to its condition,flexible). Several lighter forms are new and optional. - Flags. Every flag of a removed feature is rejected as an unknown option.
Most projects need a handful of edits, and the compiler names each one. This skill maps every diagnostic to its fix. The upstream moc 1 → 2 migration guide has longer explanations, and the release notes list each change per release.
First: is any canister still on classical persistence?
moc 2 cannot build a canister on classical (32-bit) persistence, but it can upgrade one to EOP. A deployed canister is classical if it was built with --legacy-persistence, with a non-incremental GC flag (--copying-gc, --compacting-gc, --generational-gc), or with a moc older than 0.15, where classical was the default.
- Move it to EOP: compile that one upgrade with
--enhanced-orthogonal-persistenceand without--enhanced-migration. The move is irreversible; later upgrades need neither flag. Without the flag the upgrade traps ("Detected implicit upgrade from classical orthogonal persistence to enhanced orthogonal persistence"); with--enhanced-migrationit traps too ("Cannot upgrade from classical orthogonal persistence with --enhanced-migration"). - Keep it classical: stay on moc 1.
A canister that moved to EOP with a moc older than 1.5.0 can trap on a later upgrade with cannot upgrade from an actor using enhanced migration to an actor not using enhanced migration. Run that one upgrade with graph-copy stabilization; the upstream EOP migration path has the steps.
Every other canister already runs on EOP and needs no persistence work.
Checklist
- Build cleanly on the latest moc 1 first. The
.vals()(M0269) andpreupgrade/postupgrade(M0270) deprecations are identical in moc 2, so fix them before switching; on moc 2,mops check --fixrewrites.vals()to.values(). Fix every warning in the diagnostics table too — most become errors. - Bump the toolchain to the latest 2.x release:
mops toolchain use moc <version>(it rewrites[toolchain] mocinmops.toml), or wherever your build pins moc. - Delete the removed flags from
[moc].args,[build].args,[canisters.<name>].args,dfx.jsonand build scripts. - Run
mops checkand fix what it reports in this order, because earlier errors hide later ones:- syntax errors (
??, glued branches,flexible, record literals in block position); - errors that were warnings in moc 1;
- M0277, redundant
asyncon a function body; - M0142 and M0193 in libraries and actor classes;
- M0131, only if you built with
--legacy-actors.
- syntax errors (
- Check upgrade compatibility against the deployed version before upgrading a live canister:
mops check-stable, ormoc --stable-compatible old.most new.most. Removingpersistentandstablekeywords does not change the stable signature. - Optionally adopt the moc 2 forms — only once nothing builds this code with moc 1 anymore. See After the switch.
Removed flags
moc 2 exits with unknown option '<flag>' on each of these.
| Flag | Replacement |
|---|---|
--default-persistent-actors, --require-persistent-actors |
none needed: actors are persistent by default |
--legacy-actors |
mark every field that should reset on upgrade transient |
--legacy-persistence, --copying-gc, --compacting-gc, --generational-gc |
none: stay on moc 1 for classical canisters |
--incremental-gc, --rts-stack-pages, --skip-gc-deprecation-warning, --experimental-rtti |
none needed |
| `--experiment |
Установить migrating-to-moc-2 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл migrating-to-moc-2?
Move a Motoko project from moc 1 to moc 2 — toolchain bump, removed compiler flags, and the fix for every new error. Load when bumping the moc toolchain to a 2.x release, when code that built on moc 1 fails on moc 2, or when one codebase must compile with both.
Как установить скилл migrating-to-moc-2?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл migrating-to-moc-2 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic