Skills gateway-guard
Ensures OpenClaw gateway auth consistency and can auto-prompt "continue" when a run error (Unhandled stop reason: error) appears in gateway logs. Use when checking or fixing gateway token/password mismatch, device_token_mismatch errors, or before delegating to sub-agents.
git clone https://github.com/openclaw/skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/austindixson/gateway-guard" ~/.claude/skills/openclaw-skills-gateway-guard && rm -rf "$T"
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/austindixson/gateway-guard" ~/.openclaw/skills/openclaw-skills-gateway-guard && rm -rf "$T"
skills/austindixson/gateway-guard/SKILL.mdGateway Guard
Description
Ensures OpenClaw gateway auth consistency and can auto-prompt "continue" when a run error (Unhandled stop reason: error) appears in gateway logs. Use when checking or fixing gateway token/password mismatch, device_token_mismatch errors, or before delegating to sub-agents.
Ensures OpenClaw gateway auth consistency and can auto-prompt "continue" when a run error (Unhandled stop reason: error) appears in gateway logs. Use when checking or fixing gateway token/password mismatch, device_token_mismatch errors, or before delegating to sub-agents.
Gateway Guard
Keeps OpenClaw gateway authentication in sync with
openclaw.json. Use when the user or agent sees gateway auth issues, device_token_mismatch, or needs to ensure the gateway is running with the correct token/password before spawning sub-agents.
Metadata: This skill uses
always: false in _meta.json. It is not forced into every agent run; the orchestrator invokes it when needed (e.g. before delegating to sub-agents). Optional persistence (LaunchAgent) is installed only when you run the install scripts; see "Before installing" below.
Before installing
- Backup
— The script may add or correctopenclaw.json
(token/password) when missing or wrong. Make a copy before runninggateway.auth
.ensure --apply - Test read-only first — Run
andpython3 scripts/gateway_guard.py status --json
(withoutpython3 scripts/gateway_guard.py ensure --json
) to see what it would do before allowing restarts or config writes.--apply - Understand
delivery — The watcher can runcontinue
when a run error appears inopenclaw agent --message continue --deliver
. Confirm that automatically sending that message is acceptable in your environment.gateway.log - LaunchAgent is optional — Persistence (watcher every 30s) is installed only if you run
. The installer copies the plist from the skill directory intoinstall_watcher.sh
and runs~/Library/LaunchAgents
; only run it if you accept that. The plist is included in this package:launchctl load
(andscripts/com.openclaw.gateway-guard.watcher.plist
). Ensurescripts/com.openclaw.gateway-guard.continue-on-error.plist
andOPENCLAW_HOME
resolve to your intended paths before installing the watcher.OPENCLAW_BIN - Try in a non-production environment first if you are unsure.
Package contents (file manifest)
Included in this skill so installers do not error:
— Main script (status, ensure, continue-on-error, watch).scripts/gateway_guard.py
— Installs the single combined LaunchAgent (token sync + continue-on-error).scripts/install_watcher.sh
— Redirects toscripts/install_continue_on_error.sh
.install_watcher.sh
— LaunchAgent plist template (install_watcher.sh copies and substitutes paths).scripts/com.openclaw.gateway-guard.watcher.plist
— Legacy plist (optional; install_watcher.sh replaces with the combined watcher).scripts/com.openclaw.gateway-guard.continue-on-error.plist
Usage
- User or logs report "Gateway auth issue", "device_token_mismatch", or "unauthorized"
- Before running the router and
(orchestrator flow): check gateway status firstsessions_spawn - After installing or updating OpenClaw: verify gateway and config match
- When the TUI disconnects or won't connect: fix auth and restart gateway
- Run error (Unhandled stop reason: error): run
(e.g. via LaunchAgent or cron) so the guard auto-sends "continue" to the agent when this appears incontinue-on-error --loopgateway.log
python3 <skill-dir>/scripts/gateway_guard.py status [--json] python3 <skill-dir>/scripts/gateway_guard.py ensure [--apply] [--wait] [--json] python3 <skill-dir>/scripts/ensure_gateway_then.sh [command ...] python3 <skill-dir>/scripts/gateway_guard.py continue-on-error [--once] [--loop] [--interval 30] [--json]
- status — Report whether the running gateway's auth matches
. Exit 0 if ok, 1 if mismatch.openclaw.json - ensure — Same check; if mismatch and
, restart the gateway with credentials from config. Writes--apply
togateway.auth
only when it is missing or wrong (never overwrites correct config). Useopenclaw.json
after--wait
to block until the gateway port is open (up to 30s), so clients can connect immediately after.--apply - ensure_gateway_then.sh — Detect and connect automatically: ensures the gateway is running (starts it if needed, waits for port), then runs your command. Example:
orensure_gateway_then.sh openclaw tui
(just ensure and wait).ensure_gateway_then.sh - continue-on-error — When
contains Unhandled stop reason: error (run error), send continue to the agent viagateway.log
. Useopenclaw agent --message continue --deliver
to check once and exit, or--once
to run every--loop
seconds. Cooldown 90s between triggers. State:--interval
.logs/gateway-guard.continue-state.json - watch — Single combined daemon (one LaunchAgent). Each run: (0) token sync —
so gateway auth matches config (prevents device_token_mismatch); (1) gateway back → what-just-happened summary; (2) continue-on-error check. Install one daemon:ensure --apply
(orbash <skill-dir>/scripts/install_watcher.sh
). This unloads the old separate what-just-happened and continue-on-error LaunchAgents and loadsinstall_continue_on_error.sh
so users only need one. For periodic gateway recovery (check every 10s, restart if not ok), use the separate gateway-watchdog skill.com.openclaw.gateway-guard.watcher
Behavior
- Reads
→openclaw.json
(token or password) andgateway.auth
.gateway.port - Compares with the process listening on that port (and optional guard state file).
- If
: restarts gateway viaensure --apply
thenopenclaw gateway stop
.openclaw gateway --port N --auth token|password --token|--password SECRET - If token is missing in config (token mode only): generates a token, writes it to config once, then proceeds. Does not overwrite config when it is already correct.
- continue-on-error: Tails
for the stringOPENCLAW_HOME/logs/gateway.log
. When found (and not in cooldown), runsUnhandled stop reason: error
so the agent receives "continue" and can resume. Runopenclaw agent --message continue --deliver
to install a LaunchAgent that checks every 30s. If the error appears in the TUI but the watcher never triggers, the gateway may not be writing run errors toinstall_continue_on_error.sh
— ensure run/stream errors are logged there.gateway.log
JSON output (for orchestration)
- status --json / ensure --json:
,ok
,secretMatchesConfig
,running
,pid
,reason
,recommendedAction
,configPath
,authMode
. When not ok,gatewayPort
is "run gateway_guard.py ensure --apply and restart client session".recommendedAction
Requirements
- OpenClaw
withopenclaw.json
(modegateway.auth
ortoken
) andpassword
.gateway.port - CLI / system:
CLI on PATH (foropenclaw
and continue-on-error);ensure --apply
andlsof
(macOS/Unix);ps
on macOS when using the LaunchAgent install scripts.launchctl - Environment (optional):
— OpenClaw home directory (default:OPENCLAW_HOME
).~/.openclaw
— Path or name ofOPENCLAW_BIN
binary (default:openclaw
).openclaw
Privileged actions (what you accept)
This skill may: read and modify
(including writing openclaw.json
gateway.auth when missing or wrong); write state and log files under OPENCLAW_HOME/logs/; restart the gateway via the OpenClaw CLI; and, if the watcher is installed, invoke openclaw agent --message continue --deliver automatically when a run error is detected. These are privileged local actions; run only if you accept them.