Grok CLI cheat sheet
Every command, flag and slash command for grok — xAI's official Grok Build CLI — fullscreen TUI, git worktrees, MCP, powered by grok-build / grok-4.5. 15+ commands, verified July 2026.
Two grok binaries exist — this is xAI's official Grok Build CLI. The community superagent-ai/grok-cli (now the grok-dev npm package) is unaffiliated and also uses grok, so don't install both globally.
curl -fsSL https://x.ai/cli/install.sh | bash # macOS / Linux
irm https://x.ai/cli/install.ps1 | iex # Windows (PowerShell)
npm install -g @xai-official/grok # npm (no x.ai host — good for CI)
grok update · grok version
grok # interactive fullscreen TUI
grok login # browser sign-in (grok login --device-auth for headless)
export XAI_API_KEY="xai-…" # API-key auth for CI, then: grok
grok -p "query" # headless: one prompt, then exit
grok -p "…" --output-format json
grok -c # continue the most recent session
grok -r <ID> # resume a session
Key flags
| Flag | What it does |
|---|---|
-p, --single <prompt> | Headless: send one prompt, then exit |
--output-format <fmt> | plain · json · streaming-json |
-m, --model <model> | e.g. grok-build, grok-4.5 |
-c, --continue / -r, --resume [id] | Continue / resume sessions |
-w, --worktree [name] | Start the session in a new git worktree |
--always-approve (--yolo) | Auto-approve all tool executions |
--sandbox <profile> | off · workspace · read-only · strict |
--max-turns <n> | Cap agent turns |
In-session commands
| Command / key | What it does |
|---|---|
/help · /new (/clear) | Help · new session |
/model <name> (/m) · /effort | Switch model · reasoning effort |
/plan [desc] · /always-approve | Plan mode · toggle auto-approve |
/context · /compact · /rewind | Context usage · compact · rewind |
/mcps · /skills · /plugins · /hooks | Extensions modal |
/remember <note> · /memory | Cross-session memory |
Shift+Tab · Ctrl+P / ? · ! | Cycle mode · palette · shell mode |
~/.grok/config.toml # user (GROK_HOME defaults to ~/.grok)
.grok/config.toml # project ([mcp_servers], [plugins], [permission] only)
export XAI_API_KEY="xai-…" # GROK_DEFAULT_MODEL, GROK_SANDBOX also honored
grok inspect # show which config / rules / MCP loaded
grok -p "Run the test suite and summarize failures" --output-format json
grok -p "Fix the type errors in src/ and update tests" --always-approve --max-turns 40
grok -w refactor-auth --ref main -p "Extract auth into its own module"
grok agent stdio # run as an ACP agent for your editor
More CLI cheat sheets
Stop memorizing flags
Run Grok CLI — and every other agent — from one app
TheVibeFather orchestrates Grok CLI alongside every other coding CLI in one native macOS app. Bring the models you already pay for; keep your keys.
Claude Code
Gemini CLI
Aider
Goose
Qwen Code
Crush
OpenHands CLI
Cline CLI
Roo Code CLI
Continue CLI