OpenClaw Upgrader
Use this skill for cross-platform, same-host OpenClaw upgrades. Keep the skill focused on one job:
- 1. OpenClaw does the minimal safe preparation itself
- A local ACP/CLI coding agent (Codex or Claude Code) executes the full upgrade and recovery workflow on the same host
- Success means the upgraded OpenClaw runtime is usable again, not merely that package installation finished
Core contract
Do not treat this as a shell script wrapper skill. Treat it as a same-host ACP/CLI delegation skill.
This skill is for upgrading the OpenClaw installation on the same host where the delegated coding agent runs. It is cross-platform across host OS/service models, but it is not a generic remote-host orchestration skill.
Concurrency contract:
- - On a given host, allow at most one active openclaw-upgrader run at a time.
- If a second run is requested while one is active, do not run them concurrently.
- The caller must either reject re-entry immediately or queue it explicitly.
- Prefer immediate rejection by default unless the caller has a real queueing mechanism.
OpenClaw should do only lightweight preparation before delegation:
- - detect current version
- identify likely package manager / install method if easy to determine
- back up the config
- collect relevant environment facts for Codex
- formulate a strong Codex prompt
Use scripts/collect-upgrade-context.sh to gather a machine-readable context snapshot before delegation. That script must reject re-entry before agent preflights and may claim the host-level active-run lock on behalf of the outer upgrader flow. Use scripts/run-upgrade-delegation.sh as the outer runner scaffold so the lock is released only when the upgrader flow reaches a terminal path. Read references/review-checklist.md when composing or reviewing the Codex handoff.
After that, hand off the full upgrade workflow to a local coding agent: prefer Codex; use Claude Code if Codex is unavailable or unsuitable.
What success means
An upgrade is successful only if all of these are true:
- 1. OpenClaw version is at the requested target, or already latest/target
- The correct OpenClaw Gateway/service instance is running again under the host's service model
- The correct configured/local Gateway endpoint is reachable again
- Authentication-aware probing shows the endpoint is live, even if it is protected
- OpenClaw can serve the intended local clients again
- No required post-upgrade recovery step remains pending
If package installation succeeded but the runtime did not recover, report failure, not success.
Cross-platform rule
Do not hardcode macOS-specific assumptions into the skill contract.
Examples:
- - Do not require
LaunchAgent in the generic rules - Do not hardcode
127.0.0.1:18789 as the only valid endpoint - Do not assume only one service manager exists
Instead, require Codex to verify the appropriate host-specific service model and the actual configured/local endpoint.
Examples of host-specific service models Codex may need to handle:
- - macOS LaunchAgent / launchctl
- Linux systemd / service managers
- containerized or manually supervised installs
- other local supervisor arrangements
What OpenClaw should do before delegation
Do these directly before spawning the delegated agent:
- 1. Enforce the single-active-run lock for this host before any agent probe, preflight, or other side-effecting preparation
- Detect current version
- Back up config
- Check agent availability and delegation preconditions
- Record key runtime facts, if cheaply available
- Pass those facts into the delegated-agent task
The run lock must cover the entire active upgrader lifecycle, not just context collection. scripts/collect-upgrade-context.sh may claim the host-level run lock and emit lock metadata, but the caller/outer runner must retain that lock until the delegated upgrade run reaches a terminal state and then release it deliberately. scripts/run-upgrade-delegation.sh is the default outer-runner scaffold for this purpose and must remain responsible for terminal lock release.
If delegation cannot begin, OpenClaw itself must write a structured pre-delegation failure result. Do not leave blocked delegation as an implicit or unstructured failure.
If another upgrader run is already active on this host, reject re-entry or explicitly queue it; do not allow concurrent execution.
Useful facts to pass:
- - current version
- requested target version
- install method clues (
npm, pnpm, yarn, package manager, custom) - config path
- state dir / profile context if present (
OPENCLAW_STATE_DIR, OPENCLAW_PROFILE) - expected gateway/service command(s)
- actual service label / unit / task name, if known
- known local endpoint, if known
- endpoint auth mode, if known
- token/password source or auth expectation, if known
- OS / platform
- any recent failure mode already observed by the user
- Codex installed/auth/preflight status
- Claude Code installed/auth/preflight status
- selected agent, if any
- delegation block reason, if delegation cannot start
When multiple OpenClaw instances may exist, pass enough identity information that Codex can upgrade, repair, and verify the same instance.
Delegated agent responsibility
The delegated local coding agent (Codex or Claude Code) owns the full upgrade flow after handoff. That includes:
- 1. Determine the correct upgrade path for this host
- Execute the upgrade
- Refresh or reinstall the host-native service definition if the updated install requires it
- Restart or recover the correct Gateway/service instance
- Detect broken post-upgrade states
- Repair them
- Verify end-to-end usability
- Write a structured result
Agent selection and fallback
Before delegation, check whether a supported local coding agent is actually usable.
Preferred order:
- 1. Codex
- Claude Code
Check all of the following before selecting an agent:
- - CLI is installed and invokable
- CLI is authenticated/logged in
- CLI passes a lightweight, non-destructive delegation-viability preflight on this host
Important: this preflight is a necessary but not sufficient condition. It is only meant to reject obviously unusable agents before delegation. It does not prove that the agent will definitely succeed at package upgrade, service recovery, verification, or file writes during the real run.
Handle these cases explicitly:
No supported CLI installed
If neither Codex nor Claude Code is installed, stop and report that the skill cannot proceed yet. Do not silently fall back to a shell-only upgrade flow. Write a structured result with status delegation_blocked.
CLI installed but not logged in
If a CLI is installed but not authenticated, stop and report that the selected agent is unavailable until login/auth is completed. If no other supported agent is usable, write a structured result with status delegation_blocked.
CLI logged in but fails delegation preflight
If a CLI is authenticated but fails the lightweight delegation-viability preflight, treat it as unavailable for this task and try the other supported CLI if present. If neither agent passes preflight, stop and report that delegation cannot safely continue, and write a structured result with status delegation_blocked.
Do not overclaim what the preflight proves. A passing preflight only means the agent looks viable enough to start delegation; it does not prove that the full upgrade workflow will succeed.
Both available
Prefer Codex by default. Use Claude Code when Codex is unavailable, unauthenticated, or lacks the needed capabilities.
OpenClaw should record the selected agent explicitly before delegation.
What the delegated-agent prompt must emphasize
The most important part of this skill is the prompt quality. The prompt to the delegated agent should strongly emphasize these points:
1. Treat runtime recovery as part of the upgrade
Tell the delegated agent explicitly:
- - The upgrade is not complete when package installation finishes
- The upgrade is only complete when OpenClaw is operational again
- Broken service state after install is a failed upgrade and must be repaired
- If the updated install ships or expects refreshed service definitions, refresh/reinstall them before concluding recovery failed
2. Work from the host's real service model
Tell the delegated agent to infer and verify the real service management model on the host instead of assuming macOS or any single supervisor.
Examples:
- - inspect how OpenClaw is currently launched
- inspect current service state
- restart/reload using the correct host-native mechanism
- refresh or reinstall the host-native service definition if needed after upgrade
- verify that the service manager actually brought the runtime back
3. Verify the real endpoint, not a guessed one
Tell the delegated agent to validate the real configured/local Gateway endpoint.
Do not let Codex stop after a restart command. Require it to verify actual reachability.
Require authentication-aware verification:
- - if the endpoint responds and is auth-protected, treat that as reachable service, not dead service
- use the available auth context when appropriate
- distinguish "unreachable" from "reachable but requires auth"
- continue validating real host operations during the delegated run instead of assuming the preflight proved everything
4. Distinguish package success from runtime success
Tell the delegated agent to separately evaluate:
- - package/install success
- service-definition refresh success
- service recovery success
- endpoint reachability
- authenticated or auth-aware probe success
- client usability
- whether the delegated run actually retained enough permissions/capabilities once real upgrade actions began
If the first passes and the latter fail, overall status must still be failure.
5. Prefer diagnosis + repair over blind retries
Tell the delegated agent to inspect the failure mode and repair the actual cause.
Examples of causes:
- - service manager failed to reload
- updated install requires refreshed service definition
- unit/agent not loaded
- wrong instance label/unit/task repaired
- process crashed on boot
- config/env regression after upgrade
- port/endpoint mismatch
- stale wrapper / broken launch target
- auth assumptions wrong during endpoint verification
6. Keep instance identity stable through the whole run
Tell the delegated agent to identify the exact OpenClaw instance being upgraded and use the same identity for upgrade, repair, restart, and validation.
Useful identity anchors include:
- - config path
- INLINECODE15
- INLINECODE16
- service label/unit/task name
- endpoint
- runtime working directory
Do not allow "upgraded one instance, repaired another" outcomes.
7. Leave a machine-readable result
Require the delegated agent to write a structured result file with:
- - prior version
- final version
- upgrade status
- service-definition refresh status
- service recovery status
- endpoint reachability status
- auth-aware endpoint probe status
- instance identity used
- key repair actions taken
- final error if unsuccessful
- log location
Suggested delegated-agent prompt template
Use a prompt roughly like this, adapted to the environment and selected agent:
CODEBLOCK0
Result file
Write structured output to:
CODEBLOCK1
Expected shape:
CODEBLOCK2
Important notes
- 1. Keep OpenClaw-side preparation light
- Delegate the real upgrade workflow to a supported local coding agent
- Prefer Codex, but support Claude Code as a first-class fallback
- Refuse shell-only fallback when no suitable coding agent is available
- Enforce single-active-run semantics on the host; reject or explicitly queue re-entry
- If delegation cannot begin, OpenClaw must write a structured
delegation_blocked or rejected_reentry result itself - Make the delegated-agent prompt strict about recovery and verification
- Keep the skill cross-platform
- Never equate package installation with upgrade success
- Never let the delegated agent repair or verify the wrong OpenClaw instance
- Never let auth-protected reachability be mistaken for outage
OpenClaw 升级器
使用此技能进行跨平台、同主机 OpenClaw 升级。保持技能专注于一项任务:
- 1. OpenClaw 自行完成最小化的安全准备工作
- 本地 ACP/CLI 编码代理(Codex 或 Claude Code)在同一主机上执行完整的升级和恢复工作流
- 成功意味着升级后的 OpenClaw 运行时再次可用,而不仅仅是软件包安装完成
核心契约
不要将此技能视为 shell 脚本包装器技能。将其视为同主机 ACP/CLI 委派技能。
此技能用于升级运行委派编码代理的同一主机上的 OpenClaw 安装。它跨主机操作系统/服务模型平台,但不是通用的远程主机编排技能。
并发契约:
- - 在给定主机上,一次最多允许一个活动的 openclaw-upgrader 运行。
- 如果在活动运行期间请求第二次运行,不要并发执行它们。
- 调用方必须立即拒绝重入或显式将其排队。
- 除非调用方有真正的排队机制,否则默认优先立即拒绝。
OpenClaw 在委派前应仅执行轻量级准备工作:
- - 检测当前版本
- 如果容易确定,识别可能的包管理器/安装方法
- 备份配置
- 为 Codex 收集相关环境事实
- 制定一个强力的 Codex 提示
使用 scripts/collect-upgrade-context.sh 在委派前收集机器可读的上下文快照。该脚本必须在代理预检前拒绝重入,并可代表外部升级器流程声明主机级活动运行锁。使用 scripts/run-upgrade-delegation.sh 作为外部运行器脚手架,以便仅在升级器流程到达终端路径时才释放锁。在编写或审查 Codex 交接时阅读 references/review-checklist.md。
之后,将完整的升级工作流移交给本地编码代理:优先使用 Codex;如果 Codex 不可用或不合适,则使用 Claude Code。
成功的含义
仅当以下所有条件都为真时,升级才算成功:
- 1. OpenClaw 版本已达到请求的目标版本,或已是最新/目标版本
- 正确的 OpenClaw 网关/服务实例在主机的服务模型下再次运行
- 正确的配置/本地网关端点再次可达
- 认证感知探测显示端点处于活动状态,即使它受保护
- OpenClaw 可以再次服务于预期的本地客户端
- 没有待处理的升级后恢复步骤
如果软件包安装成功但运行时未恢复,则报告失败,而非成功。
跨平台规则
不要将特定于 macOS 的假设硬编码到技能契约中。
示例:
- - 不要在通用规则中要求 LaunchAgent
- 不要将 127.0.0.1:18789 硬编码为唯一有效端点
- 不要假设只有一个服务管理器
相反,要求 Codex 验证适当的主机特定服务模型和实际配置/本地端点。
Codex 可能需要处理的主机特定服务模型示例:
- - macOS LaunchAgent / launchctl
- Linux systemd / 服务管理器
- 容器化或手动监督的安装
- 其他本地监督器安排
OpenClaw 在委派前应做什么
在生成委派代理之前直接执行以下操作:
- 1. 在任何代理探测、预检或其他副作用准备之前,强制执行此主机的单活动运行锁
- 检测当前版本
- 备份配置
- 检查代理可用性和委派前提条件
- 如果容易获取,记录关键运行时事实
- 将这些事实传递给委派代理任务
运行锁必须覆盖整个活动升级器生命周期,而不仅仅是上下文收集。scripts/collect-upgrade-context.sh 可以声明主机级运行锁并发出锁元数据,但调用方/外部运行器必须保留该锁,直到委派的升级运行达到终端状态,然后有意识地释放它。scripts/run-upgrade-delegation.sh 是用于此目的的默认外部运行器脚手架,并且必须负责终端锁释放。
如果委派无法开始,OpenClaw 本身必须编写结构化的委派前失败结果。不要将阻塞的委派作为隐式或非结构化失败处理。
如果此主机上已有另一个升级器运行处于活动状态,则拒绝重入或显式将其排队;不允许并发执行。
要传递的有用事实:
- - 当前版本
- 请求的目标版本
- 安装方法线索(npm、pnpm、yarn、包管理器、自定义)
- 配置路径
- 状态目录/配置文件上下文(如果存在)(OPENCLAWSTATEDIR、OPENCLAW_PROFILE)
- 预期的网关/服务命令
- 实际的服务标签/单元/任务名称(如果已知)
- 已知的本地端点(如果已知)
- 端点认证模式(如果已知)
- 令牌/密码来源或认证期望(如果已知)
- 操作系统/平台
- 用户已观察到的任何近期故障模式
- Codex 安装/认证/预检状态
- Claude Code 安装/认证/预检状态
- 选定的代理(如果有)
- 委派阻塞原因(如果委派无法开始)
当可能存在多个 OpenClaw 实例时,传递足够的身份信息,以便 Codex 可以升级、修复和验证同一实例。
委派代理职责
委派的本地编码代理(Codex 或 Claude Code)在交接后拥有完整的升级流程。这包括:
- 1. 确定此主机的正确升级路径
- 执行升级
- 如果更新后的安装需要,刷新或重新安装主机原生服务定义
- 重启或恢复正确的网关/服务实例
- 检测升级后损坏的状态
- 修复它们
- 验证端到端可用性
- 编写结构化结果
代理选择与回退
在委派之前,检查受支持的本地编码代理是否实际可用。
优先顺序:
- 1. Codex
- Claude Code
在选择代理之前检查以下所有内容:
- - CLI 已安装且可调用
- CLI 已认证/登录
- CLI 在此主机上通过了轻量级、非破坏性的委派可行性预检
重要:此预检是必要但不充分的条件。它仅用于在委派前拒绝明显不可用的代理。它不能证明代理在实际运行期间一定能成功完成包升级、服务恢复、验证或文件写入。
显式处理以下情况:
未安装受支持的 CLI
如果既未安装 Codex 也未安装 Claude Code,则停止并报告该技能尚无法继续。不要静默回退到仅 shell 的升级流程。编写状态为 delegation_blocked 的结构化结果。
CLI 已安装但未登录
如果 CLI 已安装但未认证,则停止并报告所选代理在登录/认证完成之前不可用。如果没有其他受支持的代理可用,则编写状态为 delegation_blocked 的结构化结果。
CLI 已登录但未通过委派预检
如果 CLI 已认证但未通过轻量级委派可行性预检,则将其视为对此任务不可用,并尝试另一个受支持的 CLI(如果存在)。如果两个代理均未通过预检,则停止并报告委派无法安全继续,并编写状态为 delegation_blocked 的结构化结果。
不要夸大预检的证明力。通过的预检仅意味着代理看起来足够可行以开始委派;它不能证明完整的升级工作流会成功。
两者都可用
默认优先使用 Codex。当 Codex 不可用、未认证或缺乏所需能力时,使用 Claude Code。
OpenClaw 应在委派前显式记录所选代理。
委派代理提示必须强调的内容
此技能最重要的部分是提示质量。给委派代理的提示应强烈强调以下几点:
1. 将运行时恢复视为升级的一部分
明确告知委派代理:
- - 软件包安装完成时升级并未完成
- 仅当 OpenClaw 再次可运行时升级才算完成
- 安装后的服务状态损坏是失败的升级,必须修复
- 如果更新后的安装附带或期望刷新服务定义,在断定恢复失败之前刷新/重新安装它们
2. 从主机的实际服务模型出发
告知委派代理推断并验证主机上的实际服务管理模型,而不是假设 macOS 或任何单一监督器。
示例:
- - 检查 OpenClaw 当前如何启动
- 检查当前服务状态
- 使用正确的主机原生机制重启/重新加载
- 如果升级后需要,刷新或重新安装主机原生服务定义
- 验证服务管理器确实使运行时恢复
3. 验证实际端点,而非猜测的端点
告知委派代理验证实际配置/本地网关端点。
不要让 Codex 在重启命令后停止。要求它验证实际可达性。
要求认证感知验证:
- - 如果端点响应且受认证保护,则将其视为可达服务,而非死服务
- 在适当时使用可用的认证上下文
- 区分不可达和可达但需要认证
- 在委派运行期间继续验证实际主机操作,而不是假设预检证明了所有