CLI Reference

This page describes the public grok command surface for end users. It is intentionally focused on behavior, side effects, and when to use each command.

Global Flags

These apply to grok before you choose a subcommand:

Flag What it changes
-m, --model Overrides the xAI model for the current launch.
--region Overrides the xAI regional endpoint, for example us-east-1.
-y, --trust Sets trust mode, such as off, limited, or full.
-c, --continue Opens the most recent saved session in the TUI.
-s, --session Opens a matching saved session in the TUI.
--team-name Starts the session with a team context.

Side Effects You Should Know

  • grok run and grok exec apply successful file edits live.
  • grok exec streams progress to stderr and the final answer to stdout.
  • grok exec --json writes JSONL events to stdout.
  • grok exec --ephemeral skips session persistence.
  • grok exec supports --sandbox read-only, workspace-write, and full-access.
  • grok exec --full-auto auto-approves tool calls with a workspace-write sandbox.
  • run and exec accept image attachments in .png, .jpg, .jpeg, .gif, and .webp.
  • export and replay accept session@branch when you need a specific branch.
  • update keeps backups so rollback remains possible.
  • uninstall removes local state, saved sessions, keyring data, and known PATH hooks, not just the binary.

Command Inventory

text
grok run
grok exec
grok login
grok logout
grok whoami
grok config
grok init
grok import
grok import claude
grok import cursor
grok import mcp-json
grok mcp
grok mcp add
grok mcp list
grok mcp remove
grok mcp remote
grok mcp remote add
grok mcp remote list
grok mcp remote remove
grok sessions
grok export
grok session
grok session delete
grok session rename
grok stats
grok cost
grok deepinit
grok teams
grok teams list
grok teams show
grok teams delete
grok skills
grok wait
grok replay
grok harness
grok harness run
grok harness report
grok harness diff
grok harness bless
grok harness bless baseline
grok update
grok uninstall
grok ci-fix

What The Main Commands Are For

Command What it is for
run One human-readable non-interactive run.
exec Script-friendly single-shot execution with structured output options.
login Validate and save a local xAI API key.
logout Remove stored local xAI auth state.
whoami Show current auth and runtime defaults.
config Print the config paths and the merged config Grok Code is actually using.
init Create the starter .grok/ scaffold in the current project.
import Materialize compatibility data from other tools into .grok/.
mcp Manage local and remote MCP definitions.
sessions List saved sessions.
export Export a saved session branch to Markdown.
session Rename or delete a saved session.
stats Show usage analytics.
cost Show a cost report for a time range.
deepinit Generate lightweight AGENTS.md guidance for a project tree.
teams Inspect or delete persisted team state.
skills List learned skills.
wait Inspect or wait out stored xAI rate-limit state.
replay Replay a saved session timeline.
harness Run and inspect harness evidence.
update Check for updates, apply them, or roll back.
uninstall Remove the install and local Grok state.
ci-fix Read a CI log and ask Grok Code to diagnose and repair it.

Was this page helpful? Report issues on GitHub.