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
# macOS / Linux / WSL
curl -fsSL https://x.ai/cli/install.sh | bashWindows PowerShell:
irm https://x.ai/cli/install.ps1 | iexgrok --version
# e.g. grok 0.2.112 … [stable]
grok updateOfficial product pages: x.ai/cli · docs: docs.x.ai/build
Auth
| Mode | How |
|---|---|
| Browser (default) | grok → first launch opens OAuth |
| API key | export XAI_API_KEY="xai-..." then grok |
| CLI login | grok login / grok logout |
Subscription note (product marketing): SuperGrok / X Premium Plus tiers apply for some installs — check x.ai if auth fails.
First run
cd ~/code/my-project # prefer Linux FS on WSL, not /mnt/c
grokUseful first prompts:
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
# 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)
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:
grok inspectCommon 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
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
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 HEADSkills & toolkit
- Agent playbooks: apsolut-skills
- Vault / project notebook: apsolut-seshat
- Browser QA for agents: agent-browser
Next
- Grok Build advanced — permissions, sandbox, plugins, MCP, CI, worktrees, privacy
- Official: Modes & commands · Headless · Skills / plugins