把老用户的 .cheat-state.json 升级到当前 schema_version。读 migrations/registry.md 算迁移链,按顺序应用每一步迁移文件。幂等:跑两次结果一样。失败停在中间版本不前进。触发词:"迁移"/"升级 state"/"migrate"/"我的 state 是老版本"/"schema 版本不对"。
68
84%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
把用户 .cheat-state.json 从旧 schema_version 升级到 cheat-on-content 当前期望的 LATEST_SCHEMA。
[用户:迁移 / 或 SessionStart 提示后用户跑]
↓
[Phase 0: 读 .cheat-state.json + migrations/registry.md → 确定迁移链]
↓
[Phase 1: dry-run(默认)展示迁移计划,等用户确认]
↓
[Phase 2: 备份 .cheat-state.json → .cheat-state.json.backup-<timestamp>]
↓
[Phase 3: 按顺序对每个 step 应用对应迁移文件的 HOW 段]
↓
[Phase 4: 验证升级后 state 文件能被解析 + schema_version 已更新]
↓
[Phase 5: 报告 + 提示如有备份需要清理]${SKILL_DIR}/../../migrations/registry.md — 版本链单一来源${SKILL_DIR}/../../migrations/ — 迁移文件目录💡 调用时覆盖:
/cheat-migrate — dry-run: false直接执行 //cheat-migrate — to: 1.2仅升到指定版本
| 必填 | 来源 |
|---|---|
.cheat-state.json | 用户项目根 |
migrations/registry.md | LATEST_SCHEMA + 版本链表 |
migrations/<from>-to-<to>.md | 每步具体迁移指令 |
.cheat-state.json → 解析 current_version = state.schema_versionmigrations/registry.md → 解析 LATEST_SCHEMA 字段(行:LATEST_SCHEMA = "X.Y")args.to 覆盖(如有);否则 target = LATEST_SCHEMAargs.from 覆盖(罕见场景:用户的 state 文件 schema 字段坏了,强制指定起点)current_version == target → 输出"✅ state 已是 {target},无需迁移" → 退出current_version > target(比如用户跑了 dev 版又切回 release)→ 报错"无法降级,请手动调整或重新 init"current_version < target → 继续,从注册表查出迁移链chain = [(from, to, file), ...],按顺序串起 current → target如果某一步在注册表里缺失(比如 current_version 不在表里)→ 报错并展示"目前已知版本:[1.0, 1.1, ...]",让用户检查。
输出迁移计划:
📋 迁移计划
当前版本: 1.0
目标版本: 1.2
将按顺序跑 2 步:
[1/2] 1.0 → 1.1(MINOR)
新增字段:typical_duration_seconds, target_publish_cadence_days, ...(共 12 字段)
删除字段:mode, prediction_complexity, bucket_scheme
详见: migrations/1.0-to-1.1.md
[2/2] 1.1 → 1.2(MINOR)
新增字段:[...]
详见: migrations/1.1-to-1.2.md
⚠️ 备份位置: .cheat-state.json.backup-<timestamp>
继续吗?回 yes 执行 / no 退出 / dry-run-detail 看每步具体改什么。如 args["dry-run"] == false 或用户回 yes → 进 Phase 2。
cp .cheat-state.json .cheat-state.json.backup-$(date +%s)输出:"📦 备份到 .cheat-state.json.backup-1714838400"
对 chain 里的每个 (from, to, file):
migrations/<file> → 找到 ## HOW (Claude steps for /cheat-migrate) 段升完后:
.cheat-state.json → 解析 → 应能成功schema_version == target✅ 迁移完成
从: 1.0
到: 1.2
应用步骤: 2
state 文件现在含 X 字段,全部通过验证。
📦 备份保留:.cheat-state.json.backup-1714838400
(确认一切正常后可手动 rm;下次成功 /cheat-init 也会清理过期备份)
下一步建议:
- 跑 /cheat-status 确认看板正常
- 如有 hooks 重装需求,跑 bash <skill_repo>/install.sh --reinstall-hookscurrent_version == target 实现--dry-run: false,备份动作仍执行.cheat-state.json。其他用户数据由各自 skill 负责,迁移 skill 不碰--dry-run: false),但备份仍强制执行--from: 1.0,但要警告"基于猜测的迁移可能导致字段错位"state.schema_version != LATEST_SCHEMA → 输出红色警告 + 建议跑 /cheat-migratecheat-init:init 写新 state 时直接用 LATEST_SCHEMA,不需要走 migrateinstall.sh --reinstall-hooks:迁移不重装 hook 脚本(hook 脚本属于 skill 包代码,不属于用户 state)。这两件事解耦本 skill 写:
schema_version(每步成功后更新)本 skill 读:
本 skill 绝不写:
calibration_samples / pending_retros / shoots 等业务状态(这些是其他 skill 的职责)用户:迁移
Claude: [跑 cheat-migrate]
Phase 0: current=1.1, target=1.2, chain=[(1.1, 1.2)]
Phase 1: dry-run 输出计划
用户: yes
Phase 2: 备份
Phase 3: 应用 1.1-to-1.2.md(MINOR:新增 platform_metrics_url 等字段)
Phase 4: 验证 OK
Phase 5: 报告 ✅用户:我从 v0.1.0 升到 v0.5.0,state 还是 1.0
Claude: [跑 cheat-migrate]
Phase 0: current=1.0, target=1.4 (LATEST), chain=[(1.0, 1.1), (1.1, 1.2), (1.2, 1.3), (1.3, 1.4)]
Phase 1: dry-run 输出 4 步计划
...Phase 3:
→ [1/4] 应用 1.0-to-1.1.md ✓
→ [2/4] 应用 1.1-to-1.2.md ✓
→ [3/4] 应用 1.2-to-1.3.md... ❌ 失败:用户 baseline_plays 字段含非数字值,无法转 int
state 已停在 schema_version: 1.2。
修复 .cheat-state.json 后重跑 /cheat-migrate 会从 1.2 → 1.3 继续。86823e1
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.