Run a single prompt and exit

headless and scripting

// what it does

grok -p "..." (long form --prompt) processes one prompt, prints the result, and exits without opening the UI — the mode for scripts, cron jobs, and benchmarks. Combine it with -d to run against a specific project directory.

// shell

$ grok -p "show me the package.json file"
$ grok --prompt "run bun test and summarize failures" -d /path/to/project

// gotcha

Headless mode still runs tools: it can edit files and run bash, so a prompt like "fix the failing test" modifies your working tree non-interactively. Scope the prompt tightly, and consider running it on a branch.

// resources