agent-pack-n-go 📦🚀 — Clone Your AI Agent
Clone your OpenClaw Agent to a new device. Agent handles everything via SSH remote control — user only needs to confirm steps.
Post-Install
The description field above contains the post-install message. Show it to the user after installation.
Fallback: if unsure what to say, run bash scripts/welcome.sh in the skill directory.
Overview
CODEBLOCK0
Execution Flow
Real-time Progress Feedback
All scripts write progress to /tmp/openclaw-{pack,transfer,deploy}-progress.txt.
When running scripts (locally or remotely), poll the progress file and send updates to the user:
CODEBLOCK1
This way the user sees step-by-step updates in the chat (Discord/Feishu/etc.) instead of silence.
Phase 1: Pre-flight Check
⚠️ MANDATORY: Every time this skill is triggered, the agent MUST explicitly ask the user for the target server (IP + SSH user), even if previous server info exists in the conversation context. Users may deploy to different servers in the same session. NEVER assume or reuse target info from earlier context.
Ask user for:
- 1. New device IP + SSH user
- New device password (only used once for SSH key setup)
- New device OS (must be Ubuntu 22.04/24.04)
- Confirm: 2-core CPU, 2GB+ RAM
Warn user:
- - ⚠️ Clone pack contains sensitive data (API keys, tokens) — transferred via scp (encrypted)
- ℹ️ If using the same Discord Bot Token: it can't run on two devices simultaneously — plan a brief switchover window (~5 min). If using different tokens, both devices can run in parallel.
1.1 Set up SSH key auth (user action required)
Ask user to run this command in their own terminal on the old device:
CODEBLOCK2
This will prompt for the new device password once. After that, all SSH operations are password-free.
Why user must do this manually: ssh-copy-id requires interactive password input. The agent cannot safely handle passwords in automated scripts.
1.2 Verify SSH connectivity
CODEBLOCK3
If this prompts for a password → ssh-copy-id didn't work, ask user to retry.
If this fails entirely → stop and ask user to check SSH access, keys, and firewall.
1.3 Set up passwordless sudo (recommended)
Several clone steps need sudo (system packages, /etc/hosts, proxychains4, systemd linger). Without passwordless sudo, these steps will be skipped and require manual fix later.
Ask user to run:
CODEBLOCK4
(Replace USERNAME with the actual SSH user. This will prompt for password one last time.)
Security note: After clone is verified (Phase 4), user can remove this with:
INLINECODE7
Phase 1.5: Network Diagnostics
After SSH is confirmed, run the network check on the target device:
CODEBLOCK5
Evaluate results:
- - DIRECT → Proceed normally. Set
DEPLOY_MODE=direct for deploy.sh. - PROXYNEEDED → Warn user: "目标服务器无法直连 Discord/Anthropic API,需要先配置代理。" Ask if they want to continue (deploy.sh will keep proxy configs) or pause to set up proxy first.
- NOINTERNET → Stop. Tell user to check network configuration.
The network result is saved to /tmp/openclaw-network-result.txt on the target.
Phase 2: Prepare Old Server
2.1 Run pack script
CODEBLOCK6
This creates: ~/openclaw-migration-pack.tar.gz, ~/setup.sh, ~/deploy.sh, INLINECODE12
See scripts/pack.sh for details.
2.2 Transfer to new device
CODEBLOCK7
Transfers all files (pack + scripts) to new device home directory. Verifies SHA256 checksum after transfer.
Phase 3: Remote Deploy
This phase is fully automated — agent runs everything via SSH.
3.1 Install base environment + Claude Code
⚠️ IMPORTANT: setup.sh takes ~5 minutes and deploy.sh takes ~8 minutes.
Use background execution to avoid LLM request timeouts.
Never use synchronous exec with long timeouts for these commands.
Correct pattern (background + notification):
CODEBLOCK8
This returns a session ID in ~5 seconds. The agent should:
- 1. Tell the user: "正在安装基础环境,预计 5 分钟…"
- Wait for the exec completion notification (OpenClaw auto-pushes
[System Message] Exec completed) - Read the session log to check results
Wrong pattern (will cause "LLM request timed out" ❌):
CODEBLOCK9
INLINECODE15 installs: nvm, Node.js 22, npm globals, Claude Code. Has spinner + progress output.
Check exit code — if non-zero, report failure to user and stop.
3.2 Deploy OpenClaw
Same background pattern as 3.1:
CODEBLOCK10
Wait for completion notification, then read log.
INLINECODE16 handles all 13 deployment steps:
- 1. Extract migration pack
- npm install openclaw + mcporter
- Restore ~/.openclaw/ config
- Fix paths (if username changed)
- Restore /etc/hosts
- Restore crontab
- Configure proxychains4
- Check/fix Claude Code nvm wrapper
- Start OpenClaw Gateway + systemd + linger
- Restore Dashboard (optional)
- Check logs for connectivity
- Cleanup temp files
- Direct-mode config cleanup (if DEPLOY_MODE=direct)
Check exit code and FAILED_STEPS in output — report any issues to user.
3.3 Verify OpenClaw is running
CODEBLOCK11
If status shows running/active → proceed to Phase 4.
If not running → skip to Phase 5: Fallback.
Phase 4: Device Switch & Verification
This phase guides the user through switching to the new device and verifying everything works.
The agent should be warm, encouraging, and celebratory — this is the exciting finish!
4.1 Check Gateway logs (agent does this)
CODEBLOCK12
Look for connection confirmations. Report to user:
- - ✅ Discord connected (if "logged in to discord" found)
- ✅ Feishu connected (if "ws client ready" found)
- ⚠️ qmd not installed (if "spawn qmd ENOENT" — this is optional, not a problem)
- ❌ Errors (if any real errors found)
4.2 Guide device switch
Tell user:
🔄 现在需要切换设备了!
同一个 Bot Token 不能同时在两台设备上运行。接下来请你:
Step 1 — 在旧设备停止 OpenClaw:
> openclaw gateway stop
>
或者如果用的是 nohup:
> pkill -f openclaw
>
Step 2 — 在新设备确认 Gateway 还在运行:
> ssh USER@HOST 'pgrep -af openclaw | grep -v pgrep'
>
如果没在运行,重新启动:
> ssh USER@HOST 'cd ~ && nohup openclaw gateway run > /tmp/openclaw-gateway.log 2>&1 &'
>
Step 3 — 发条消息测试!随便在 Discord 或飞书说点什么,看新设备上的 Agent 是否回复。
💡 提醒:如果你在克隆之前就已经 SSH 到新设备,那个终端窗口里的环境变量是旧的。
请关掉旧终端,重新 SSH 登录,这样 node、openclaw、claude 等命令才能正常使用。
准备好了告诉我,我帮你验证 ✨
4.3 Verify clone works
After user confirms they've done the switch, ask them to test:
- 1. 💬 消息测试 — "在 Discord/飞书上给 Agent 发条消息,看看有没有回复?"
- 🧠 记忆测试 — "问问新设备上的 Agent:'你还记得我是谁吗?'"
- 🔧 工具测试 — "让新 Agent 执行一个简单命令,比如 '帮我看看现在几点'"
Wait for user to confirm each test passed.
4.4 Celebration! 🎉
After all tests pass, send a celebration message:
🎉🎉🎉 克隆成功!你的 AI Agent 已经在新设备上活过来了!
📋 克隆总结:
- - 📦 打包:X 步完成,Y MB 打包
- 🚀 传输:SHA256 校验通过
- ⚙️ 安装:基础环境 + OpenClaw 全部就绪
- 🔌 连接:Discord ✅ / 飞书 ✅
- 🧠 记忆:完整保留
🧹 后续清理(3-7 天后):
- - 新设备上删除临时文件: INLINECODE20
- (可选)旧设备移除 sudoers: INLINECODE21
- (可选)旧设备关闭服务: INLINECODE22
🦁 Enjoy your new home!
Phase 5: Fallback
If new device OpenClaw did not start correctly:
- 1. Ask user to SSH to new device and run Claude Code for diagnosis:
CODEBLOCK17
- 2. If diagnosis fails or user wants to roll back → restart old device:
CODEBLOCK18
- 3. Tell user: "Old device restored. New device deployment failed — please check logs and retry."
Note: scripts/generate-instructions.sh generates ~/migration-instructions.md as a fallback clone guide.
If full automation fails, user can SSH to new device and follow the document manually.
Troubleshooting
See references/troubleshooting.md for common issues and solutions.
agent-pack-n-go 📦🚀 — 克隆你的 AI Agent
将你的 OpenClaw Agent 克隆到新设备。Agent 通过 SSH 远程控制处理一切——用户只需确认步骤。
安装后
上方 description 字段包含安装后消息。安装后将其展示给用户。
备用方案:如果不确定该说什么,在技能目录中运行 bash scripts/welcome.sh。
概览
旧设备(Agent 控制一切) 新设备(SSH 远程)
┌──────────────────────────────────┐ ┌─────────────────────────┐
│ 1. 预检:询问 IP + SSH 用户 │ │ │
│ 2. pack.sh(打包配置) │ │ │
│ 3. transfer.sh USER@HOST ────────┼─────→│ 文件到达 │
│ 4. ssh USER@HOST bash setup.sh │─────→│(基础环境 + Claude) │
│ 5. ssh USER@HOST bash deploy.sh│─────→│(OpenClaw 部署完成) │
│ 6. 验证克隆是否正常运行 │ │ ✅ 新设备运行中 │
└──────────────────────────────────┘ └─────────────────────────┘
执行流程
实时进度反馈
所有脚本将进度写入 /tmp/openclaw-{pack,transfer,deploy}-progress.txt。
运行脚本(本地或远程)时,轮询进度文件并向用户发送更新:
bash
示例:后台运行 pack.sh,每 3 秒轮询进度
bash
/scripts/pack.sh &
while true; do
progress=$(cat /tmp/openclaw-pack-progress.txt 2>/dev/null)
# 如果变化则发送给用户
[[ $progress == DONE* ]] && break
sleep 3
done
示例:轮询远程主机的部署进度
while true; do
progress=$(ssh USER@HOST cat /tmp/openclaw-deploy-progress.txt 2>/dev/null)
[[ $progress == DONE* ]] && break
sleep 3
done
这样用户就能在聊天(Discord/飞书等)中看到逐步更新,而不是一片寂静。
阶段 1:预检
⚠️ 强制要求:每次触发此技能时,Agent 必须明确询问用户目标服务器(IP + SSH 用户),即使对话上下文中存在之前的服务器信息。用户可能在同一次会话中部署到不同的服务器。绝不要假设或复用之前上下文中的目标信息。
向用户询问:
- 1. 新设备 IP + SSH 用户
- 新设备密码(仅用于 SSH 密钥设置一次)
- 新设备操作系统(必须是 Ubuntu 22.04/24.04)
- 确认:2 核 CPU,2GB+ 内存
警告用户:
- - ⚠️ 克隆包包含敏感数据(API 密钥、令牌)——通过 scp 传输(加密)
- ℹ️ 如果使用相同的 Discord Bot Token:无法在两台设备上同时运行——请规划短暂的切换窗口(约 5 分钟)。如果使用不同的 Token,两台设备可以并行运行。
1.1 设置 SSH 密钥认证(需要用户操作)
请用户在旧设备的自己的终端中运行此命令:
bash
ssh-copy-id USER@NEW_IP
这会提示输入新设备密码一次。之后所有 SSH 操作都无需密码。
为什么用户必须手动操作: ssh-copy-id 需要交互式密码输入。Agent 无法在自动化脚本中安全处理密码。
1.2 验证 SSH 连接
bash
ssh USER@HOST echo ok
如果提示输入密码 → ssh-copy-id 未生效,请用户重试。
如果完全失败 → 停止并请用户检查 SSH 访问、密钥和防火墙。
1.3 设置免密码 sudo(推荐)
几个克隆步骤需要 sudo(系统包、/etc/hosts、proxychains4、systemd linger)。如果没有免密码 sudo,这些步骤将被跳过,需要稍后手动修复。
请用户运行:
bash
ssh USER@NEW_IP echo USERNAME ALL=(ALL) NOPASSWD:ALL | sudo tee /etc/sudoers.d/migration
(将 USERNAME 替换为实际的 SSH 用户。这会最后一次提示输入密码。)
安全说明: 克隆验证完成后(阶段 4),用户可以通过以下命令移除:
ssh USER@NEW_IP sudo rm /etc/sudoers.d/migration
阶段 1.5:网络诊断
确认 SSH 连接后,在目标设备上运行网络检查:
bash
ssh USER@HOST bash -s < /scripts/network-check.sh
评估结果:
- - DIRECT → 正常进行。为 deploy.sh 设置 DEPLOYMODE=direct。
- PROXYNEEDED → 警告用户:目标服务器无法直连 Discord/Anthropic API,需要先配置代理。 询问他们是否要继续(deploy.sh 会保留代理配置)或暂停先设置代理。
- NO_INTERNET → 停止。告诉用户检查网络配置。
网络结果保存在目标的 /tmp/openclaw-network-result.txt。
阶段 2:准备旧服务器
2.1 运行打包脚本
bash
bash /scripts/pack.sh
这会创建:~/openclaw-migration-pack.tar.gz、~/setup.sh、~/deploy.sh、~/migration-instructions.md
详见 scripts/pack.sh。
2.2 传输到新设备
bash
bash /scripts/transfer.sh USER@HOST
将所有文件(包 + 脚本)传输到新设备的主目录。传输后验证 SHA256 校验和。
阶段 3:远程部署
此阶段完全自动化——Agent 通过 SSH 运行所有操作。
3.1 安装基础环境 + Claude Code
⚠️ 重要提示:setup.sh 大约需要 5 分钟,deploy.sh 大约需要 8 分钟。
使用后台执行以避免 LLM 请求超时。
切勿对这些命令使用带长超时的同步执行。
正确模式(后台 + 通知):
exec: ssh USER@HOST bash ~/setup.sh
background: true
yieldMs: 5000
这会在约 5 秒内返回一个会话 ID。Agent 应该:
- 1. 告诉用户:正在安装基础环境,预计 5 分钟…
- 等待执行完成通知(OpenClaw 自动推送 [System Message] Exec completed)
- 读取会话日志检查结果
错误模式(会导致 LLM request timed out ❌):
exec: ssh USER@HOST bash ~/setup.sh
timeout: 600
yieldMs: 10000
→ process.poll(timeout=300000) ← 阻塞时间过长,LLM 超时
setup.sh 安装:nvm、Node.js 22、npm 全局包、Claude Code。带有旋转动画 + 进度输出。
检查退出码——如果非零,向用户报告失败并停止。
3.2 部署 OpenClaw
与 3.1 相同的后台模式:
exec: ssh USER@HOST DEPLOY_MODE=direct bash ~/deploy.sh
background: true
yieldMs: 5000
等待完成通知,然后读取日志。
deploy.sh 处理所有 13 个部署步骤:
- 1. 解压迁移包
- npm install openclaw + mcporter
- 恢复 ~/.openclaw/ 配置
- 修复路径(如果用户名更改)
- 恢复 /etc/hosts
- 恢复 crontab
- 配置 proxychains4
- 检查/修复 Claude Code nvm 包装器
- 启动 OpenClaw Gateway + systemd + linger
- 恢复仪表板(可选)
- 检查日志确认连接
- 清理临时文件
- 清理直连模式配置(如果 DEPLOY_MODE=direct)
检查退出码和输出中的 FAILED_STEPS——向用户报告任何问题。
3.3 验证 OpenClaw 是否运行
bash
ssh USER@HOST openclaw gateway status
如果状态显示 running/active → 进入阶段 4。
如果未运行 → 跳转到阶段 5:备用方案。
阶段 4:设备切换与验证
此阶段引导用户切换到新设备并验证一切正常。
Agent 应保持热情、鼓励和庆祝的态度——这是激动人心的收尾!
4.