当前位置: 首页 > Skill >

Modernize Move

Modernize Move

Modernize Move

检测并现代化过时的 Move V1 语法、模式和 API,升级至 Move V2+。适用于升级遗留合约、迁移到现代语法或转换...

1.0.0 2026.11.26 651
获取Skill文件查看使用说明
作 者:苏言 许可证: 更新时间:2026.11.26
本文目录展开

Skill: modernize-move

Detect and modernize outdated Move V1 syntax, patterns, and APIs to Move V2+. Preserves correctness through tiered transformations with test verification after each tier.

Essential Principles

Five non-negotiable rules for every modernization:

  1. Test safety net is mandatory WHY: Modernization must preserve behavior. No tests = no safety net. If no tests exist, invoke generate-tests skill first to create comprehensive tests before making any changes.

  2. Analyze before modifying WHY: The user must see exactly what will change and confirm the scope. Never surprise-edit code. Present the full analysis report and wait for confirmation.

  3. Tiered execution order WHY: Syntax changes (Tier 1) are zero-risk. API migrations (Tier 3) change semantics. Always apply safest changes first so riskier changes build on a clean, verified foundation.

  4. Verify after each tier WHY: If tests break, you know exactly which tier caused it. Revert that tier and investigate before proceeding. Never apply the next tier on a broken baseline.

  5. Preserve error code values WHY: Tests use #[expected_failure(abort_code = N)]. Changing numeric values breaks tests silently. When creating named constants, the numeric value MUST match the original literal.

When to Use This Skill

  • Upgrading Move V1 contracts to V2 syntax
  • Migrating public(friend) to package fun
  • Converting vector::borrow to index notation
  • Converting while loops with counters to for range loops
  • Replacing manual vector iteration with stdlib inline functions (vector::for_each_ref, vector::map, vector::fold, etc.) and lambdas
  • Replacing magic abort numbers with named constants
  • Migrating legacy coin/TokenV1 to modern fungible_asset/Digital Assets
  • Converting EventHandle to #[event] pattern
  • Upgrading custom signed integer workarounds to native i8-i256 types

When NOT to Use This Skill

  • Writing new contracts from scratch — use write-contracts
  • Fixing bugs or adding features — modernization is structural, not functional
  • Optimizing gas usage — use analyze-gas-optimization
  • Auditing security — use security-audit (run AFTER modernization)

Workflow

Phase 1: Analyze Contract

Entry: User provides a Move contract or project to modernize.

Actions:

  1. Read all contract source files (.move files in sources/)
  2. Scan for V1 patterns using detection rules from detection-rules.md:
    • Grep for Tier 1 patterns (syntax) — highest confidence, most common
    • Grep for Tier 2 patterns (visibility, errors, events)
    • Grep for Tier 3 patterns (API migrations) — flag for manual review
  3. Cross-reference coupled patterns (T3-09+T3-10)
  4. Categorize each finding: line number, rule ID, pattern name, proposed change, tier, confidence
  5. Build the Analysis Report

Exit: Analysis Report ready for presentation.

Phase 2: Present Analysis (GATE 1)

Entry: Analysis Report complete.

Actions:

  1. Present the full Analysis Report to the user in this format:
## Modernization Analysis Report

### Summary
- Tier 1 (Syntax): X findings
- Tier 2 (Visibility & Errors): X findings
- Tier 3 (API Migrations): X findings

### Findings

| # | File:Line | Rule | Pattern | Proposed Change | Tier | Confidence |
|---|-----------|------|---------|-----------------|------|------------|
| 1 | src/mod.move:15 | T1-01 | vector::borrow | → index notation | 1 | High |
| ... | ... | ... | ... | ... | ... | ... |

### Tier 3 Warnings (if any)
- T3-03: coin → fungible_asset migration is a major rewrite (X locations)
  1. Ask the user to choose scope:
    • syntax-only (Tier 1 only) — zero risk, just cleaner syntax
    • standard (Tier 1 + Tier 2) — recommended default, syntax + visibility + error constants
    • full (all tiers) — includes API migrations, higher risk
  2. Highlight any Tier 3 items that require major rewrites
  3. If scope includes Tier 3, ask the user about deployment context:
    • Compatible — Upgrading an already-deployed contract. Breaking changes are excluded even if the scope includes them. Rules marked ⚠ Breaking are skipped.
    • Fresh deploy — New deployment or willing to redeploy. All changes in the selected scope are applied including breaking changes.

Exit: User has confirmed scope (and deployment context if Tier 3 is included). Do NOT proceed until confirmed.

Phase 3: Establish Test Safety Net

Entry: User confirmed scope.

Actions:

  1. Search for existing tests:
    • #[test_only] modules within source files
    • *_tests.move files
    • tests/ directory
  2. If no tests found: stop and invoke generate-tests skill to create comprehensive tests first, then return here
  3. Run aptos move test to establish a passing baseline
  4. Record baseline: number of tests, all passing status

Exit: All tests pass. Baseline recorded. If tests fail pre-modernization, stop and address test failures first — do not modernize on a broken test suite.

Phase 4: Apply Transformations (with Feedback Loops)

Entry: Test baseline established.

Actions — apply in tier order:

Tier 1 (if scope includes it — always):

  1. Apply all Tier 1 syntax changes per transformation-guide.md
  2. Run aptos move test
  3. If tests fail → revert all Tier 1 changes, investigate which specific change caused failure, fix and retry

Tier 2 (if scope is standard or full): 4. Apply all Tier 2 changes per transformation guide 5. Run aptos move test 6. If tests fail → revert all Tier 2 changes, investigate and fix

Tier 3 (if scope is full only): 7. Apply Tier 3 changes ONE AT A TIME (not all at once)

  • If deployment context is compatible: skip any rule marked ⚠ Breaking. Add to the skipped list with reason "breaking change, excluded in compatible mode."
  • If deployment context is fresh deploy: apply all rules in scope normally.
  1. Run aptos move test after EACH individual Tier 3 change
  2. If tests fail → revert that specific change, note it as skipped, proceed to next Tier 3 item

Exit: All approved changes applied, all tests passing.

Phase 5: Final Verification

Entry: All transformations applied.

Actions:

  1. Run aptos move test --coverage
  2. Verify test coverage is >= baseline (should be same or better)
  3. Generate Modernization Summary Report:
## Modernization Summary

### Changes Applied
- Tier 1: X changes (syntax)
- Tier 2: X changes (visibility & errors)
- Tier 3: X changes (API migrations)

### Changes Skipped
- [List any skipped items with reasons]

### Test Results
- Tests: X passing (baseline: Y)
- Coverage: X% (baseline: Y%)

### Files Modified
- [List of modified files]

Exit: Report presented to user.

Modernization Scope Quick Reference

Scope Tiers Risk When to Use
syntax-only Tier 1 Zero Just clean up syntax, no semantic changes
standard Tier 1+2 Low Default. Syntax + visibility + error constants
full Tier 1+2+3 Medium-High Full migration including API changes

Tier Quick Reference

Tier What Changes Risk Examples
1 — Syntax Code reads differently, compiles identically Zero vector::borrow(&v, i) → v[i], x = x + 1 → x += 1, while (i < n) { ... i += 1 } → for (i in 0..n) { ... }
2 — Visibility & Errors Same semantics, cleaner declarations Low public(friend) → package fun, magic numbers → E_* constants
3 — API Migrations Different APIs, same intended behavior. Most are breaking changes. Medium-High coin → fungible_asset, SmartTable → BigOrderedMap, EventHandle → #[event], manual loops → stdlib v.for_each_ref()/v.map()/v.fold() with lambdas

See detection-rules.md for the complete rule catalog (22 rules across 3 tiers).

Rationalizations to Reject

Rationalization Why It's Wrong
"Tests pass so the modernization is correct" Tests verify behavior, not code quality. Review changes manually too.
"This contract is simple, skip the analysis" Simple contracts can have subtle patterns. Always analyze first.
"Let's do all tiers at once to save time" If tests break, you can't isolate which change caused it. Always tier.
"The receiver-style call looks right" Must verify the target function declares self. False positives are common.
"Error constants can have new names and values" Existing tests depend on exact numeric values. Preserve them.
"No tests exist, but the changes are safe" Without tests there is no safety net. Generate tests first.
"Tier 3 changes are optional, skip the test run" Every change needs verification. Tier 3 is highest risk — test MORE, not less.

Success Criteria

  • Analysis Report presented before any modifications
  • User confirmed modernization scope
  • Test baseline established before changes
  • Tests pass after each tier of changes
  • All error code numeric values preserved
  • No Tier 3 changes applied without full scope confirmation
  • Breaking changes excluded when user selected compatible mode
  • Modernization Summary Report generated
  • Test coverage maintained at or above baseline

Reference Index

File Content
detection-rules.md Complete V1 pattern detection catalog (22 rules across 3 tiers)
transformation-guide.md Before/after code, safety checks, edge cases per rule
MOVE_V2_SYNTAX.md Full V2 syntax reference
OBJECTS.md Modern object model patterns
ADVANCED_TYPES.md Enums, signed integers, phantom types

Related skills: generate-tests, write-contracts, security-audit

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,040
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,033
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,021
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,021
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,019
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,016
Skill 文件
  • SKILL.md
    • Skill: modernize-move
    • Essential Principles
    • When to Use This Skill
    • When NOT to Use This Skill
    • Workflow
      • Phase 1: Analyze Contract
      • Phase 2: Present Analysis (GATE 1)
      • Phase 3: Establish Test Safety Net
      • Phase 4: Apply Transformations (with Feedback Loops)
      • Phase 5: Final Verification
    • Modernization Scope Quick Reference
    • Tier Quick Reference
    • Rationalizations to Reject
    • Success Criteria
    • Reference Index
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期