Grok CLI: install, commands, models, and how it works

Most people searching "Grok CLI" mean the terminal coding agent xAI shipped in 2026. Its official product name is Grok Build, and the command you actually run is grok. Grok Build 1.0 left beta on 7 August 2026, and this guide covers the install, the auth paths, the model lineup, every verified flag, MCP support, and what it costs.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

Grok CLI refers to xAI's terminal coding agent, whose official product name is Grok Build and whose executable is grok. Install it with curl -fsSL https://x.ai/cli/install.sh | bash on macOS and Linux, or the PowerShell equivalent on Windows. It authenticates through a browser by default or an XAI_API_KEY for headless environments, runs on grok-4.5 by default, and supports headless scripting with grok -p, structured output with --json-schema, and MCP servers with grok mcp. Access rides a SuperGrok or X Premium+ subscription, or a separately billed API key.

What you need to know
  • The official product is Grok Build. The command you type is grok. "Grok CLI" is the common name, not the vendor name.
  • Install: curl -fsSL https://x.ai/cli/install.sh | bash on macOS and Linux, PowerShell script on Windows. No npm package for the official CLI.
  • Auth is browser OAuth by default, or set XAI_API_KEY for headless and CI environments.
  • The default model is grok-4.5. Run grok models to see what your account can actually reach.
  • Headless mode is grok -p "...", with --output-format json and --json-schema for structured, parseable output.
  • Access needs a SuperGrok or X Premium+ subscription, or a separately billed XAI_API_KEY. It is not free.

What "Grok CLI" actually is

xAI does not sell a product called "Grok CLI." Its terminal coding agent is officially Grok Build, and the binary it installs is grok. The names blur because the whole category trained people to expect one: Anthropic ships Claude Code, OpenAI ships the Codex CLI, and "the CLI named after the model" carried straight over to Grok. This guide says Grok CLI in the title because that is what people type into a search bar, and Grok Build in the body because that is what xAI calls it.

Grok Build launched in early beta on 14 May 2026, gated to SuperGrok Heavy. It opened to all SuperGrok and X Premium+ subscribers on 25 May 2026, and Grok Build 1.0 shipped on 7 August 2026, ending the beta. No model changed at that release. 1.0 bought stability and a wider command surface, nothing more.

The shape of the product, as of August 2026.

ThingDetail
Official nameGrok Build
Common nameGrok CLI
Binarygrok
VendorxAI
CategoryTerminal coding agent (same category as Claude Code, Codex CLI, Gemini CLI)
Status as of August 2026Grok Build 1.0, out of beta since 7 August 2026

Install Grok CLI

There is no npm package and no Homebrew formula for the official CLI as of August 2026. xAI ships a single install script per platform.

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

grok --version
Windows PowerShell
irm https://x.ai/cli/install.ps1 | iex

grok --version

The installer drops the binary on your PATH and registers a shell entry, so a fresh terminal window finds grok immediately. If it does not, restart your shell before you troubleshoot anything else. To update later, use the CLI's own updater rather than re-running the install script.

Check for updates, then apply one
grok update --check
grok update

Authenticate it

The first time you launch grok in interactive mode, it opens a browser window to complete OAuth sign-in against your xAI or X account. That account needs to carry a subscription tier that includes Grok Build access, covered below.

grok
# opens a browser for sign-in on first launch

Two situations break that flow: a remote box with no browser, and a script or CI job that must never block waiting for a human to click something.

SituationWhat to use
Local machine, first runDefault browser OAuth flow
Remote server, SSH sessiongrok login --device-auth, then open the printed URL locally
CI, scripts, headless boxesSet XAI_API_KEY as an environment variable
Explicit re-auth mid-session--oauth flag, or grok logout then sign in again
API key auth for headless environments
export XAI_API_KEY="your-key-here"
grok -p "list every TODO comment in this repository"

Models and reasoning effort

The default model is grok-4.5, xAI's flagship since its July 2026 release. Nothing locks the CLI to it. One command lists your account's full lineup, including any custom models you registered yourself.

grok models
grok -m <model-id> -p "your prompt"

Custom or self-hosted model endpoints can be registered in the CLI's own config file rather than passed on every command line.

~/.grok/config.toml
[models.custom]
# add non-default model endpoints here; see `grok models --help`

Reasoning effort is a separate dial from model choice. The documented levels are none, minimal, low, medium, high, xhigh, and max, but only the ones your selected model advertises are accepted. A model that does not support a level rejects the run rather than silently rounding down to something cheaper.

grok --effort high -p "explain the retry logic in internal/queue"
grok -m <model-id> --effort xhigh

Grok CLI commands and flags

Subcommands

CommandWhat it does
grokStart the interactive terminal session
grok login / logoutSign in or out; --device-auth for headless sign-in
grok modelsList models your account can use
grok mcplist, add, remove, doctor for MCP servers
grok pluginlist, install, uninstall, update, enable, disable
grok sessionslist, search, delete past sessions
grok export / importMove a session transcript in or out
grok worktreelist, show, rm, gc for git worktree sessions
grok memory clear--workspace, --global, or --all
grok inspectShow discovered config, skills, plugins, hooks, MCP servers for this directory
grok setupFirst-run configuration wizard
grok updateUpdate the binary; --check only checks for a newer version
grok dashboardUsage and session dashboard
grok agent stdioRun as an Agent Client Protocol server for other applications

Flags

From xAI's CLI reference. Run grok --help or grok <command> --help on your installed version for the complete, current list.

FlagEffect
-p, --single <PROMPT>Headless mode: one prompt, run tools, print the result, exit
--output-format <FMT>plain, json, streaming-json, or streaming-messages-json
--json-schemaConstrain the final answer to a supplied JSON Schema
-m, --model <MODEL>Select a model for this session
--effort <LEVEL>Reasoning effort, gated by what the model supports
--always-approve (alias --yolo)Auto-approve every tool execution; explicit deny rules still apply
--max-turns <N>Cap the number of agent turns before it stops
--allow <RULE>, --deny <RULE>Permission rules using a tool-prefix glob syntax
--sandbox <PROFILE>off, workspace, devbox, read-only, or strict
--cwd <PATH>Working directory for the session
-r, --resume [ID]Resume a session by id, or the most recent one
-c, --continueContinue the most recent session
-w, --worktree [NAME]Start the session inside a git worktree
--no-plan, --no-subagents, --no-memoryDisable plan mode, sub-agents, or persistent memory for this run
--oauthForce the browser OAuth flow instead of a stored credential

Interactive TUI vs headless mode

Running grok with no arguments opens a full-screen, mouse-interactive terminal UI: chat pane, plan view, inline tool approvals. That is the mode for sitting down and working a task through.

Headless mode is what makes the CLI callable from a script, a Makefile, or another agent's shell. It takes one prompt, runs whatever tools the task needs, prints the result, and exits with a status code you can branch on.

A one-shot, read-only headless call
grok -p "Summarize what internal/queue does. Do not edit files." --cwd ~/code/your-project
Structured output for a downstream script
grok -p "list every exported function with no doc comment" \
  --output-format json | jq

For CI or another agent that must parse the result reliably, pair headless mode with --json-schema rather than asking for JSON in plain English. A supplied schema is a contract; a sentence asking politely for JSON is not.

MCP servers

MCP works out of the box, covering both local stdio servers and remote HTTP servers with automatic OAuth.

Add a local stdio MCP server
grok mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/dir
Add a remote MCP server over HTTP
grok mcp add --transport http linear https://mcp.linear.app/mcp

# with a static auth header instead of OAuth
grok mcp add --transport http api https://mcp.example.com/mcp \
  --header "Authorization: Bearer ${API_TOKEN}"

You can also declare servers in config, which is the right move for a team setup checked into the repository with --scope project.

ScopeFile
User, all projects~/.grok/config.toml
One project, shared with a team.grok/config.toml in the repo (--scope project)
grok mcp list
grok mcp doctor          # diagnose a misbehaving server
grok mcp remove <name>

Inside the interactive TUI, /mcps opens the same management surface: toggle a server with space, refresh after a config edit, and authenticate an OAuth server without leaving the session.

Pricing and subscriptions

Installing Grok Build costs nothing. Running it is not free. You need either a qualifying xAI subscription or a separately billed API key, and those are two different rails that do not top each other up.

Access paths, as of August 2026. Confirm current figures on x.ai before you commit; consumer AI pricing has moved more than once this year.

PathRoughlyNotes
SuperGrok~$30/monthIncludes Grok Build access under the plan's usage limits
SuperGrok Heavy~$300/monthGrok Build's original beta tier; highest usage ceiling
X Premium+Bundled with the X subscriptionAlso unlocks Grok Build access
XAI_API_KEYPay-per-token, billed separatelyNeeded for headless CI and any use outside a subscription seat

Grok CLI vs Claude Code, Codex CLI, and Gemini CLI

All four are terminal-native agents that read a repository, edit files, run shell commands, and speak MCP. In practice the differences that decide your choice are billing and ecosystem maturity, not raw model quality.

Against Claude Code: Anthropic's CLI has the longest track record in this category, the deepest plugin and skill ecosystem, and a permission model most teams have already tuned. Grok CLI's equivalents (plugins, hooks, MCP, worktree-scoped sessions) exist and cover similar ground, but they are newer, and less has been written about their edge cases. If your team is already deep in Claude Code's conventions, that familiarity is worth something Grok CLI cannot yet offer.

Against Codex CLI: OpenAI's tool and Grok Build both ship a headless mode built for scripting and both support structured JSON output, so the two feel closest in shape. The real choice usually comes down to which subscription you already pay for and which model answers your specific codebase better, which is worth testing directly rather than trusting a benchmark number. Anyone weighing Codex against Claude Code specifically has a dedicated Codex vs Claude Code comparison.

Against Gemini CLI: Google's tool went through its own naming shift in 2026 when Antigravity CLI took over serving individual accounts. Grok CLI has not gone through an equivalent access cutover: the same grok binary that launched in May 2026 is the one you install today, just further out of beta. If you were burned by Gemini CLI's auth rail changing under you, that stability is a point in Grok CLI's favor.

If you run more than one of these, one recent addition matters: Grok Build can resume a Claude Code session, importing its transcript so the conversation continues inside Grok. That is transcript portability, not a live handoff, and its limits are worth knowing before you lean on it mid-task. The mechanics are in resuming Claude Code sessions in Grok.

When it does not behave

SymptomLikely causeFix
grok: command not foundShell profile not reloaded after installOpen a new terminal window, then re-check grok --version
Browser sign-in never completes over SSHNo browser on a remote boxgrok login --device-auth, open the printed URL on your local machine
Headless run exits with no outputA tool call needed approval and was not grantedAdd an explicit --allow rule, or run interactively once to see the prompt
A documented flag is "unrecognized"CLI build is behind the docsgrok update --check, then grok update
--effort value rejectedThat level is not supported by the selected modelRun grok models and pick a level the model actually advertises
MCP server never connectsWrong transport, or config edited without a refreshgrok mcp doctor <name>, then grok mcp list
Session used more quota than expectedSigned in with a subscription but a script exported XAI_API_KEYCheck which credential the session actually used before assuming the plan is wrong

Questions people ask

xAI's official name for the product is Grok Build. The command-line binary is grok. "Grok CLI" is the common name people search for, not the vendor's own branding.

On macOS and Linux, curl -fsSL https://x.ai/cli/install.sh | bash. On Windows, irm https://x.ai/cli/install.ps1 | iex in PowerShell. There is no npm package or Homebrew formula for the official CLI as of August 2026.

No. It requires a SuperGrok subscription, X Premium+, or a separately billed XAI_API_KEY. SuperGrok is roughly $30 a month and SuperGrok Heavy roughly $300 a month, and API usage is billed per token on top of any subscription. Confirm current numbers on x.ai before committing.

Grok-4.5, xAI's flagship model as of its July 2026 release. Run grok models to see every model your account can actually select, since the lineup changes and can include custom endpoints you configure yourself.

grok -p "your prompt" runs one prompt in headless mode, executes any needed tools, prints the result, and exits. Add --output-format json and --json-schema when a script needs to parse the answer reliably.

Yes. grok mcp add connects local stdio servers or remote HTTP servers with automatic OAuth, servers can be declared in ~/.grok/config.toml or a project-scoped .grok/config.toml, and /mcps manages them inside the interactive session.

Two of the three, in a narrower form than the claims suggest. --json-schema constrains headless output to a schema, and --check is real only under grok update --check, where it looks for a newer CLI build. A best-of-N sampling flag and a self-verifying --check did not appear in xAI's official CLI reference or changelog when this guide was checked, so treat those two as unverified until grok --help on your own install shows them.

Mostly in billing and maturity, not capability. All three read a repository, edit files, run commands, and support MCP from a terminal session. Claude Code and Codex CLI have longer track records and larger plugin ecosystems. Grok CLI is newer but stable since its 1.0 release on 7 August 2026, and it bills against your xAI subscription or API key rather than Anthropic's or OpenAI's.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. xAI: Grok Build overview
  2. xAI: Grok Build CLI reference
  3. xAI: MCP servers in Grok Build
  4. xAI: Introducing Grok Build
Try it

Grok, Claude, and Codex,
one workbench.

Continuum runs Grok Build beside every other agent CLI you use, on your own logins, with usage gauges per provider.

free app · your subscriptions · local-first