Skip to content

Grok Build Cheatsheet ​

Lookup only, no teaching. Every entry comes from xAI's official documentation, with the source page linked next to each section heading. The authoritative full command set is always grok --help / grok <subcommand> --help.

Covers npm @xai-official/grok 1.0.5 (dist-tags.latest and alpha as of 2026-08-16). The changelog header still showed v1.0.3 / Aug 12, 2026 when re-checked on 2026-08-18. If something does not match, run grok version and check the changelog.

Install and update ​

ScenarioCommand
macOS / Linuxcurl -fsSL https://x.ai/cli/install.sh | bash
Windows PowerShellirm https://x.ai/cli/install.ps1 | iex
npm channelnpm install -g @xai-official/grok
Check for updatesgrok update --check
Install a specific versiongrok update --version <V>
Switch channelgrok update --alpha / grok update --stable
Show versiongrok version

The npm package requires node >= 20; the binary is named grok.

Subcommands ​

Source: CLI Reference

CommandPurpose
grokNo arguments starts the interactive TUI
grok loginLog in; --device-auth uses the device-code flow (no browser)
grok logoutLog out and clear cached credentials
grok inspect [--json]Show what was discovered in this directory: rules, skills, plugins, hooks, MCP servers
grok modelsList available models
grok mcp <list|add|remove|doctor>Manage MCP servers
grok plugin <list|install|uninstall|update|enable|disable|details|validate>Manage plugins
grok plugin marketplace <list|add|remove|update>Manage marketplace sources
grok sessions <list|search|delete>List, search, delete sessions
grok export <session-id> [output]Export a session as Markdown
grok import [targets...]Import sessions from Claude Code
grok memory clear [--workspace|--global|--all]Clear cross-session memory files
grok worktree <list|show|rm|gc>Manage git worktrees created by sessions
grok dashboardOpen the Agent Dashboard
grok agent stdioRun as an ACP agent over stdin/stdout
grok wrap <command...>Run a command in a local PTY, forwarding OSC 52 clipboard writes
grok updateCheck for or install updates
grok versionPrint version information
grok completions <shell>Generate a shell completion script
grok setupFetch and install managed configuration

Common flags ​

FlagPurpose
--cwd <PATH>Working directory
-r, --resume [<ID>]Resume a session; omit the ID for the most recent
-c, --continueContinue the most recent session in this directory
-s, --session-id <UUID>Assign a UUID to a new session (not a resume)
--fork-sessionFork into a new session ID when resuming
-w, --worktree [<NAME>]Start the session in a new git worktree
--ref <REF>Branch / tag / commit the worktree is based on
-m, --model <MODEL>Model ID
--effort <LEVEL>Reasoning effort
--always-approveAuto-approve all tool calls (alias --yolo)
--allow <RULE> / --deny <RULE>Permission rules
--sandbox <PROFILE>Sandbox profile
--rules <TEXT>Extra rules appended to the system prompt
--system-prompt-override <TEXT>Replace the system prompt entirely
--tools <LIST> / --disallowed-tools <LIST>Expose or remove built-in tools
--max-turns <N>Maximum agent turns
--no-plan / --no-subagents / --no-memory / --disable-web-searchDisable a feature for this session
--experimental-memoryEnable cross-session memory
--oauthUse OAuth on the welcome-screen auth flow
--trustTrust project-level hooks / MCP / LSP at startup
--plugin-dir <PATH>Additional plugin directory

Claude Code flag names are accepted as aliases: --allowedTools, --disallowedTools, --append-system-prompt, --system-prompt, --dangerously-skip-permissions.

Headless-specific ​

FlagPurpose
-p <PROMPT>Run one prompt non-interactively
--output-format plain|json|streaming-jsonOutput format, default plain
--permission-mode dontAsk|acceptEditsPermission mode for CI
--no-alt-screenDo not use the alternate screen buffer
--no-auto-updateSkip auto-update for this run

Permissions and modes ​

Sources: Permissions, Modes and Commands

ModeBehaviorHow to enter
Ask (default)Anything not allowed promptsDefault
AutoA classifier auto-approves safe tools; dangerous ones may still prompt/auto, Shift+Tab (when enabled)
Always-approveAuto-approves tool calls (deny rules and PreToolUse hooks still apply)/always-approve, Ctrl+O, Shift+Tab, grok --always-approve
PlanOnly the session plan file is editable until you approve/plan [description], Shift+Tab
dontAskSilently denies anything without an explicit allow (headless / CI)--permission-mode dontAsk
acceptEditsAuto-approves file edits, still asks for shell commands--permission-mode acceptEdits

Shift+Tab cycles: Normal → Plan → Auto (when available) → Always-approve.

Rule syntax (deny always beats allow):

toml
[permission]
rules = [
  { action = "allow", tool = "bash", pattern = "git *" },
  { action = "allow", tool = "read" },
  { action = "deny",  tool = "bash", pattern = "rm -rf *" },
]

Supported filters: Bash, Edit, Read, Grep, MCPTool, WebFetch, WebSearch.

[ui] permission_mode only takes effect in user configuration (~/.grok/config.toml, or managed / requirements files); setting it in a project .grok/config.toml does nothing. The legacy keys approval_mode and yolo = true still work; when both are set, permission_mode wins.

Sandbox profiles ​

Source: Sandbox

Off by default. Landlock on Linux, Seatbelt on macOS.

ProfileReadWriteNetworkPositioning
offUnrestrictedUnrestrictedAllowedNo sandbox (default)
workspaceAnywhereCWD, ~/.grok/, temp dirsAllowedNormal development
devboxAnywhereTop-level dirs except /dataAllowedCloud dev machine
read-onlyAnywhereOnly ~/.grok/ and temp dirsBlockedCode review, audit
strictCWD and system pathsCWD, ~/.grok/, temp dirsBlockedUntrusted repos

Three limitations: subprocess network restrictions only apply on Linux (on macOS the blocking in read-only / strict is a no-op); built-in profiles do not permanently protect paths like ~/.ssh, so write your own deny list; ~/.grok/ stays writable under every profile. The model API and web tools are unaffected by subprocess network settings.

Custom profiles go in ~/.grok/sandbox.toml or .grok/sandbox.toml; built-in names cannot be redefined:

toml
[profiles.my-profile]
extends = "workspace"
restrict_network = true
deny = ["/secrets", "**/.env", "**/*.pem"]

Slash commands ​

Source: Modes and Commands

Session ​

CommandPurpose
/quit (alias /exit)Quit
/helpBrowse commands and key bindings
/homeBack to the welcome screen
/new (alias /clear)New session
/resumeResume a past session
/sessionsSwitch, rename, close active sessions
/forkFork the current session into a peer agent
/rename <title> (alias /title)Rename the current session
/shareShare the current session as a URL
/session-infoSession information
/contextContext usage
/compact [context]Compact conversation history
/rewindRoll back to an earlier turn
/exportExport the conversation to a file or the clipboard
/copy [N]Copy the last (or Nth-from-last) response
/findSearch the scrollback
/transcriptView the full transcript with $PAGER

Models and modes ​

CommandPurpose
/model <name> (alias /m)Switch model
/effortSet reasoning effort for the current model
/always-approveToggle always-approve
/autoToggle auto mode
/plan [description]Enter plan mode
/view-planView the current plan

Tasks and orchestration ​

CommandPurpose
/btw <question>Ask a side question without derailing the main thread
/loop [interval] <prompt>Repeat a prompt on an interval
/tasksList background tasks, subagents, scheduled jobs
/queueList prompts queued behind the current turn
/create-workflow [description]Write and save a new workflow
/workflow <name> [args]Start a workflow, or pause / resume / stop / save
/workflowsFull-screen workflow run board
/deep-research <query>Run the built-in research workflow
/dashboardOpen the Agent Dashboard
/imagine <prompt>Text to image
/imagine-video <prompt>Text to video

Extensions and configuration ​

CommandPurpose
/hooks / /plugins / /marketplace / /skills / /mcpsDifferent tabs of the same extensions dialog
/config-agents (alias /agents)Manage agent definitions
/personasManage personas
/settings (alias /config)Settings dialog
/theme [name] (alias /t)Switch theme
/compact-modeMore compact UI
/multiline (alias /ml)Toggle multiline input
/vim-modeToggle vim-style scrollback keys
/timestampsToggle message timestamps
/terminal-setupCheck terminal and clipboard configuration
/hooks-trustTrust the current project's hooks
/import-claudeOpen the Claude settings-import dialog

Account and memory ​

CommandPurpose
/login / /logoutLog in / out
/usageView quota usage or manage billing
/privacyView or change privacy and data-retention status
/feedback [text]Send feedback about the current session
/release-notes (alias /changelog)Release notes for the current version
/remember <note>Store a memory
/flushWrite conversation memory to disk now
/memory (alias /mem)Browse and manage memories
/dreamRun memory consolidation

/flush, /memory, and /dream are provided by the shell and only appear when cross-session memory is enabled. User-invocable skills also become /<skill-name>; on a name collision use the qualified form such as /local:commit.

Key bindings ​

Source: Keyboard Shortcuts. Press Ctrl+. in the TUI for the full list (Ctrl+X on Windows or terminals without Kitty keyboard protocol support).

Essential ​

KeyAction
EnterSend
TabMove focus between the input box and the scrollback
EscCancel the running turn
Esc EscClear the input box; opens rewind when the input is empty
Ctrl+CCancel the turn
Shift+TabCycle modes
Ctrl+P or ?Command palette
F2 or Ctrl+,Settings
Ctrl+Q / Ctrl+DQuit (press twice)

Input ​

KeyAction
Ctrl+Enter or Ctrl+IInterject during a running turn
Shift+EnterNewline; sends in multiline mode (use Alt+Enter where unsupported)
Ctrl+MToggle multiline input
Ctrl+RSearch prompt history
!Enter shell mode from an empty input box

Panels and sessions ​

KeyAction
Ctrl+TToggle the todo panel
Ctrl+BSend the running command to the background
Ctrl+; or Ctrl+'Toggle the prompt-queue panel
Ctrl+SOpen the session list
Ctrl+LOpen the extensions dialog
Ctrl+GToggle the task panel
Ctrl+OToggle always-approve
Ctrl+NNew session (press twice)
Ctrl+MPick a model when the input box is not focused
Ctrl+\Open the Agent Dashboard

Terminal differences (important) ​

  • VS Code-family terminals (VS Code, Cursor, Windsurf, Zed): quit is Ctrl+D only, interject is Ctrl+L, half-page scroll is Shift+D, Ctrl+L does not open the extensions dialog (use /plugins), newline is Alt+Enter
  • Apple Terminal: Ctrl+O also interjects
  • WezTerm: needs enable_kitty_keyboard = true for Ctrl+Enter and Shift+Enter

Letter keys in the scrollback (j/k/g/e/y// and friends) require vim mode (/vim-mode or [ui] vim_mode = true); the arrow-key equivalents always work.

Configuration files ​

PathPurpose
~/.grok/config.tomlUser configuration (Windows: %USERPROFILE%\.grok\config.toml)
<project>/.grok/config.tomlProject configuration; only [mcp_servers], [plugins], [permission] are read
~/.grok/sandbox.toml / .grok/sandbox.tomlCustom sandbox profiles
~/.grok/hooks/*.json / <project>/.grok/hooks/*.jsonHook definitions
~/.grok/skills/ / ./.grok/skills/Skill directories
~/.grok/plugins/ / ./.grok/plugins/Plugin directories
~/.grok/agents/ / .grok/agents/Custom subagent types
~/.grok/personas/*.toml / .grok/personas/*.tomlPersona definitions
~/.grok/workflows/*.rhai / .grok/workflows/*.rhaiWorkflows
~/.grok/sessions/Session history (indexed by working directory)
~/.grok/worktrees/<repo>/<name>Session worktrees
~/.grok/mcp_credentials.jsonMCP OAuth tokens
~/.grok/trusted_folders.tomlTrusted project directories
~/.grok/logs/mcp/<server>.stderr.logstderr of MCP stdio servers
/etc/grok/requirements.tomlSystem-level managed policy (the tamper lock is honored only from root-owned sources)

Instruction files: the AGENTS.md family (AGENTS.md / Agents.md / AGENT.md) and the Claude family (CLAUDE.md / Claude.md / CLAUDE.local.md / .claude/rules/) are read from the cwd upward to the repository root.

Common configuration keys ​

Source: Settings Reference

SectionKeyNotes
[models]defaultModel used by new sessions
[models]allowed_models / hidden_models / disabled_modelsRestrict selectable models (glob list / ID list)
[model.<id>]model / base_url / name / env_key / api_backendCustom or BYOK model
[model.<id>]context_windowContext window size; affects when auto-compaction kicks in
[tools]respect_gitignoreDefault false; when true, search/read tools skip gitignored files
[toolset]file_toolsetstandard (default) or hashline
[toolset.bash]timeout_secs / output_byte_limit / max_timeout_secsDefaults 120 s / 20000 bytes / 36000 s
[toolset.bash]auto_background_on_timeoutDefault true; moves to background on timeout
[toolset.web_fetch]allowed_domains / proxy_endpointDomain allowlist and egress proxy for web_fetch
[sandbox]profile / auto_allow_bashSandbox profile; skip bash prompts while the sandbox is active
[permission]rulesallow / deny rules
[ui]permission_mode"ask" / "auto" / "always-approve"; user config only
[ui]disable_bypass_permissions_modeGlobally lock out always-approve (root-owned sources only)
[ui]vim_modevim keys in the scrollback
[features]web_fetch / lsp_tools / write_file / tool_searchlsp_tools off by default; write_file / tool_search on
[subagents]enabled / toggle / modelsMaster switch / per-type switch / per-type model routing
[memory]enabledCross-session memory master switch, off by default
[skills] / [plugins]paths / disabled / enabledExtra directories / discovered but inactive / explicitly enabled
[compat.claude] / [compat.cursor]skills / rules / agents / mcps / hooksWhether to scan those directories; all default true
[dashboard]enabledAgent Dashboard master switch
[workflows]enabledWorkflow master switch
[mcp_servers.<name>]startup_timeout_sec / tool_timeout_secDefaults 30 / 6000 seconds

Environment variables ​

VariableDefaultNotes
GROK_HOME~/.grokHome for configuration, auth, sessions, skills, plugins, logs
XAI_API_KEY—API key when not using browser login (CI / headless)
GROK_DEFAULT_MODELdirectory / configDefault model for sessions
GROK_XAI_API_BASE_URLhttps://api.x.ai/v1xAI API base when authenticating with an API key
GROK_MODELS_BASE_URL—Custom inference base URL
GROK_DISABLE_AUTOUPDATERunsetSet to disable auto-update (CI / containers)
GROK_SANDBOXoffSandbox profile, equivalent to --sandbox
GROK_SANDBOX_AUTO_ALLOW_BASH0Auto-allow bash while the sandbox is active
GROK_RESPECT_GITIGNOREfollows configForce search/read filtering by gitignore
GROK_WEB_FETCH0Enable the web_fetch tool, off by default (security)
GROK_WEB_FETCH_PROXY—Egress proxy for web_fetch
GROK_MEMORY0Cross-session memory
GROK_SUBAGENTS0Enable subagents / the task tool (1/0). The subagents page also says they are "Enabled by default when the setting is unset." Those two official sentences disagree — do not guess which wins; check grok inspect on your machine.
GROK_WRITE_FILE1Set 0 to disable the write tool (read-only sessions)
GROK_TOOL_SEARCH1On-demand MCP tool discovery for large tool sets
GROK_LSP_TOOLS0LSP code-intelligence tools
GROK_AGENTgrok-buildBuilt-in agent name, profile, or absolute path to an agent definition
GROK_AGENT_DASHBOARD—Set 0 to disable the Agent Dashboard
GROK_WORKFLOWS—Set 0 to disable workflows
GROK_THEMEbuilt-inColor theme
GROK_MCP_STARTUP_TIMEOUT_SECS30Global MCP startup handshake timeout, in seconds
MCP_TIMEOUTsame settingClaude-compatible MCP startup timeout, in milliseconds; checked before the one above
GROK_LOG_FILE—Write logs to this path
RUST_LOG—Log filter (e.g. debug)
GROK_CRASH_HANDLER0Write panic reports to $GROK_HOME/crash/
HTTPS_PROXY / HTTP_PROXY / NO_PROXYsystemStandard proxy variables

The compatibility-scanner switches all default to on: GROK_CURSOR_{SKILLS,RULES,AGENTS,MCPS,HOOKS}_ENABLED, GROK_CLAUDE_{SKILLS,RULES,AGENTS,MCPS,HOOKS}_ENABLED.

Additional UI variables include GROK_SHOW_THINKING_BLOCKS, GROK_GROUP_TOOL_VERBS, GROK_COLLAPSED_EDIT_BLOCKS, GROK_PROMPT_SUGGESTIONS, GROK_SCROLL_SPEED, GROK_SCROLL_MODE, GROK_SCROLL_LINES, GROK_INVERT_SCROLL, GROK_DEFAULT_SELECTED_PERMISSION, GROK_REMEMBER_TOOL_APPROVALS, GROK_MOUSE_REPORTING_TOGGLE, GROK_DISPLAY_REFRESH_AUTO_CADENCE; full defaults are in the official Settings Reference.

Hook events ​

EventWhen it fires
SessionStart / SessionEndSession starts / ends
UserPromptSubmitYou submit a prompt
PreToolUseA tool is about to run — the only blocking event
PostToolUse / PostToolUseFailureTool finished / failed
PermissionDeniedThe permission system denied a call
Stop / StopFailureTurn ended / ended due to an API error
NotificationThe agent emits a notification
SubagentStart / SubagentStopSubagent starts / stops
PreCompact / PostCompactBefore / after conversation compaction

Exit code 0 allows, exit code 2 blocks, and everything else (timeout, crash, malformed output) fails open.

Models and pricing ​

Source: Models. Prices are US dollars per million tokens.

ModelContextInputCached inputOutput
grok-4.6 (prompt < 200k)500k$2.00$0.50$6.00
grok-4.6 (prompt ≥ 200k)500k$4.00$1.00$12.00
grok-build-0.1 (prompt < 200k)256k$1.00$0.20$2.00
grok-build-0.1 (prompt ≥ 200k)256k$2.00$0.40$4.00

Long-context billing rule: once a prompt reaches the threshold, every token in that request is billed at the higher tier — it is not just the excess that costs more.

Official model-selection advice:

For everything else, including code, use Grok 4.6. It is the most intelligent and fastest model we've built.

grok-4.6 has a knowledge cutoff of 2026-02-01. Alias rules: <modelname> points at the latest stable release, <modelname>-latest at the latest release, and <modelname>-<date> pins a specific one.

Prices for other models (grok-4.5, grok-4.3, the grok-4.20-* series, Imagine image/video, Voice) are on the official page.

High-quality sources ​

Last verified 2026-08-18. Ordered by reliability and freshness. The changelog can list commands before CLI Reference does (the research note recorded grok du and grok trace appearing on the changelog first) — check it first for behavior the docs do not mention.

First-party official ​

SourceUse
docs.x.ai/build/overviewGrok Build documentation entry point
docs.x.ai/build/cli/referenceSubcommands and flags
docs.x.ai/build/cli/headless-scriptingHeadless and ACP
docs.x.ai/build/cli/terminal-supportTerminal compatibility and diagnostics
docs.x.ai/build/modes-and-commandsFull mode and slash-command tables
docs.x.ai/build/keyboard-shortcutsFull key-binding table
docs.x.ai/build/settingsConfig layers and precedence
docs.x.ai/build/settings/referenceFull env var and TOML key tables
docs.x.ai/build/enterpriseManaged config, SSO, ZDR, CI permission modes
docs.x.ai/build/features/permissionsPermission model
docs.x.ai/build/features/sandboxSandbox profiles
docs.x.ai/build/features/hooksHook events and the script contract
docs.x.ai/build/features/mcp-serversMCP configuration
docs.x.ai/build/features/skills-plugins-marketplacesSkills / plugins / marketplaces
docs.x.ai/build/features/sessionsSessions, fork, rewind, compact
docs.x.ai/build/features/worktreesWorktrees
docs.x.ai/build/features/subagentsSubagents and personas
docs.x.ai/build/features/background-tasksBackground tasks, /loop, monitors
docs.x.ai/build/features/dashboardAgent Dashboard
docs.x.ai/developers/modelsModel list and pricing
docs.x.ai/grok/overviewgrok.com / apps consumer overview
docs.x.ai/developers/model-capabilities/imagineImagine API (images and video)
docs.x.ai/grok-bot/overviewGrok Bot product entry
docs.x.ai/grok-bot/get-startedGrok Bot install and first task
docs.x.ai/grok-bot/computer-and-appsShared cloud computer
docs.x.ai/grok-bot/faqGrok Bot platforms, cost, memory

Efficiency tricks ​

TrickNotes
docs.x.ai/llms.txtSingle-file full-text mirror of the whole docs site; good for local grep or feeding a model (it is large — do not commit it to a repo). Last verified 2026-08-18, HTTP 200.
https://docs.x.ai/api/mcpOfficial docs MCP endpoint (Streamable HTTP, stateless); tools list_doc_pages / get_doc_page. Browser GET/HEAD is not a docs page — 2026-08-18: HEAD 405, GET/POST 406, OPTIONS 204. Use an MCP client, not a browser.
grok inspect --jsonFastest way to answer "what is actually loaded on this machine"

Versions and source ​

SourceUse
x.ai/build/changelogChangelog; updated faster than the docs site
x.ai/news/grok-build-cliLaunch announcement (2026-05-25, early beta)
x.ai/news/grok-4-6Grok 4.6 announcement (mentions time-boxed 2x included usage in Grok Build; no standing quota number)
x.ai/grokConsumer Grok (chat / Imagine / voice)
grok.com/imagineConsumer Imagine
x.ai/grok/build-modeBuild Mode marketing (not Grok Build CLI)
x.ai/news/grok-build-modeBuild Mode launch; SuperGrok Heavy Early Beta; grok.me publish host
x.ai/botGrok Bot marketing + downloads
x.ai/news/introducing-grok-botGrok Bot launch (2026-08-11, beta)
github.com/xai-org/grok-buildSource (Rust, Apache-2.0); external PRs are not accepted, feedback goes through /feedback
github.com/xai-org/plugin-marketplaceOfficial plugin marketplace catalog
npmjs.com/package/@xai-official/grokRelease cadence and version history

Access note (re-checked 2026-08-18): x.ai/build and x.ai/build/changelog return 403 to command-line curl (Cloudflare). x.ai/news/grok-build-cli and x.ai/cli/install.sh returned 200. docs.x.ai pages above returned 200. npmjs.com HTML returned 403; the registry JSON at https://registry.npmjs.org/@xai-official/grok is readable.

Built for frontend engineers · Powered by VitePress