OpenClaw 模块 1:安装与首个 Agent

目标:从一台干净环境出发,完成 OpenClaw 初始化,并让一个 Agent 能正常收发一条测试消息。

建议在非生产环境先完整跑一遍。即便已经安装过 OpenClaw,也可以把本页当作 smoke test。

实操步骤(可直接执行)

每一步都先执行命令,再记录结果和问题。

步骤 1:Initialize OpenClaw config and workspace

执行:
openclaw setup
openclaw setup --workspace ~/.openclaw/workspace

预期:

  • ~/.openclaw/openclaw.json is created or updated.
  • A default agent workspace exists under ~/.openclaw/workspace (or the path you specified).
可复制命令
openclaw setup
openclaw setup --workspace ~/.openclaw/workspace
~/.openclaw/openclaw.json
~/.openclaw/workspace

步骤 2:Run the onboarding wizard (local gateway)

Run the interactive wizard:
openclaw onboard --flow quickstart

If you already know you want a remote gateway, use:
openclaw onboard --flow manual --mode remote --remote-url wss://gateway-host:18789

During the wizard:

  • Pick a provider/model (for example, OpenAI or a custom endpoint).
  • Accept the suggested defaults unless your org requires custom ports or auth.

If you need a fully non-interactive run (for CI or automation), adapt one of the examples in the official docs, e.g.:
openclaw onboard --non-interactive --auth-choice custom-api-key \
--custom-base-url "https://llm.example.com/v1" \
--custom-model-id "foo-large" \
--custom-api-key "$CUSTOM_API_KEY" \
--secret-input-mode plaintext --custom-compatibility openai

可复制命令
openclaw onboard --flow quickstart
openclaw onboard --flow manual --mode remote --remote-url wss://gateway-host:18789
openclaw onboard --non-interactive --auth-choice custom-api-key \ --custom-base-url "https://llm.example.com/v1" \ --custom-model-id "foo-large" \ --custom-api-key "$CUSTOM_API_KEY" \ --secret-input-mode plaintext --custom-compatibility openai

步骤 3:Run health checks with `openclaw doctor`

执行:
openclaw doctor

If issues are reported, let the CLI apply safe fixes:
openclaw doctor --repair

需要更深度检查时 (sandbox, channels, cron, secrets):
openclaw doctor --deep

You should continue only when doctor reports healthy status or warns only about items you understand and accept.

可复制命令
openclaw doctor
openclaw doctor --repair
openclaw doctor --deep

步骤 4:Create and inspect your first agent

List existing agents:
openclaw agents list

Create a new agent workspace:
openclaw agents add work --workspace ~/.openclaw/workspace-work

Inspect bindings (how channels map to agents):
openclaw agents bindings

If you already have a main workspace and just want to set identity:
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity

可复制命令
openclaw agents list
openclaw agents add work --workspace ~/.openclaw/workspace-work
openclaw agents bindings
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity

继续学习下一模块

建议把本页命令沉淀成团队 Runbook。

OpenClaw 模块 1: Setup & First Agent | BestClaw