How to Use Grok Build: Install, Login and Core Commands
By CodeAgentSwarm · Updated October 31, 2026
grok binary, authenticate, and work inside a project folder the same way you would with Claude Code or Codex CLI.
Three different products share the word Grok: the consumer Grok chatbot, xAI's official coding CLI called Grok Build (the grok command this guide is about), and unaffiliated community tools named grok-cli on GitHub. CodeAgentSwarm integrates Grok Build, not the chat app.
This guide covers install, first login, the flags you will actually use, session resume, and how CodeAgentSwarm runs Grok Build as a first-class agent next to the rest of your swarm.What is Grok Build?
Grok Build is the official coding CLI from xAI. It runs as an interactive TUI, as a headless one-shot command with grok -p, or as an ACP agent process for editor integrations. Its default model is Grok 4.7, and grok models lists the others your account can use. As of October 2026 releases are on the 1.0.x line, so grok --version prints a 1.0.x number.
Data lives under ~/.grok/ by default (config, auth, sessions, skills, rules). You can relocate the whole tree with the GROK_HOME environment variable. Skills follow the agentskills.io layout under ~/.grok/skills/, and MCP servers are configured in ~/.grok/config.toml.
Grok Build moves quickly. Install and auth details can change; when something disagrees with this page, prefer the official xAI CLI docs and grok --help on your machine.
Install Grok Build
The recommended path is the official install script. It works on macOS and Linux, and on Windows via Git Bash or the native PowerShell installer.
# macOS / Linux / Git Bash
curl -fsSL https://x.ai/cli/install.sh | bash
# Verify
grok --version# Windows PowerShell
irm https://x.ai/cli/install.ps1 | iexThe installer places the binary under ~/.grok/bin (or %USERPROFILE%\.grok\bin on Windows) and adds it to your PATH. Update later with grok update. xAI also publishes a WinGet package (xAI.GrokBuild) and an npm package (@xai-official/grok); if you install through WinGet, update with WinGet instead.
After install, run grok doctor to check terminal, clipboard and color support before your first long session.
First launch and authentication
From a project directory, run grok. On first launch the CLI opens a browser so you can sign in with your grok.com account. Credentials land in ~/.grok/auth.json and refresh automatically. On a server or over SSH, run grok login --device-auth and finish the sign-in on another device.
For CI or headless environments without a browser, set an API key instead:
export XAI_API_KEY="xai-..."
grok -p "Summarize this repository"Grok Build is available to try free, while paid xAI plans raise usage limits. Confirm current access before a team rollout and see the Grok Build pricing and access guide.
Commands and flags that matter
You do not need every flag. These are the ones that show up daily:
grok: start the interactive TUI in the current directorygrok "fix the flaky test": open the TUI with an initial promptgrok -p "..."(or--single): one-shot headless prompt to stdoutgrok --continue/-c: continue the most recent session for this cwdgrok --resume/-r: resume by session id or title, or the latest one if you pass nothinggrok --always-approve(alias--yolo): auto-approve tool runs, use carefullygrok --worktree=name: start in a new git worktreegrok --no-plan/--no-subagents: disable plan mode or native subagentsgrok sessions list/search: find past sessionsgrok export: export a transcript as Markdown
In the TUI, Shift+Tab cycles Normal, Plan, Auto (when available) and Always-approve. On the command line, --permission-mode takes auto, acceptEdits, dontAsk (deny anything not explicitly allowed, useful in CI) or bypassPermissions (the same as --always-approve). Plan Mode is covered in depth in the Plan Mode guide.
grok --help
grok doctor
grok sessions listRun Grok Build inside CodeAgentSwarm

CodeAgentSwarm is a desktop workspace that runs on top of the official CLIs. Install Grok Build on the machine, open CodeAgentSwarm, and choose Grok Build in the SELECT AI AGENT picker for that terminal. From there you get desktop notifications when a session finishes or needs input, searchable history across agents, live per-terminal diffs, and the ability to mix Grok Build with Claude Code, Codex, Antigravity, OpenCode and Kimi Code in one window.
That is different from Grok Build's own native subagents: those stay inside one vendor session. A CodeAgentSwarm swarm is several independent terminals you supervise. The Grok Build agent swarm guide and the subagents vs swarm comparison spell out the difference.
FAQ
Is Grok Build the same as the Grok chatbot?
No. Grok Build is xAI's coding CLI (the grok command). The Grok chatbot is a separate consumer product. CodeAgentSwarm integrates the CLI.
How do I install Grok Build?
On macOS and Linux run curl -fsSL https://x.ai/cli/install.sh | bash. On Windows PowerShell use irm https://x.ai/cli/install.ps1 | iex. Then run grok --version.
Does Grok Build work inside CodeAgentSwarm?
Yes. Install the CLI, pick Grok Build in the agent picker, and run it like any other supported agent with notifications, history and live diffs.
How do I resume a Grok Build session?
Use grok --continue for the latest session in the current directory, or grok --resume with a session id or title. grok sessions list helps you find them.