Reference and workflow guidance for the Grok Build CLI (`grok`), including interactive and headless runs, authentication, sessions, worktrees, permissions, sandboxing, MCP servers, plugins, inspection, updates, and automation output. Invoke only when the user explicitly requests the `grok-build` skill, explicitly asks to use Grok Build CLI, or an already-selected workflow requires Grok Build; do not invoke for general coding, generic shell tasks, or other agent CLIs.
76
95%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Operate Grok Build from a terminal while keeping execution mode, permissions, sandboxing, session state, and output handling explicit.
Confirm that the CLI is available:
command -v grok
grok versionInspect the installed command before giving version-sensitive advice:
grok --help
grok <subcommand> --helpInspect the configuration discovered for the target workspace when behavior depends on rules, skills, plugins, hooks, or MCP servers:
grok --cwd /path/to/repo inspect
grok --cwd /path/to/repo inspect --jsonTreat current official documentation and installed help as authoritative when they differ from this bundled reference.
grok with no arguments for the interactive TUI.grok "<initial prompt>" to open the TUI with an initial task.grok -p "<prompt>" for one non-interactive turn that prints a result and exits.grok agent stdio for an ACP client that communicates over stdin/stdout.grok dashboard to open the Agent Dashboard.Prefer headless mode for scripts, CI, bots, and agent orchestration. Prefer ACP only when the caller implements the ACP JSON-RPC lifecycle and consumes session/update chunks.
Use an interactive login on a developer machine:
grok loginUse device-code authentication in headless or remote environments:
grok login --device-authUse a locally cached login or provide XAI_API_KEY only to the process that needs it. Never print, persist, or commit credentials. Use grok logout to clear cached credentials.
Use an explicit working directory and output format:
grok --no-auto-update \
--cwd /path/to/repo \
--sandbox workspace \
-p "Inspect the repository and explain the failing test." \
--output-format jsonChoose output according to the consumer:
plain for humans.json for one final machine-readable object.streaming-json for newline-delimited incremental events.--json-schema '<schema>' when the installed CLI supports constrained structured output.Pass --no-auto-update in scripts and CI to suppress background update checks. Do not parse interactive TUI rendering in automation.
Treat permissions and sandboxing as separate controls:
--sandbox workspace for normal repository changes.--sandbox read-only for review and auditing.--sandbox strict for an untrusted repository, then add narrow permission rules.--allow <RULE> and --deny <RULE> for per-run policy; remember that deny rules win.--always-approve only when the environment and command scope justify unattended execution. Pair it with a suitable sandbox and explicit deny rules.Do not describe --always-approve as equivalent to sandboxing. The sandbox is off by default unless configured or selected.
Continue or resume intentionally:
grok -c
grok --resume <session-id>
grok --resumeUse --session-id <UUID> for a new named session, not to resume an existing one. Add --fork-session when branching from a resumed session.
Use a worktree when concurrent work could collide:
grok --worktree --ref main "Fix the flaky test"
grok --worktree=feature-name "Implement the feature"Preview removal with grok worktree rm --dry-run <id> before deleting a worktree. Do not assume deleting a session removes its worktree.
Use built-in inspection and diagnostics first:
grok inspect --json
grok mcp list --json
grok mcp doctor
grok plugin list
grok modelsPrefer grok mcp add, grok mcp remove, and plugin subcommands over manually editing configuration when the CLI supports the requested operation. Keep secrets in environment variables rather than command history or committed configuration.
Verify destructive commands such as session deletion, plugin removal, MCP removal, memory clearing, and worktree removal with the user or the governing workflow before running them.
ec3f989
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.