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 runandgrok execapply successful file edits live.grok execstreams progress tostderrand the final answer tostdout.grok exec --jsonwrites JSONL events tostdout.grok exec --ephemeralskips session persistence.grok execsupports--sandbox read-only,workspace-write, andfull-access.grok exec --full-autoauto-approves tool calls with aworkspace-writesandbox.runandexecaccept image attachments in.png,.jpg,.jpeg,.gif, and.webp.exportandreplayacceptsession@branchwhen you need a specific branch.updatekeeps backups so rollback remains possible.uninstallremoves 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-fixWhat 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. |