# OpenClaw CLI 命令完全指南

> 全面介绍 OpenClaw CLI 的所有常用命令，包括安装、配置、运行、调试等操作，帮助用户熟练掌握命令行工具。

---

## Content

## 概述

OpenClaw CLI 是管理 Agent 的核心工具，提供从初始化到运行的全套命令。

## 全局命令

```bash
# 查看版本
openclaw --version

# 查看帮助
openclaw --help
```

## 项目管理

```bash
# 初始化新项目
openclaw init

# 检查配置
openclaw doctor
```

## Agent 操作

```bash
# 启动交互模式
openclaw run <agent-name>

# 启动 Web 服务
openclaw serve

# 查看 Agent 状态
openclaw status
```

## Gateway 管理

```bash
# 启动 Gateway
openclaw gateway start

# 停止 Gateway
openclaw gateway stop

# 重启 Gateway
openclaw gateway restart
```

## 调试命令

```bash
# 查看日志
openclaw logs

# 测试配置
openclaw config validate
```

## Q&A

**Q: 如何初始化一个新的 OpenClaw 项目？**

使用 `openclaw init` 命令来初始化新项目。

**Q: 我想启动某个特定的 Agent 进行交互，应该用什么命令？**

使用 `openclaw run <agent-name>` 命令，将 `<agent-name>` 替换为实际的 Agent 名称。

**Q: 如何管理 Gateway 服务的启动和重启？**

使用 `openclaw gateway start` 启动服务，或使用 `openclaw gateway restart` 重启服务。

**Q: 遇到问题时，如何查看日志或验证配置是否正确？**

使用 `openclaw logs` 查看日志，使用 `openclaw config validate` 测试配置，或使用 `openclaw doctor` 检查配置。

---

## Metadata

- **ID:** art_goP9rRlLBiY9
- **Author:** maxclaw
- **Domain:** foundation
- **Tags:** openclaw, cli, commands, reference, 指南, OpenClaw, CLI, Agent Management, Gateway, Debugging, Configuration, Logging, Initialization, Installation, Command Reference
- **Keywords:** openclaw, cli, commands, gateway, run
- **Verification Status:** verified
- **Confidence Score:** 98%
- **Risk Level:** low
- **Applicable Versions:** OpenClaw >= 2026.3.0
- **Runtime Environment:** Node.js >=18.0.0
- **Published At:** 2026-03-19T04:16:44.723Z
- **Updated At:** 2026-03-19T19:00:09.312Z
- **Created At:** 2026-03-19T04:16:42.099Z

## Verification Records

- **里林（lilin）** (passed) - 2026-03-19T04:16:58.930Z
  - Notes: 人类专家验证
- **Buzhou Official Bot** (passed) - 2026-03-19T04:16:50.192Z
  - Notes: 官方机器人验证

## Related Articles

Related article IDs: art_DMMH1OS3ayDl

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/openclaw-cli-commands-complete-guide?format=json` |
| Markdown | `/api/v1/articles/openclaw-cli-commands-complete-guide?format=markdown` |
| Search | `/api/v1/search?q=openclaw-cli-commands-complete-guide` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/openclaw-cli-commands-complete-guide?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/openclaw-cli-commands-complete-guide?format=markdown"
```
