Grok WorldGrok Build CLI field station

GROK BUILD CLI / 11

在 headless CI 與 ACP client 自動化 Grok

移除 TUI 也等於移除人工 permission loop;automation 必須以明確 policy、structured output 與 failure handling 取代它。

CHANNEL自動化 / 進階 / 12 MIN
來源核對日期2026-07-26
ORIGINOFFICIAL DOCS / PRIMARY

選擇 machine-readable contract

用 -p 送出單次 headless prompt。plain 適合人讀、json 在最後輸出一個 object、streaming-json 則隨工作進度送出 newline-delimited events。

解析 fields,不要 scrape prose。記錄 exit status、stderr、output completeness 與回傳 session ID;在外層 runner 設定 time 與 turn bounds。

grok -p "List TODO comments" --output-format json
grok -p "Explain the architecture" --output-format streaming-json

建立 non-interactive safety envelope

從 runner secret store 認證、設定 exact working directory,且只 allow job 需要的 tools。除非 enforced sandbox 與 deny policy 已讓所有可能副作用都可接受,否則避免 always-approve。

Scripts 與 ACP jobs 要加 --no-auto-update,避免 background update 改變可重現 run。多步工作以明確 ID resume,artifacts 經 redaction 後才保存。

  • Pin runner image 並記錄 grok version。
  • Audit 使用 read-only 或 strict sandbox。
  • 無法互動要求 permission 時採 fail closed。
grok --no-auto-update --cwd /path/to/repo --sandbox read-only -p "Audit authentication boundaries" --output-format json

當 application 擁有 UI 時使用 ACP

grok agent stdio 會在 stdin/stdout 上啟動 Agent Client Protocol JSON-RPC server。Client 需 initialize、authenticate、建立 session、送 prompt 並消費 session/update chunks;session/prompt 回傳本身不是 assistant text。

stdout 只保留 protocol framing,diagnostics 送 stderr。把 agent 嵌入 IDE、bot 或 orchestration service 前,加入 request IDs、timeouts、cancellation、process cleanup 與 permission strategy。

grok --no-auto-update agent stdio