Skip to content

Grok Build CLI ​

Starter xAI’s terminal coding agent (TUI + headless). Binary: grok.

This page was verified against Grok Build 0.2.112 (grok --version / grok --help). Flags and slash commands evolve — re-check on your install.

What's new: see Agent CLI game changers, checked against 1.0.70.

Install ​

bash
# macOS / Linux / WSL
curl -fsSL https://x.ai/cli/install.sh | bash

Windows PowerShell:

powershell
irm https://x.ai/cli/install.ps1 | iex
bash
grok --version
# e.g. grok 0.2.112 … [stable]
grok update

Official product pages: x.ai/cli · docs: docs.x.ai/build

Auth ​

ModeHow
Browser (default)grok → first launch opens OAuth
API keyexport XAI_API_KEY="xai-..." then grok
CLI logingrok login / grok logout

Subscription note (product marketing): SuperGrok / X Premium Plus tiers apply for some installs — check x.ai if auth fails.

First run ​

bash
cd ~/code/my-project   # prefer Linux FS on WSL, not /mnt/c
grok

Useful first prompts:

text
Explain this repo.
@src/main.ts Walk me through this file.

Inside the TUI, slash commands cover much of daily power use (/model, /doctor, /usage, …). Run grok doctor outside the TUI for terminal/tmux/clipboard checks.

Everyday ​

bash
# interactive (optional initial prompt)
grok
grok "fix the failing test"
grok --worktree=feat/login "add login form + tests"

# continue / resume
grok -c                          # most recent session for this cwd
grok -r                          # resume latest (or pass id/title)
grok -r "session title or uuid"

Headless (one-shot) ​

bash
grok -p "Explain this codebase"
grok -p "List public API entrypoints" --output-format json
grok -p "Summarize architecture" --output-format streaming-json
grok --prompt-file ./task.md

-p / --single prints to stdout and exits — good for scripts. Details: advanced.

Project context ​

Grok discovers project/user config, instructions, skills, plugins, hooks, and MCP for the cwd:

bash
grok inspect

Common instruction surfaces (names can vary by version — inspect is source of truth):

  • Repo guides such as AGENTS.md / CLAUDE.md-style instruction files
  • User config: ~/.grok/config.toml (Windows: %USERPROFILE%\.grok\config.toml)
  • Skills & plugins (see advanced + skills)

Models ​

bash
grok models
grok -m <model-id> -p "Hello"
# inside TUI:
/model <name>

Custom models can be defined under ~/.grok/config.toml ([model.*] + [models] default = "…"). After edits, grok inspect shows what was picked up. See docs.x.ai/build/overview.

Everyday loop ​

bash
git switch -c feat/thing
grok --worktree=feat/thing "implement thing, keep tests green"
# review diff
git add -A && git commit -m "feat: thing"
git push -u origin HEAD

Skills & toolkit ​

Next ​