Machine-readable contract を選ぶ
-p で一回の headless prompt を送ります。plain は人向け、json は最後に一 object、streaming-json は処理中に newline-delimited events を出します。
prose を scrape せず fields を解析します。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 を設定し、job に必要な tools だけを許可します。enforced sandbox と deny policy が全 side effect を許容可能にしない限り always-approve を避けます。
scripts と ACP jobs では --no-auto-update を渡し、background update が再現 run を変えないようにします。多段 job は明示 ID で resume し、artifact は redaction 後だけ保存します。
- runner image を pin し 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/prompt を text とせず session/update chunks を消費します。
stdout を protocol framing、stderr を diagnostics に分けます。IDE、bot、orchestration service へ埋め込む前に request IDs、timeouts、cancellation、process cleanup、permission strategy を実装します。
grok --no-auto-update agent stdio