Getting Started

Grok Build

View as Markdown

Grok Build is a coding agent for the terminal. Use it as an interactive TUI, headlessly in scripts or bots, or through the Agent Client Protocol (ACP) in other apps.

Install

Run the command for your system. It downloads the latest stable release and adds grok to your PATH:

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

Run Grok

Start Grok in your project folder:

Bash

cd your-project
grok

If your shell can't find grok, open a new terminal.

On first launch, Grok opens your browser to sign in, and keeps you signed in after that. If there is no browser, use another method:

Where you're workingSign in withCommand
Your own machineBrowsergrok
SSH or a remote machineDevice codegrok login --device-auth
CI and scriptsAPI keyexport XAI_API_KEY="xai-..."

For every sign-in option, see Authentication.

Ask your first question

At the prompt, start with a question that works in any repository:

Text

Explain this repo.

Grok reads the files it needs, shows each step as it runs, and answers with a summary of the codebase. Once you see that, the install, sign-in and project are all working.

Then point it at a file with @:

Text

@src/main.rs Walk me through this file.

In a session, /usage shows your credit usage.

Run headlessly

Headless mode is ideal for scripts, automations, or integration into other apps:

Bash

grok -p "Explain this codebase"
grok -p "Explain the architecture" --output-format streaming-json

For its flags and output formats, see Headless and Scripting.

Update

One command updates Grok for both interactive and headless use:

Bash

grok update

To see what each release changed, read the Changelog.

Requirements

  • macOS (Apple silicon or Intel) or Linux (x86_64 or arm64). On Windows, use PowerShell, Git Bash or WSL.
  • A terminal, and a project folder to run Grok in.
  • A SpaceXSI account to sign in with, or an API key.

Features

Next