Skip to main content
9 – 17 UHR +49 8031 3508270 LUITPOLDSTR. 9, 83022 ROSENHEIM
DE / EN
Coding agent xAI (SpaceXAI) USA Terminal (TUI), headless, ACP

Grok CLI

Grok CLI, officially Grok Build, is the open-source coding agent from xAI (SpaceXAI) for the terminal. Features, models, sandbox, MCP and enterprise use.

Licence Apache-2.0
First release May 2026 (early beta)
Interfaces Terminal (TUI), Headless mode (CLI), Editors via ACP
Platforms macOS, Linux, Windows
Instruction file AGENTS.md

The seven building blocks in Grok CLI

How Grok CLI implements the building blocks of an AI harness

  1. 1

    Agent loop

    Grok Build works through tasks as a fullscreen TUI in a loop of model call, tool execution and feedback; in plan mode a plan can be approved, commented on or rewritten before execution. The same loop runs non-interactively with grok -p for scripts and CI.

  2. 2

    Tools and execution environment

    The agent edits files, runs shell commands, searches the web and manages background tasks; further tools are added through MCP servers, which are registered with grok mcp add or in config.toml and namespaced as <server>__<tool>.

  3. 3

    Context management

    Grok Build loads project rules from AGENTS.md files from the repository root down to the working directory and from .grok/rules/, with deeper files taking precedence; CLAUDE.md files are read for compatibility. The history is compacted automatically or via /compact.

  4. 4

    State and memory

    Every session is saved with prompts, responses, tool calls and file snapshots under ~/.grok/sessions/ and can be resumed with /resume, grok --resume or grok -c and branched with /fork.

  5. 5

    Permissions

    Three permission modes (Ask as the default, Auto, Always-approve) are complemented by allow and deny rules, with deny always winning. Separately, a sandbox (Landlock on Linux, Seatbelt on macOS) with profiles such as workspace, read-only and strict limits what an approved call may do; it is off by default.

  6. 6

    Verification and feedback

    According to the vendor, changes appear as a diff once a plan is approved; /rewind (alias /undo) rolls the conversation back to an earlier turn but, according to the documentation, does not change any files on disk. Hooks such as PreToolUse, UserPromptSubmit and Stop can block an action or the end of a turn, and PostToolUse can start a formatter afterwards.

  7. 7

    Orchestration

    Subagents are independent child sessions with their own context that return a summary to the parent session; the built-in types are general-purpose, explore and plan, and custom types live under .grok/agents/. Git worktrees isolate parallel sessions.

Models and model access

Which models the harness uses and how they are obtained

Models and model access
Models Grok models from xAI
Access routes xAI account (inference proxy), xAI API (API key), custom endpoints via base_url
Free choice of model Yes
Custom endpoint / LLM gateway Yes
According to the documentation, custom models are added to ~/.grok/config.toml as a [model.<name>] section with the fields model, base_url, name and env_key and set as default under [models]; the grok inspect command shows which configuration was discovered.
Features
MCP servers Sub-agents Hooks Skills Plugins / extensions Sandbox Headless / CI IDE integration Resume sessions
Running it with herdr
Supported by herdr Yes
State detection Screen manifest
Integration Session
herdr lists the agent as Grok CLI; the corresponding detection manifest grok carries the alias grok-build and refers to Grok Build from xAI.
More about herdr →

Enterprise use

Data processing, controls and pricing model according to the vendor

Data flow

According to the documentation, prompt and file content are assembled locally, sent over TLS 1.2/1.3 to an inference proxy (cli-chat-proxy.grok.com) and forwarded from there to the model; tools run locally. Processing in an EU region is not described in the Grok Build documentation.

Zero Data Retention

According to the documentation, Zero Data Retention is enabled at team level; no prompts, code or responses are then persisted at the inference layer. Local session history remains under ~/.grok/.

Identity and SSO

Besides browser login, device code and API key, Grok Build supports enterprise OIDC against your own identity provider (Entra ID, Okta and Auth0 are named). disable_api_key_auth and force_login_team_uuid pin sign-in to SSO and to specific teams.

Admin policies

Configuration has five layers; according to the documentation, values in /etc/grok/requirements.toml cannot be overridden by user config or environment variables and are suited to distribution via MDM or golden images, for example to pin sandbox profiles or lock the always-approve mode.

Pricing model

At the start of the early beta, Grok Build was available to SuperGrok and X Premium Plus subscribers according to the announcement; alternatively, use with an xAI API key is documented – see the vendor for current terms.

Strengths
  • Open-source Rust code under Apache-2.0 in the official xai-org/grok-build repository
  • Reads existing AGENTS.md, CLAUDE.md, hook, skill and MCP configurations without changes, according to the documentation
  • Freely configurable model endpoints via base_url in config.toml
  • Headless mode with JSON and streaming JSON output plus an ACP interface via grok agent stdio
  • Documented enterprise controls with pinnable policies, OIDC sign-in and Zero Data Retention at team level
  • Operating-system-level sandbox profiles and rule-based permissions
Limitations
  • According to the documentation the sandbox is off by default; the network restriction for child processes is enforced on Linux only, and paths such as ~/.ssh require a custom deny list
  • According to the documentation, /rewind explicitly rolls back only the conversation and does not restore files on disk; there are no code checkpoints
  • EU data residency is not publicly documented for the Grok Build inference proxy
  • According to the README, building from source on Windows is best-effort and not tested from this repository

Use cases

Typical tasks for this harness

Agentic coding in the terminal with plan approval and diff view
Parallel subtasks with subagents and Git worktrees
Automated reviews and scripts in CI via grok -p
Embedding in editors and custom applications via the Agent Client Protocol
Centrally managed developer workstations with pinned policies

Grok CLI is xAI’s terminal-based coding agent, officially called Grok Build, which acts as an AI harness connecting the Grok models with tools, context, permissions and subagents to form a working agent. The source code is available under the Apache-2.0 licence in the official xai-org/grok-build repository; Grok Build is used as a fullscreen TUI, headlessly in scripts or in editors via the Agent Client Protocol (ACP). As of 20 September 2026.

What is Grok CLI?

The name “Grok CLI” comes from herdr’s list of agents; the vendor calls the product Grok Build, started with the grok command. xAI now appears as SpaceXAI in its documentation and repository, and announced Grok Build as an early beta on 25 May 2026. It should not be confused with the community project grok-cli by superagent-ai, whose own README states it is not affiliated with xAI.

Grok Build installs on macOS and Linux with curl -fsSL https://x.ai/cli/install.sh | bash and on Windows via irm https://x.ai/cli/install.ps1 | iex; the enterprise documentation also names npm install -g @xai-official/grok. Running grok then starts an interactive session in the project directory; a browser opens for sign-in on first launch, or the XAI_API_KEY environment variable suffices without one.

Grok CLI as an AI harness

Grok Build covers the building blocks of a harness with documented mechanisms. The agent reads project rules from AGENTS.md files from the repository root down to the working directory and from .grok/rules/; for compatibility, CLAUDE.md, .claude/rules/ and .cursor/rules/ are read as well. Tools are added through MCP servers, for example with grok mcp add or as an [mcp_servers.<name>] section in ~/.grok/config.toml.

Permissions and sandbox are separate: modes such as default (ask), acceptEdits, auto, dontAsk and bypassPermissions (always-approve) plus allow/deny rules decide whether a tool call runs; the sandbox (Landlock on Linux, Seatbelt on macOS) additionally limits what an approved call may do, enabled with grok --sandbox workspace or GROK_SANDBOX=workspace. Hooks are JSON files under ~/.grok/hooks/ or .grok/hooks/; PreToolUse, UserPromptSubmit, Stop and SubagentStop can block, and project hooks first need trust via /hooks-trust.

Subagents run as child sessions with their own context (general-purpose, explore, plan). Skills are folders with a SKILL.md; plugins bundle skills, agents, hooks and MCP/LSP servers. Sessions live under ~/.grok/sessions/; /rewind (alias /undo) rolls the conversation back a turn but leaves file changes untouched. For automation there is grok -p "…" --output-format json and the ACP interface grok agent stdio.

Models and model access

By default Grok Build works with the Grok models from xAI; our page on xAI Grok puts the model family into context. Requests run either with the xAI account session through the inference proxy or with an API key directly against the xAI API.

According to the documentation, Grok Build also supports any custom model. To do so, a [model.<name>] section with model, base_url, name and env_key is added to ~/.grok/config.toml and set as default under [models]; grok inspect shows the discovered configuration. This means Grok Build can be operated through a central, OpenAI-compatible proxy such as the AI Gateway: enter the gateway endpoint as base_url and the variable holding the gateway key as env_key. The enterprise documentation notes that such third-party endpoints keep working even when sign-in with an xAI API key is disabled.

Enterprise use: data protection and governance

xAI describes the data flow in six steps: input is assembled locally, sent over TLS 1.2/1.3 to the inference proxy cli-chat-proxy.grok.com, forwarded from there to the model, processed, streamed back over the same encrypted connection, and – unless the team has enabled Zero Data Retention – stored; tools run locally throughout. Zero Data Retention can be enabled at team level, meaning, according to the documentation, no prompts, code or responses are persisted at the inference layer. EU data residency is not publicly documented for Grok Build.

Five configuration layers govern control. Values in /etc/grok/requirements.toml cannot be overridden and can be distributed via MDM – for example a fixed sandbox profile, disable_api_key_auth for enforced SSO, or force_login_team_uuid. Enterprise OIDC connects identity providers such as Entra ID, Okta or Auth0, and the standard HTTPS_PROXY/NO_PROXY variables are honoured. Regardless, source code and prompts go to the chosen model provider and belong in your records of processing activities beforehand.

Orchestrating Grok CLI with herdr

herdr lists Grok CLI with the state authority “screen manifest” and the integration role “session”, recognising from the terminal output whether Grok Build is working, waiting or asking for approval, and providing a session identity for restore. Its manifest grok carries the alias grok-build.

Where it fits: developer harness and enterprise harness

Grok Build is a harness for developers: a repository, a terminal, an editor. Employees in business departments need a different harness – business systems as tools, company knowledge as context, roles from the directory service. That role is taken by CompanyGPT, a complement rather than a competitor. The AI Gateway serves both as a shared cost and governance layer with budgets per team, user and agent; see the overview of AI harnesses for further coding agents. We support organisations in introducing coding agents such as Grok Build in line with data protection requirements and their AI governance.

From developer harness to enterprise harness

Coding harnesses are tools for developers. Business users, cost control and governance need two more layers.

CompanyGPT – the harness for business users

CompanyGPT gives any language model tools via MCP servers, integrations and n8n, company knowledge via companyRAG, roles from Entra ID or Keycloak, and audit logs – operated in your Azure environment or sovereignly on STACKIT.

Discover CompanyGPT
AI Gateway – cost and governance for every agent

The AI Gateway bundles the model access of your tools and coding agents behind an OpenAI-compatible API: authentication via Entra ID, budgets and cost centres per team, user and agent, guardrails and complete logging.

View the AI Gateway

Frequently Asked Questions

What is Grok CLI?

Grok CLI refers to xAI's terminal-based coding agent, which is officially called Grok Build and is started with the grok command. It runs as a fullscreen TUI, understands the codebase, edits files, executes shell commands and can also be used headlessly or in editors via the Agent Client Protocol.

Is Grok CLI an official xAI product?

Yes, Grok Build comes from xAI, which now appears as SpaceXAI in its documentation and repository, and is maintained in the xai-org/grok-build repository. It is distinct from the community project grok-cli by superagent-ai, which states in its own README that it is not affiliated with xAI. When herdr says Grok CLI, it means the official Grok Build.

Is Grok CLI open source?

The Grok Build source code is published in the xai-org/grok-build repository under the Apache-2.0 licence and, according to the README, is synced periodically from the internal monorepo. The inference proxy and the Grok models themselves are services of the vendor.

Which models does Grok CLI support?

By default Grok Build uses the Grok models from xAI. According to the documentation the tool additionally supports any custom model, added to ~/.grok/config.toml with model, base_url and env_key and selected via /model or the -m flag.

Can Grok CLI be used in line with the GDPR?

That depends on the chosen model access and the contract. xAI documents TLS transport, local tool execution and Zero Data Retention at team level, but does not describe EU data residency for Grok Build. Source code and prompts go to the chosen model provider and must be recorded in your records of processing activities beforehand.

Does Grok CLI work with herdr?

Yes. herdr lists Grok CLI among its supported agents with the state authority screen manifest and the integration role session. herdr therefore reads state from Grok Build's terminal output and provides a session identity for restore.

Introduce coding agents safely in your company

We support selection, model access in the EU, permission design and cost control.