AgentSkillsCN

openclaw-dev-harness

为构建和调试扩展(插件、钩子、技能)而搭建并管理一个隔离的 OpenClaw 开发环境。当有人希望开发 OpenClaw 插件、创建钩子、测试扩展、调试网关、生成新扩展的脚手架,或搭建 OpenClaw 开发工具链时,请使用此模板。该模板将在提及“openclaw”、“openclaw 插件”、“openclaw 扩展”、“openclaw 钩子”、“openclaw 开发”、“openclaw 测试工具链”、“openclaw 调试”或“openclaw TUI 开发”时触发。

SKILL.md
--- frontmatter
name: openclaw-dev-harness
description: Set up and manage an isolated OpenClaw development environment for building and debugging extensions (plugins, hooks, skills). Use when someone wants to develop OpenClaw plugins, create hooks, test extensions, debug the gateway, scaffold new extensions, or set up an OpenClaw dev harness. Triggers on mentions of "openclaw", "openclaw plugin", "openclaw extension", "openclaw hook", "openclaw dev", "openclaw test harness", "openclaw debugging", or "openclaw TUI development".

OpenClaw Dev Harness

Set up an isolated --dev environment for extension development with TUI as the primary interaction surface.

Quick Start

bash
# 1. Set up isolated dev environment
bash scripts/setup-harness.sh

# 2. Start dev gateway (terminal 1)
bash scripts/dev-gateway.sh

# 3. Open TUI (terminal 2)
bash scripts/dev-tui.sh

# 4. Scaffold an extension
bash scripts/scaffold-extension.sh my-plugin --type plugin

Architecture

OpenClaw's --dev flag isolates all state under ~/.openclaw-dev/ with gateway on port 19001. Extensions load from the dev workspace at ~/.openclaw-dev/workspace/extensions/.

Three extension types:

  • Plugins: Gateway-resident code (RPC methods, CLI commands, services, agent tools, channels)
  • Hooks: Event-driven TypeScript handlers (command events, agent lifecycle, gateway startup)
  • Skills: SKILL.md-based knowledge extensions

Workflow

Initial Setup

Run scripts/setup-harness.sh to create the dev environment. Options:

  • --reset: Wipe existing dev state first
  • --auth-choice <choice>: Set auth provider (default: skip)
  • --port <port>: Gateway port (default: 19001)

For authenticated testing, pass your provider:

bash
bash scripts/setup-harness.sh --auth-choice setup-token

Develop Extensions

Scaffold with scripts/scaffold-extension.sh <name> --type <plugin|hook|skill>.

Edit the generated files, then restart the gateway to pick up changes:

bash
openclaw --dev gateway restart

Or run the gateway in foreground for live output:

bash
bash scripts/dev-gateway.sh

Test via TUI

Open scripts/dev-tui.sh to interact with extensions through the TUI. Key shortcuts:

ActionKey
Send messageEnter
Stop runEsc
Model pickerCtrl+L
Agent pickerCtrl+G
Toggle tool outputCtrl+O
Toggle thinkingCtrl+T

TUI slash commands: /status, /help, /agent <id>, /session <key>, /new, /debug.

Prefix lines with ! to run shell commands directly from TUI.

Debug

Run scripts/debug-session.sh to collect diagnostics. Options:

  • --deep: Include security audit and deep doctor scan
  • --logs <n>: Number of log lines (default: 50)

Enable raw stream debugging for protocol-level inspection:

bash
OPENCLAW_RAW_STREAM=1 openclaw --dev gateway --port 19001 --verbose

Test RPC methods directly:

bash
openclaw --dev gateway call pluginId.action --params '{}'

Run Tests

For plugin unit tests (Vitest):

bash
npx vitest run ~/.openclaw-dev/workspace/extensions/my-plugin/my-plugin.test.ts

For gateway-level validation:

bash
openclaw --dev doctor --non-interactive
openclaw --dev plugins doctor
openclaw --dev hooks check

Key Paths

PathPurpose
~/.openclaw-dev/Dev state root
~/.openclaw-dev/workspace/extensions/Plugin source
~/.openclaw-dev/workspace/hooks/Hook source
~/.openclaw-dev/workspace/skills/Skill source
~/.openclaw-dev/openclaw.jsonDev config
~/.openclaw-dev/credentials/Auth profiles

References

Scripts

ScriptPurpose
scripts/setup-harness.shInitialize dev environment
scripts/dev-gateway.shStart gateway in dev mode
scripts/dev-tui.shConnect TUI to dev gateway
scripts/scaffold-extension.shScaffold plugin/hook/skill
scripts/debug-session.shCollect diagnostics