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
cdinto the project.- 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./resumeopens a previous session./sessionsswitches, renames, or closes active sessions./sharemints 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_KEYis already in the environment. /shareis a session URL from this TUI. Strip secrets before you send it.- Headless
-pstill uses the same account and credits as the interactive CLI.