Automate Grok inside a CI pipeline

headless and scripting

// what it does

For CI, set GROK_API_KEY from a secret, run in headless mode with -p, point it at the checkout with -d, and cap work with --max-tool-rounds. Because headless mode is non-interactive, it fits build steps, terminal benchmarks, and batch jobs.

// shell

$ grok -p "review the staged diff and flag risky changes" -d . --max-tool-rounds 25

// gotcha

There is no approval prompt in CI, so a prompt that edits files or runs bash does so unattended. Restrict it to read-only analysis, or commit results to a branch and open a PR for human review rather than pushing to main.

// resources