OpenClaw Commands とは何ですか? (そしてなぜドキュメントだけでは十分ではないのか)
OpenClaw の公式ドキュメントは詳細です。また、午後 11 時にエージェントがダウンし、10 秒以内に正確なフラグ構文が必要な場合ではなく、完全性を重視して構造化されています。
OpenClaw コマンドは、OpenClaw エージェント ランタイムへの CLI インターフェイスです。OpenClaw エージェント ランタイムは、メッセージング チャネル、ブラウザー、ファイル、外部 API にわたるワークフローを自動化する AI エージェントを展開するためのプラットフォームです。 CLI は、初期セットアップから運用監視までのすべてをカバーします。
このガイドでは、公式ドキュメントに記載されていないことを行っています。つまり、コマンドを次のように整理しています。 やるべき仕事では、スクリプトの出力形式について説明し、実際の自動化パイプラインでコマンドがどのように連鎖するかを示します。
60 秒でわかる OpenClaw CLI アーキテクチャ
OpenClaw CLI は、標準の 3 レベルの階層に従います。
openclaw <command> <subcommand> [flags]
- Entry point:
openclaw - Commands: 名詞グループ (
gateway、agent、channel、skill、model、browser、file) - Flags: 動作を変更します。グローバルまたはコマンド固有にすることができます。
構成ファイルの優先順位 (最高から最低)
- 直接渡される CLI フラグ
- 環境変数 (
OPENCLAW_*) - ローカル構成ファイル (
.openclaw/config.json) - グローバル構成 (
~/.openclaw/config.json)
openclaw config show を使用すると、解決された構成を実行時にいつでも検査できます。
グローバル フラグのリファレンス
| フラグ | タイプ | Default | 説明 |
|---|---|---|---|
| --config | 弦 | ~/.openclaw/config.json | Path to config file |
| - プロフィール | 弦 | デフォルト | Named config profile to use |
| - 出力 | 弦 | 無地 | Output 形式: plain、json、table |
| --ログレベル | 弦 | 情報 | Log verbosity: debug、info、warn、error |
| --色なし | ブール | 間違い | Disable ANSI color output |
| - 静かな | ブール | 間違い | Suppress non-essential output |
| - タイムアウト | 整数 | 30 | Command timeout in seconds |
| --ワークスペース | 弦 | ./ワークスペース | Override workspace directory path |
| --ドライラン | ブール | 間違い | Preview actions without executing |
| - はい | ブール | 間違い | Skip confirmation prompts |
コア コマンド リファレンス (実行するジョブごとにグループ化)
インストール、初期化および構成コマンド
# Install OpenClaw CLI (npm) npm install -g openclaw # Initialize a new project with guided setup openclaw init # Initialize non-interactively with defaults openclaw init --yes --profile production # Show current resolved configuration openclaw config show # Set a config value openclaw config set gateway.port 8080 # Get a specific config value openclaw config get gateway.port # Generate a blank config file template openclaw config init --output .openclaw/config.json # Validate current config file openclaw config validate # List all environment variable overrides in effect openclaw config env
Environment variable pattern: 構成キーの前に OPENCLAW_ を付け、ネストにはアンダースコアを使用します。例: OPENCLAW_GATEWAY_PORT=8080。
ゲートウェイおよびエージェント管理コマンド
ゲートウェイは HTTP/WebSocket ホスト プロセスです。エージェントは、管理されるタスクを実行するワーカーです。
# Start the gateway (foreground) openclaw gateway start # Start gateway as background daemon openclaw gateway start --daemon # Stop the gateway openclaw gateway stop # Restart the gateway (applies config changes) openclaw gateway restart # Check gateway status openclaw gateway status # Stream gateway logs openclaw gateway logs --follow # Tail last N lines openclaw gateway logs --tail 100 # List all registered agents openclaw agent list # Start a specific agent openclaw agent start my-agent # Stop an agent gracefully openclaw agent stop my-agent # Force-kill an unresponsive agent openclaw agent stop my-agent --force # View agent runtime status and uptime openclaw agent status my-agent # Stream logs for a specific agent openclaw agent logs my-agent --follow # Reload agent config without full restart openclaw agent reload my-agent
チャネル セットアップ コマンド (Telegram、WhatsApp、Discord、Google チャット、Synology)
更新されました v2026.4.21 構文 — --provider フラグは、2026 年以前のビルドの従来の --type フラグを置き換えることに注意してください。
# List all configured channels openclaw channel list # Add a Telegram channel openclaw channel add --provider telegram --token YOUR_BOT_TOKEN --name my-telegram # Add a WhatsApp channel (via WhatsApp Cloud API) openclaw channel add --provider whatsapp --token YOUR_TOKEN --phone-id YOUR_PHONE_ID --name my-whatsapp # Add a Discord channel openclaw channel add --provider discord --token YOUR_BOT_TOKEN --guild-id YOUR_GUILD_ID --name my-discord # Add Google Chat channel openclaw channel add --provider google-chat --credentials ./service-account.json --space-id YOUR_SPACE --name my-gchat # Add Synology Chat channel openclaw channel add --provider synology --webhook-url YOUR_WEBHOOK_URL --name my-synology # Test a channel connection openclaw channel test my-telegram # Remove a channel openclaw channel remove my-telegram # Update channel config (e.g., rotate token) openclaw channel update my-telegram --token NEW_TOKEN # Enable/disable a channel without removing it openclaw channel disable my-telegram openclaw channel enable my-telegram
スキルとモデル管理コマンド
# List installed skills openclaw skill list # Search the skill registry openclaw skill search "web scrape" # Install a skill openclaw skill install web-scraper # Install a specific version openclaw skill install web-scraper@2.1.0 # Update a skill openclaw skill update web-scraper # Update all skills openclaw skill update --all # Remove a skill openclaw skill remove web-scraper # Show skill details and required config openclaw skill info web-scraper # List available models openclaw model list # Set the default model openclaw model use gpt-4o # Set model for a specific agent openclaw model use claude-3-7-sonnet --agent my-agent # Show current model config openclaw model show
ブラウザ制御およびシェル実行コマンド
ここが、OpenClaw がより単純なエージェント プラットフォームと異なる点です。ブラウザとシェルのコマンドにより、CLI を離れることなく、真のエンドツーエンドの自動化が可能になります。
# Launch a managed browser session openclaw browser open --url https://example.com --session my-session # Take a screenshot openclaw browser screenshot --session my-session --output ./screenshot.png # Execute JavaScript in the browser context openclaw browser exec --session my-session --script "document.title" # Click an element by CSS selector openclaw browser click --session my-session --selector "#submit-btn" # Fill a form field openclaw browser fill --session my-session --selector "#email" --value "user@example.com" # Extract page content openclaw browser extract --session my-session --selector "article.main" --format text # Close a browser session openclaw browser close --session my-session # Run a shell command through the OpenClaw runtime openclaw shell exec --cmd "python process.py --input data.json" # Run shell command with timeout openclaw shell exec --cmd "npm run build" --timeout 120 # List active shell processes openclaw shell list
Note: ブラウザ セッションは --session ID ごとに分離されます。状態 (Cookie、認証トークン、ページ コンテキスト) を維持するために、コマンド間で同じセッション ID を再利用します。
ファイルとワークスペースの管理コマンド
# List workspace files openclaw file list # Read a file from the workspace openclaw file read output/report.md # Write content to a workspace file openclaw file write output/result.txt --content "processed" # Copy a file within the workspace openclaw file copy input/raw.json output/processed.json # Delete a workspace file openclaw file delete output/temp.json # Watch a file for changes (useful in pipelines) openclaw file watch output/result.txt --on-change "openclaw agent trigger my-agent" # Export workspace to a zip archive openclaw workspace export --output ./backup.zip # Import workspace from archive openclaw workspace import --input ./backup.zip
実際のワークフローの例 (コマンド チェーン)
コンテンツ パイプラインをエンドツーエンドで自動化する
このパイプラインは、URL をスクレイピングし、LLM を通じてコンテンツを処理し、結果を Telegram チャネルにポストします。これらはすべて単一のシェル スクリプトから行われます。
#!/bin/bash set -e TARGET_URL="https://example.com/news" CHANNEL="my-telegram" WORKSPACE_OUT="output/summary.md" # Step 1: Scrape the page openclaw browser open --url "$TARGET_URL" --session scrape-session openclaw browser extract --session scrape-session --selector "article" \\ --format text > workspace/input/raw.txt openclaw browser close --session scrape-session # Step 2: Process with LLM via agent openclaw agent trigger content-summarizer \\ --input workspace/input/raw.txt \\ --output "$WORKSPACE_OUT" \\ --wait # Step 3: Post result to Telegram SUMMARY=$(openclaw file read "$WORKSPACE_OUT") openclaw channel send "$CHANNEL" --message "$SUMMARY" echo "Pipeline complete."
Cron + OpenClaw コマンドを使用したタスクのスケジュール設定
ほとんどのチームは、必要よりもはるかに遅れて cron に到達します。コピー&ペーストのパターンは次のとおりです。
# Run a daily content pipeline at 7am 0 7 * * * /usr/local/bin/openclaw agent trigger daily-report --wait --quiet >> /var/log/openclaw-cron.log 2>&1 # Restart gateway every Sunday at 2am (maintenance window) 0 2 * * 0 /usr/local/bin/openclaw gateway restart --yes >> /var/log/openclaw-restart.log 2>&1 # Health check every 5 minutes, alert if failing */5 * * * * /usr/local/bin/openclaw gateway status --output json | \\ grep -q '"status":"running"' || \\ /usr/local/bin/openclaw channel send ops-alerts --message "Gateway DOWN"
Idempotency tip: --dry-run を使用して、スケジュールする前に cron コマンドの動作を確認します。対話型プロンプトをスキップするには、すべての cron コマンドに --yes を追加します。ログ内のフラグ エラーをキャッチするには、常に stderr を stdout (2>&1) と一緒にリダイレクトしてください。
スクリプトと CI/CD の統合
出力形式と終了コード
すべての OpenClaw コマンドは、機械可読出力の --output json をサポートしています。
# Get agent status as JSON
openclaw agent status my-agent --output json
# Example output:
# {"agent":"my-agent","status":"running","uptime":3842,"pid":19204}
終了コード
| コード | 意味 |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Config or flag validation failure |
| 3 | Agent/gateway not reachable |
| 4 | Timeout exceeded |
| 5 | Permission denied |
シェル スクリプトと GitHub アクションへのパイプ処理
# Check agent health and branch on status STATUS=$(openclaw agent status my-agent --output json --quiet | jq -r '.status') if [ "$STATUS" != "running" ]; then openclaw agent start my-agent fi
GitHub Actions example:
- name: Trigger OpenClaw content agent
run: |
openclaw agent trigger content-agent \\
--input ./keywords.json \\
--output ./output/article.md \\
--wait \\
--timeout 300 \\
--output-format json
env:
OPENCLAW_API_KEY: \ secrets.OPENCLAW_API_KEY
OPENCLAW_GATEWAY_URL: \ secrets.OPENCLAW_GATEWAY_URL
本番環境でのセキュリティと権限
マルチユーザー環境またはサーバー環境で OpenClaw を実行するには、意図的な権限スコープ設定が必要です。デフォルトはローカル開発用に最適化されています。
# Generate a scoped API key (read-only) openclaw auth key create --name ci-readonly --scopes "agent:read,channel:read" # Generate a key with specific agent access only openclaw auth key create --name deploy-bot --scopes "agent:trigger:my-agent" # List active API keys openclaw auth key list # Revoke a compromised key immediately openclaw auth key revoke KEY_ID # Store API key in system keychain (avoid plaintext in config) openclaw config set-secret api_key YOUR_KEY # Restrict workspace file access openclaw config set security.workspace_isolation true # Disable shell execution in production (if not needed) openclaw config set security.allow_shell_exec false # Enable audit logging openclaw config set logging.audit true openclaw config set logging.audit_path /var/log/openclaw/audit.log
生産チェックリスト
ユースケースで明示的に必要でない限り、security.allow_shell_exec false を設定します。
API キーを生成するときは --scopes を使用します。CI/CD ではルート キーを決して使用しないでください。
最初の運用展開の前に logging.audit を有効にします。
暴露の疑いがある場合は、openclaw auth key revoke + openclaw auth key create を使用してキーをローテーションします。
Troubleshooting: 症状 → コマンド修正デシジョン ツリー
エージェントが応答しない
openclaw agent status my-agent → status: "stopped" → openclaw agent start my-agent → status: "error" → openclaw agent logs my-agent --tail 50 → status: "running" but unresponsive → openclaw agent stop my-agent --force && openclaw agent start my-agent
チャネルがメッセージを受信しない
openclaw channel test my-telegram → connection failed → openclaw channel update my-telegram --token NEW_TOKEN → connection ok but no messages → openclaw gateway logs --follow (check routing errors) → 403 error → check token scopes, re-add channel
スキルが読み込まれていません
openclaw skill info my-skill → not installed → openclaw skill install my-skill → version conflict → openclaw skill update my-skill → config missing → openclaw skill info my-skill (check required fields), then openclaw config set
ゲートウェイが起動しない
openclaw config validate → invalid config → fix reported field, retry → port conflict → openclaw config set gateway.port 8081 → permission error → check OPENCLAW_ env vars, run openclaw config env
v2026.4.21 での変更点 — 2026 年以前のビルドとのコマンドの相違点
2026 年 1 月または 2 月の日付のチートシートに基づいて作業している場合、これらの変更によりスクリプトが破損します。
| エリア | 古い構文 (2026 年 4 月より前) | 新しい構文 (v2026.4.21) |
|---|---|---|
| Channel add | --タイプ電報 | --プロバイダー電報 |
| Model switch | openclaw エージェントモデルの使用 | openclaw モデルの使用 --agent |
| Shell execute | openclaw 実行シェル | オープンクローシェル実行ファイル |
| Key creation | openclaw 認証作成キー | openclaw 認証キーの作成 |
| Output flag | --json の形式 | --出力json |
| Config secrets | openclaw 設定セットキー | openclaw 設定セット-シークレット |
v2026.4.21 の新機能
openclaw file watchコマンド (ファイル変更トリガー)--dry-runグローバル フラグがすべての変更コマンドに追加されましたsecurity.workspace_isolation設定キーlogging.auditによる監査ログopenclaw channel disable/openclaw channel enable(以前は完全な削除と再追加が必要でした)
非推奨 (v2026.4.21 で削除)
openclaw agent reload --hard—openclaw agent stop --force && openclaw agent startを使用しますopenclaw config get-all—openclaw config showに置き換えられました
最終リファレンス: 印刷可能な OpenClaw Commands チートシート
| 指示 | 構文 | キー Flags | 例 |
|---|---|---|---|
| Init project | オープンクロー初期化 | --はい、--プロフィール | openclaw 初期化 --はい |
| Show config | オープンクロー構成ショー | --出力json | オープンクロー構成ショー |
| Start gateway | オープンクローゲートウェイの開始 | - デーモン | openclaw ゲートウェイの開始 --daemon |
| Agent status | オープンクローエージェントのステータス | --出力json | openclaw エージェントのステータス my-agent --output json |
| Agent logs | openclaw エージェントのログ | --フォロー、--テール | openclaw エージェントのログ my-agent --tail 50 |
| Add channel | オープンクローチャンネル追加 | --プロバイダー、--トークン | openclaw チャネルの追加 --provider telegram --token XXX |
| テストチャンネル | オープンクローチャンネルテスト | — | openclaw チャネル テスト my-telegram |
| Send message | オープンクローチャンネル送信 | - メッセージ | openclaw チャネルが私の電報を送信 -- メッセージ "完了" |
| Install skill | オープンクロースキルインストール | @バージョン | openclaw スキル インストール web-scraper@2.1.0 |
| Set model | オープンクローモデル使用 | - エージェント | openclaw モデルは gpt-4o --agent my-agent を使用します |
| Browser open | openclaw ブラウザを開く | --url、--session | openclaw ブラウザを開く --url https://example.com --session s1 |
| Extract content | openclaw ブラウザの抽出 | --セレクター、--フォーマット | openclaw ブラウザ抽出 --session s1 --selector "article" |
| Run shell cmd | オープンクローシェル実行ファイル | --cmd、--タイムアウト | openclaw シェル exec --cmd "python run.py" |
| Read file | openclaw ファイルが読み取られました | — | openclaw ファイル読み取り出力/result.md |
| Trigger agent | オープンクローエージェントトリガー | --input、--output、--wait | openclaw エージェント トリガー パイプライン --wait |
| Create API key | openclaw 認証キーの作成 | --name、--scopes | openclaw 認証キー create --name ci --scopes "agent:read" |
| Validate config | openclaw 設定の検証 | — | openclaw 設定の検証 |
EasyClaw がエージェント ワークフローを実行するためのより賢い方法である理由
OpenClaw は、強力な CLI プリミティブを提供します。 EasyClaw は、真夜中に bash スクリプトをつなぎ合わせることなく、これらのパイプライン (ブラウザ自動化、LLM 処理、チャネル配信) を実行するデスクトップネイティブ AI エージェント層を提供します。
- OpenClaw プリミティブ上のビジュアル パイプライン ビルダー
- ローカルで実行 — クラウド ベンダーのロックインやシートごとの価格設定はありません
- 組み込みのスキル マーケットプレイス: 数秒でインストール、構成、実行
- すぐに使用できるネイティブ スケジュール、再試行ロジック、監査ログ
- GPT-4o、Claude、Gemini、または独自のセルフホスト LLM など、あらゆるモデルで動作します。
よくある質問
質問: openclaw ゲートウェイの開始と openclaw エージェントの開始の違いは何ですか?
A: ゲートウェイは、HTTP/WebSocket ランタイムを管理するホスト プロセスです。一度始めてみましょう。エージェントは、そのゲートウェイに登録された個々のタスク ワーカーであり、エージェントは個別に開始、停止、監視を行います。ゲートウェイをサーバー、エージェントをその上で実行されるアプリケーション プロセスと考えてください。
質問: v2026.4.21 にアップグレードした後、スクリプトが壊れました。何が変わったのでしょうか?
A: いくつかのコマンド シグネチャが v2026.4.21 で変更されました。最も一般的な破壊的変更は、チャネル追加の場合は --type → --provider、グローバルの場合は --format json → --output json、および openclaw exec shell → openclaw shell exec です。上記の変更ログセクションにある完全な差分テーブルを参照してください。
質問: CI/CD パイプラインで OpenClaw コマンドを非対話的に実行するにはどうすればよいですか?
A: --yes フラグを追加して確認プロンプトをスキップし、マシン解析可能な出力に --output json を使用し、OPENCLAW_API_KEY および OPENCLAW_GATEWAY_URL 環境変数を介して資格情報を渡します。バージョン管理にコミットされた構成ファイルには生のキーを決して保存しないでください。
質問: 既存の認証済みセッションで OpenClaw ブラウザ コマンドを使用できますか?
A: はい。ブラウザ セッションは --session ID によって分離されます。コマンド間で同じセッション ID を再利用する限り、Cookie、認証トークン、およびページの状態は保持されます。セッションは、明示的に openclaw browser close --session SESSION_ID を呼び出すか、ゲートウェイが再起動するまで持続します。
質問: 本番環境で API キーのローテーションを処理する最も安全な方法は何ですか?
A: まず openclaw auth key create --name new-key --scopes "..." で新しいキーを作成し、シークレット ストアを更新して、新しいキーが機能することを確認してから、openclaw auth key revoke OLD_KEY_ID で古いキーを取り消します。新しいキーが機能することを確認する前に、古いキーを決して取り消さないでください。
質問: cron でサイレントに失敗するパイプラインをデバッグするにはどうすればよいですか?
A: cron エントリでは、stdout と stderr の両方を常にリダイレクトしてください (>> /var/log/openclaw-cron.log 2>&1)。最初に --log-level debug を使用して正確な cron コマンドを手動で実行し、隠れたエラーを明らかにします。 openclaw config env を使用して、環境変数が cron 実行コンテキストで正しく解決されていることを確認します。
質問: CI/CD キーがトリガーできるエージェントを制限することはできますか?
A: はい。キーを作成するときに詳細なスコープを使用します: openclaw auth key create --name deploy-bot --scopes "agent:trigger:my-specific-agent"。これにより、侵害された CI キーが無関係のエージェントをトリガーしたり、チャネル構成にアクセスしたりすることが防止されます。
最終的な考え
OpenClaw CLI は、初回セットアップから本番環境のセキュリティ強化に至るまで、完全なランタイム コントロール サーフェスです。課題は決して能力ではありません。不都合な時間に何かが壊れたときに、どのコマンドを使用すればよいかを常に知っていました。
このページをブックマークしてください。クイックリファレンスとしてチートシートの表を使用してください。パイプラインに障害が発生した場合は、トラブルシューティング デシジョン ツリーから始めてください。1 分以内に適切なコマンドが表示されます。
実際のワークフローの構築よりもパイプライン スクリプトの保守に多くの時間を費やしていることに気付いた場合は、EasyClaw を試してみてください。EasyClaw はオーケストレーション層を処理するため、エージェントが実際に行うことに集中できます。
簡単な要約: Commands をブックマークするキー
openclaw config validate— ゲートウェイを再起動する前に常にこれを実行しますopenclaw agent logs my-agent --tail 50— エージェントが不正な動作をしたときに最初に停止するopenclaw channel test my-channel— ログを読んでチャネルの問題を確認するよりも速いopenclaw config show --output json— あらゆる環境で解決された構成を検証するopenclaw auth key revoke KEY_ID— キー漏洩の疑いに対する即時対応