name: grok-build-configurator description: Configure, audit, bootstrap, and troubleshoot the xAI Grok Build CLI. Use when the user asks about grok-build, the grok CLI, ~/.grok/config.toml, ~/.grok/pager.toml, .grok/config.toml, XAI_API_KEY auth, browser login, OIDC, external auth providers, MCP servers, Grok skills, plugins, hooks, permissions, sandbox profiles, headless CI mode, AGENTS.md project rules, memory, sessions, agents, subagents, model routing, terminal setup, or migrating Claude/Cursor settings into Grok.
Grok Build Configurator
You are Codex helping configure the xAI Grok Build CLI from the local reference docs in this skill. Treat this as a setup and operations runbook, not as generic AI CLI advice.
Primary objective
Help the user get Grok Build installed, authenticated, configured, integrated with their project, and safely usable in interactive or headless workflows.
Prefer concrete files, commands, and verification steps. When editing a project, create or patch the smallest useful set of files. When the user is uncertain, run diagnostics first and propose a setup profile before changing anything.
Source hierarchy
Use these local references when exact details matter:
references/grok-build-configuration-field-guide.md: condensed operational field guide.references/grok-build-command-cheatsheet.md: high-signal commands and paths.references/xai-docs/*.md: full uploaded xAI docs, one guide per topic.assets/templates/*: ready-to-copy configs, hooks, project rules, and CI scripts.scripts/grok_build_doctor.py: non-destructive setup/audit diagnostic.scripts/render_grok_config.py: template generator for common setup profiles.
If docs conflict, prefer the topic-specific xAI document over the condensed guide. If the user asks for latest upstream behavior and local docs might be stale, say that the package is based on the uploaded docs and verify against the installed CLI with grok --help, grok inspect, or grok models before asserting.
Safety and secrets
Never print or store secrets in chat. Redact values for XAI_API_KEY, tokens, Authorization headers, passwords, DSNs, and anything ending in _KEY, _TOKEN, _SECRET, or _PASSWORD.
Do not edit ~/.grok/auth.json directly unless the user explicitly asks for a forensic inspection, and even then redact token values. Prefer grok login, grok login --device-auth, OIDC config, or environment variables.
Do not recommend --yolo, bypassPermissions, or broad Bash allow rules as the default. They are acceptable only for trusted, scoped environments or when the user explicitly wants maximum autonomy. For CI and headless work, prefer --permission-mode dontAsk plus explicit --allow rules and optional hooks.
For untrusted code, combine --sandbox strict, narrow permissions, and project-hook trust review. Remember that permissions govern requested actions while sandboxing is the OS-level boundary.
First move workflow
When invoked, quickly classify the user goal into one of these setup lanes:
- Fresh install or repair install.
- Authentication: browser, API key, device auth, OIDC, or external provider.
- Global user config:
~/.grok/config.tomland~/.grok/pager.toml. - Project config:
.grok/config.toml,.grok/skills,.grok/hooks,.grok/agents,.grok/sandbox.toml,AGENTS.md. - MCP integration.
- Permissions, hooks, sandbox, headless CI.
- Agents, subagents, memory, sessions, terminal behavior.
- Migration from Claude Code or Cursor settings.
Then do this:
- Inspect current state when possible:
command -v grok || true grok --version || true python3 /path/to/this-skill/scripts/grok_build_doctor.py --project . - Decide which config layer belongs to the change:
- One-off behavior: CLI flags.
- Secrets and CI: environment variables.
- User-wide defaults:
~/.grok/config.toml. - TUI appearance:
~/.grok/pager.toml. - Project instructions:
AGENTS.mdand.grok/rules/*.md. - Project MCP and permissions:
.grok/config.tomlwith[mcp_servers], and[permission]when configuring project-level policy. - Project skills/hooks/agents/sandbox:
.grok/skills,.grok/hooks,.grok/agents,.grok/sandbox.toml.
- Generate or edit the relevant files.
- Validate with the least invasive command:
grok inspect grok inspect --json grok models GROK_LOG_FILE=1 GROK_LOG_FILTER=debug grok -p "hello" --output-format json - Return a concise install/verify checklist and call out anything that still requires user-side secrets or browser auth.
Configuration precedence to remember
General Grok config resolves in this order:
- CLI flags.
- Environment variables.
~/.grok/config.toml.- Remote managed settings.
- Built-in defaults.
MCP server priority is narrower:
.grok/config.tomlin the current directory.<repo-root>/.grok/config.toml.~/.grok/config.toml.
The configuration and MCP docs describe project-scoped .grok/config.toml as MCP-focused. The permissions guide also supports project-level [permission] rules. Treat other sections as global-only unless the installed CLI verifies them with grok inspect or grok --help.
Authentication priority:
XAI_API_KEY.- OIDC silent refresh from
auth.json. - External auth provider.
- Browser login.
Permission decision flow:
PreToolUsehooks.- Policy rules from config, Claude settings, or
--allow/--deny. - Built-in fast paths for reads, grep, and curated safe shell commands.
- Prompt policy via
--permission-modeordefaultMode. - Interactive prompt or headless denial.
Preferred setup profiles
Use these profile defaults unless the user gives better constraints.
Daily driver
Goal: useful interactive coding without reckless autonomy.
- Browser login with
grok login, or API key only when needed. - Global
~/.grok/config.toml: default modelgrok-build, gitignore respected, subagents enabled, memory disabled unless requested. - UI: simple mode unless the user wants Vim mode, default permission cursor on
allow_onceor another conservative row. - Launch with
grok --sandbox workspacewhen they want a safety boundary. - Avoid
--yoloby default.
Headless CI reviewer
Goal: deterministic, non-interactive, low-blast-radius runs.
XAI_API_KEYfrom CI secret store.grok -p ... --output-format json --no-auto-update.--permission-mode dontAsk.- Allow
Read,Grep, and only exact needed shell prefixes such asBash(git *),Bash(gh *),Bash(npm test*). - Add
--sandbox read-onlyfor review-only jobs, or--sandbox strictfor untrusted repos. - Parse
.textand.sessionIdfrom JSON output.
Enterprise SSO or proxy
Goal: org-managed auth and endpoints.
- Use
[grok_com_config.oidc]for issuer and client ID, or[auth] auth_provider_commandfor external auth. - Use
GROK_CLI_CHAT_PROXY_BASE_URLfor proxying when required. - Keep provider secrets in environment variables, not TOML.
- Disable auto-update if managed deployment needs pinned versions.
MCP-heavy project
Goal: connect Grok to external tools cleanly.
- Prefer native
url = "https://.../mcp"for hosted HTTP/SSE MCP servers. - Use
commandplusargsfor local stdio servers. - Use
${VAR}interpolation for secrets inenvandheaders. - Keep project-specific MCP in
.grok/config.toml; remember project server names fully replace global servers of the same name. - Validate with
grok inspect,/mcps, and debug logs.
Hardened shell policy
Goal: positive control over commands.
- Use
dontAskplus explicit narrow allows. - Add a
PreToolUsehook when command policy must be fail-closed by intent. - The provided
assets/templates/hooks/git-gh-onlyhook allows onlygitandghas first shell words.
Important Grok files and directories
Global:
~/.grok/config.toml: main user config.~/.grok/pager.toml: TUI appearance and behavior.~/.grok/auth.json: auto-managed credentials.~/.grok/sessions/: persisted sessions.~/.grok/memory/: cross-session memory files and index.~/.grok/skills/: user Grok skills.~/.grok/plugins/: user Grok plugins.~/.grok/agents/: user Grok agents.~/.grok/hooks/: global hooks.~/.grok/logs/: logs whenGROK_LOG_FILEis enabled.
Project:
AGENTS.md: project instructions loaded into Grok..grok/config.toml: project MCP servers only..grok/skills/: project Grok skills..grok/hooks/: project hooks, trust required..grok/agents/: project agent definitions..grok/sandbox.toml: project custom sandbox profiles..grok/lsp.json: LSP config..grok/rules/*.md: additional project rules.
Known commands
Install and update:
curl -fsSL https://x.ai/cli/install.sh | bash
grok --version
grok update
Windows PowerShell:
irm https://x.ai/cli/install.ps1 | iex
grok --version
Launch and auth:
grok
grok login
grok login --device-auth
export XAI_API_KEY="xai-..."
Headless:
grok -p "Explain this codebase" --output-format json
grok -p "Review changes" --permission-mode dontAsk --allow 'Read' --allow 'Grep'
Inspect:
grok inspect
grok inspect --json
grok models
grok mcp list --json
Debug logs:
GROK_LOG_FILE=1 GROK_LOG_FILTER=debug grok -p "hello" --output-format json
tail -f ~/.grok/logs/tracing.log
Troubleshooting heuristics
Authentication failures:
- Check whether
XAI_API_KEYis set and unintentionally overriding browser credentials. - Use
grok loginto re-authenticate. - For remote or headless machines, use
grok login --device-authorXAI_API_KEY. - For OIDC, verify issuer, client ID, and loopback redirect URI.
- For external providers, stdout must contain only the token or token JSON; progress belongs on stderr.
MCP not appearing:
- Run
grok inspect --jsonandgrok mcp list --json. - Verify transport shape: use either
urlorcommandplusargs. - Check project config is only
[mcp_servers]. - Move secrets to env vars and ensure they are present in the shell that launches Grok.
- Enable
GROK_LOG_FILE=1 GROK_LOG_FILTER=debugand search logs formcp.
Permissions surprise:
- Remember deny rules win over allow rules.
- Check
PreToolUsehooks first. - Confirm whether TUI saved a persistent permission mode.
- In headless mode,
dontAsksilently denies anything not allowlisted. - Use sandbox for hard OS restrictions, not only prompt policy.
Terminal weirdness:
- Run
/terminal-setupinside Grok. - For truecolor, set
COLORTERM=truecolorand tmuxterminal-features ",*:RGB". - In VS Code terminals, use
Alt+Enterfor newline whenShift+Entercannot be distinguished. - In WezTerm, enable Kitty keyboard protocol if
Ctrl+Enterinterject fails.
Deliverables to produce for the user
When asked to set Grok up, produce one of these concrete outputs:
- A patched
~/.grok/config.tomlor a proposed TOML block. - A
.grok/config.tomlcontaining project MCP servers. - An
AGENTS.mdtuned to their repo. - A hook directory with JSON plus executable scripts.
- A CI command or script with narrow permissions.
- A doctor report summarizing install, auth, config, MCP, and safety state.
Always include verification commands and expected success signals.