# Grok Build

> The Rust source of the `grok` terminal coding agent — a full-screen TUI, a headless runner and an ACP server

- Category: AI Coding / Autonomous Coding Agents
- Language: Rust
- Licence: Apache-2.0
- Repository: https://github.com/xai-org/grok-build
- Website: https://docs.x.ai/build/overview
- Canonical page: https://ai-tldr.dev/tools/grok-build/
- Updated: 2026-07-16

## In short

Grok Build is the terminal-based AI coding agent published by SpaceXAI, distributed as the `grok` command. It runs as a full-screen TUI that reads your codebase, edits files, executes shell commands, searches the web and manages long-running tasks. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in Rust and licensed Apache-2.0.

## Overview

Grok Build is the terminal-based AI coding agent published by SpaceXAI, distributed as the `grok` command. It runs as a full-screen TUI that reads your codebase, edits files, executes shell commands, searches the web and manages long-running tasks. The same binary can also run headlessly for scripting and CI, or be embedded in an editor over the Agent Client Protocol.

This repository holds the Rust source for the CLI, the TUI and the agent runtime, synced periodically from the SpaceXAI monorepo — a `SOURCE_REV` file at the root records the exact monorepo commit the tree corresponds to. The crate layout separates the concerns cleanly: the pager crate is the TUI (scrollback, prompt, modals, rendering), a shell crate holds the agent runtime and the leader, stdio and headless entry points, a tools crate implements the terminal, file-edit and search tools, and a workspace crate owns the host filesystem, version control, execution and checkpoints. A vendored Mermaid diagram stack sits under `third_party/`.

Because the source is Apache-2.0 and self-contained enough to build with cargo, pieces of it get reused outside the CLI — Simon Willison pulled the Mermaid-to-Unicode renderer out of this tree in July 2026 and compiled it to WebAssembly as a standalone browser tool. The user guide ships inside the pager crate and covers keyboard shortcuts, slash commands, configuration, theming, MCP servers, skills, plugins, hooks, headless mode and sandboxing; fuller documentation is online at docs.x.ai.

## What it does

- Full-screen terminal UI with scrollback, prompt and modals, plus mouse interaction
- Codebase-aware tools: file editing, shell execution, search and web search, with checkpoints over the host workspace
- Three run modes — interactive TUI, headless for scripting and CI, and Agent Client Protocol for editor embedding
- Extensible through MCP servers, skills, plugins and hooks, all documented in the shipped user guide
- Prebuilt binaries for macOS, Linux and Windows, or a `cargo build` from the Apache-2.0 Rust source
- Sandboxing and configuration documented alongside the source rather than only online

## Getting started

Most people install the released binary; building from source needs Rust plus DotSlash for the hermetic tools under bin/.

1. Install the released binary

   Prebuilt binaries are published for macOS, Linux and Windows.

```bash
curl -fsSL https://x.ai/cli/install.sh | bash   # macOS / Linux / Git Bash
irm https://x.ai/cli/install.ps1 | iex          # Windows PowerShell
grok --version
```

2. Install the build prerequisites (source builds only)

   The Rust toolchain is pinned by rust-toolchain.toml and rustup installs it on first build. DotSlash must be on PATH before you build so the hermetic tools under bin/ — notably protoc — can download and run.

```bash
cargo install dotslash
/usr/bin/env dotslash --help   # sanity check
```

3. Build and launch from source

   The binary artifact is named xai-grok-pager; official installs ship it as grok. On first launch it opens a browser to authenticate.

```bash
cargo run -p xai-grok-pager-bin              # build + launch the TUI
cargo build -p xai-grok-pager-bin --release  # target/release/xai-grok-pager
cargo check -p xai-grok-pager-bin            # fast validation
```

4. Read the user guide

   The guide ships inside the repository at crates/codegen/xai-grok-pager/docs/user-guide/ — getting started, keyboard shortcuts, slash commands, configuration, theming, MCP servers, skills, plugins, hooks, headless mode and sandboxing. The full online docs are at docs.x.ai/build/overview.

## When to use it

- Working in a terminal-first coding agent that edits files and runs commands against a real workspace
- Scripting agent runs headlessly in CI where there is no interactive terminal
- Embedding the agent in an editor that speaks the Agent Client Protocol
- Reading or reusing a production coding-agent runtime written in Rust, crate by crate

## Version history

- 2026-07-16: Shortly after xAI open-sourced the Grok Build tree, Simon Willison found its self-contained Mermaid-to-Unicode renderer, compiled the Rust to WebAssembly and shipped it as a standalone browser tool.
