Loading...
Loading...
macOS system migration assistant — Two phases: first collect an inventory (JSON) on the old system, then restore it on the new system. Use when the user mentions: system migration, changing computers, setting up a new system, Time Machine restoration, data migration, reinstalling the system, migration, setup new mac, restore from backup, or system backup. Automatically detects whether the current system is the old system (collection mode) or the new system (restore mode). Prerequisite: first make a full Time Machine backup; Homebrew is the only software dependency.
npx skill4agent add ttfake92-lab/skills macos-migrationDo not begin the migration without a full Time Machine backup.
ls ~/migration-manifest.json 2>/dev/null| Condition | Mode |
|---|---|
| No manifest file | Collection mode (on the old system, generate a manifest) |
| Manifest file exists | Restoration mode (on the new system, read the manifest and restore) |
which brew && brew --version || echo "NOT_INSTALLED"/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"eval "$(/opt/homebrew/bin/brew shellenv)"~/migration-manifest.jsonbrew list --formula
brew list --cask
brew tapls /Applications/
ls ~/Applications/ 2>/dev/nullmas list 2>/dev/null || echo "mas not installed"masbrew install masnpm ls -g --depth=0 2>/dev/nulluv tool list 2>/dev/nullpip list 2>/dev/null
pipx list 2>/dev/nullls ~/go/bin/ 2>/dev/nullls -la ~/.zshrc.zshenv.zprofile.bashrc.bash_profile.gitconfig.gitignore_global.ssh/.claude/.codex/.config/.cursor/.zed/.docker/.kube/.npm/.nvm/.bun/.cargo/.rustup/.SwitchHosts/.ollama/.syncthing/.ssh/.aws/.kube/"skipped_sensitive": [...]ls ~/Library/LaunchAgents/ls -d ~/*/ 2>/dev/null# 当前 shell 版本
zsh --version
# Homebrew 路径 / 版本管理器(nvm、fnm 等)配置
grep -iE 'brew|nvm|fnm' ~/.zshrc# 编辑器扩展
code --list-extensions 2>/dev/null
cursor --list-extensions 2>/dev/null
# 自购/自装字体
ls ~/Library/Fonts/ 2>/dev/null
# 定时任务
crontab -l 2>/dev/null
# 手动装到非 Homebrew 路径的命令行工具
ls /usr/local/bin/ 2>/dev/null
ls /opt/ 2>/dev/nullSystem preferences () are extensive and highly dependent on the machine model, so they are not collected automatically. If the user cares about them, remind the user in the restoration discrepancy report to verify them manually, including the keyboard, trackpad, Dock, shortcuts, and other settings.defaults
~/migration-manifest.json{
"version": 1,
"captured_at": "2026-06-28T16:00:00+08:00",
"source_macos": "15.5",
"source_hostname": "old-macbook",
"homebrew": {
"taps": ["user/repo", "..."],
"formulas": ["git", "node@22", "..."],
"casks": ["1password", "docker-desktop", "..."]
},
"applications": {
"homebrew_casks": ["claude", "firefox", "..."],
"app_store": [{"id": 123456, "name": "App Name"}],
"manual": ["Final Cut Pro.app", "..."]
},
"package_managers": {
"npm_global": ["@anthropic-ai/claude-code", "..."],
"uv_tools": ["nano-pdf", "..."],
"pip_packages": ["package1", "..."],
"go_binaries": ["tool1", "..."]
},
"configs": {
"dotfiles": [".zshrc", ".gitconfig", ".ssh", "..."],
"config_dirs": [".claude", ".codex", ".config", ".docker", "..."],
"app_support_keys": ["Syncthing", "obs-studio", "..."]
},
"editor_extensions": {
"vscode": ["ms-python.python", "..."],
"cursor": ["..."]
},
"fonts": ["MyFont.otf", "..."],
"crontab": "<crontab -l 原文,无则空>",
"manual_bins": ["/usr/local/bin/foo", "/opt/bar", "..."],
"launch_agents": ["com.github.syncthing.plist", "..."],
"user_dirs": ["Projects", "Sites", "..."],
"shell": {
"shell": "zsh",
"brew_in_path": true,
"nvm_installed": true,
"custom_env_vars": {}
},
"skipped_sensitive": []
}✅ 采集完成!清单已保存到 ~/migration-manifest.json
采集内容:
- Homebrew: X taps, Y formulas, Z casks
- 应用: X 个 Homebrew, Y 个 App Store, Z 个手动安装
- npm 全局包: X 个
- 配置文件: X 个 dotfiles, Y 个配置目录
- 编辑器扩展: X 个 / 字体: Y 个 / 定时任务: 有/无
- 自启动服务: X 个
- 用户目录: X 个
- 跳过的敏感项: X 个(用户选择不采集)
⚠️ 若采集了 .ssh / dotfiles 中的凭据,清单与备份含私钥,传输存放注意不要外泄。
下一步:确认已有 Time Machine 全量备份,将 migration-manifest.json 复制到新系统,
再次运行此 skill。migration-manifest.jsonls ~/migration-manifest.json找不到 migration-manifest.json。
请将旧系统上采集的清单文件复制到新系统的 home 目录:
scp old-mac:~/migration-manifest.json ~/migration-manifest.json
或者手动指定路径。Prerequisite: Homebrew has been confirmed as installed in Step Zero. The user must manually enter the password to install it. This step can run only after Homebrew is ready.
homebrew# 添加 taps(逐个)
brew tap <user>/<repo>
# 信任第三方 taps
brew trust <user>/<repo>
# 安装 formulas(批量,失败不回滚整批)
brew install <formula1> <formula2> ...
# 安装 casks(逐个,避免回滚)
for cask in <cask1> <cask2> ...; do
brew install --cask "$cask" 2>&1 | tail -3
donepackage_managers# npm
npm install -g <pkg1> <pkg2> ...
# uv
uv tool install <pkg1> <pkg2> ...
# pip(如果需要)
pip install <pkg1> <pkg2> ...
# go binaries
go install <pkg1>@latest <pkg2>@latest ...configsTM="<Time Machine 用户目录路径>"
LOCAL="/Users/<username>"
# dotfiles
rsync -av --ignore-existing "$TM/.zshrc" "$LOCAL/"
rsync -av --ignore-existing "$TM/.gitconfig" "$LOCAL/"
rsync -av --ignore-existing "$TM/.ssh/" "$LOCAL/.ssh/"
# 配置目录
for dir in .claude .codex .config .docker .SwitchHosts ...; do
rsync -av --ignore-existing "$TM/$dir/" "$LOCAL/$dir/"
doneAfter restoring, verify the permissions:.ssh/. If Time Machine is unavailable, ask the user to provide the source path for the configuration files.chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_*
| Subdirectory | Command | Description |
|---|---|---|
| Preferences | | Application preferences |
| Keychains | | Keychains |
| Containers | | Sandboxed application data |
| Group Containers | | Shared containers |
| Mail data | |
| Safari | | Bookmarks/history |
reportsrsyncerrors on Time Machine APFS snapshots. Useio_read_flushfor Library subdirectories.cp -rn
launch_agentslaunchctl load# 编辑器扩展(逐个装)
for ext in <清单 editor_extensions.vscode>; do code --install-extension "$ext"; done
# 字体
rsync -av --ignore-existing "$TM/Library/Fonts/" "$LOCAL/Library/Fonts/"
# 定时任务:先看新机器有没有现成的,再决定是否合并写入,避免覆盖
crontab -l 2>/dev/nullManually installed tools inand/usr/local/bincannot be restored automatically. List them in the discrepancy report in B7 and remind the user about them./opt
## 还原差异报告
### ❌ 安装失败(需手动处理)
- docker-desktop: 需要 sudo → 手动执行 `brew install --cask docker-desktop`
- tailscale-app: 需要 sudo → 手动执行 `brew install --cask tailscale-app`
- android-platform-tools: 网络问题 → 稍后重试
### ⚠️ 清单中有但无 Homebrew cask
- Final Cut Pro: App Store 应用
- DaVinci Resolve Studio: 手动下载 → blackmagicdesign.com
### ℹ️ App Store 应用(需手动安装或用 mas)
- GarageBand
- Infuse
### 🔧 需手动核对(非软件)
- 系统偏好 defaults:键盘 / 触控板 / Dock / 快捷键
- /usr/local/bin、/opt 手动工具:<manual_bins 列表>
- 拒绝采集的敏感项:<skipped_sensitive 列表>brew bundlebrew bundle --file=Brewfilebrew bundleRefusing to load cask from untrusted tapbrew trust <user>/<repo>rsyncrsync -av --ignore-existingio_read_flushcp -rncp -rncp -rndocker-desktoptailscale-appadobe-creative-cloudbrew linkbrew install node@22brew link --overwrite node@22/Applications/brew list --cask--ignore-existing-nbrew bundlebrew listdu -sh