BUILD / start-a-grok-build-session

Build

Start a Grok Build session

Start a Grok Build session

Open the CLI in the repo you want Grok to work on. The installer is already covered in Install the Grok Build CLI.

Launch

  1. cd into the project.
  2. Run grok.
cd your-project
grok

On first launch, Grok opens a browser for authentication. In a non-browser environment, export a key first:

export XAI_API_KEY="xai-..."
grok

First prompts

Ask it to read the tree, or point at one file with @:

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

Session commands

  • /new (alias /clear) starts a new session.
  • /resume opens a previous session.
  • /sessions switches, renames, or closes active sessions.
  • /share mints a URL for the current CLI session.

Headless

For scripts and bots, pass -p and skip the TUI:

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

Pitfalls

  • First launch needs a browser unless XAI_API_KEY is already in the environment.
  • /share is a session URL from this TUI. Strip secrets before you send it.
  • Headless -p still uses the same account and credits as the interactive CLI.