Grok Build Cheatsheet
The complete command map for Grok Build: from first launch to headless automation, permissions, worktrees, MCP, plugins, memory, and every fixed TUI command in the source reference.
Searches every command, example, table, and note in the source.
As of July 16, 2026, the latest official Grok Build release is v0.2.101, published July 13. The official CLI Reference documents the most commonly used options, while plugins, Skills, experiments, and account entitlements can add commands dynamically. This reference combines fixed commands from official documentation, recent changelog additions, and conditionally available commands. ([SpaceXAI][1])
Check the real command surface installed on your machine first:
grok version
grok --help
grok <subcommand> --helpInside Grok Build, run:
/helpYou can also type / to open the command menu for the installed version.
Install, launch & login
Install on macOS, Linux, WSL, or Windows; launch in a project or selected directory; authenticate with OAuth, device flow, or XAI_API_KEY.
1. Install
macOS, Linux, and WSL:
curl -fsSL https://x.ai/cli/install.sh | bashWindows PowerShell:
irm https://x.ai/cli/install.ps1 | iex2. Launch
cd your-project
grokLaunch in a specific working directory:
grok --cwd /path/to/projectUse an API key:
export XAI_API_KEY="xai-..."
grok3. Sign in and sign out
grok login
grok login --device-auth
grok logout--device-auth is intended for SSH sessions, servers, containers, WSL, and other environments where opening a browser is inconvenient. (SpaceXAI Docs)
Top-level CLI commands
All documented top-level commands for interactive work, authentication, inspection, models, MCP, plugins, sessions, imports, memory, worktrees, dashboard, ACP, terminal wrapping, updates, completions, and managed setup.
These are the top-level commands currently listed by the official CLI Reference. (SpaceXAI Docs)
| Command | Purpose |
|---|---|
grok | Start the interactive terminal interface. |
grok login | Sign in to Grok Build. |
grok logout | Sign out and remove cached credentials. |
grok inspect | Show configuration, rules, Skills, plugins, Hooks, and MCP loaded for the current directory. |
grok models | List models currently available to the account or API key. |
grok mcp ... | Manage MCP servers. |
grok plugin ... | Manage plugins. |
grok plugin marketplace ... | Manage plugin marketplace sources. |
grok sessions ... | List, search, and delete sessions. |
grok export ... | Export session records. |
grok import ... | Import Claude Code sessions. |
grok memory clear ... | Clear cross-session memory. |
grok worktree ... | Manage Git Worktrees created by Grok. |
grok dashboard | Open the Agent Dashboard. |
grok agent stdio | Run as an ACP agent. |
grok wrap ... | Wrap SSH, Docker, kubectl, and similar terminal commands. |
grok update | Check for or install updates. |
grok version | Print the installed version. |
grok completions ... | Generate shell completions. |
grok setup | Fetch and install managed configuration. |
Diagnostics, models & config
Inspect effective rules and extensions, list account-accessible models, select models and effort, check the version, generate shell completions, and install managed configuration.
grok inspect
Show exactly what Grok discovers in the current directory:
grok inspect
grok inspect --jsonThe report normally includes configuration sources, AGENTS.md and CLAUDE.md files, Skills, plugins, Hooks, MCP servers, Claude/Cursor/Codex-compatible configuration, authentication, and model settings. This is the most important command when a Skill, MCP server, Hook, or rule is not taking effect.
grok models
grok modelsLists models accessible through the current account, API key, or custom model endpoint.
Choose a model at launch:
grok -m <model-id>
grok --model <model-id>Switch models in the interactive interface:
/model <model-id>
/m <model-id>Version, completions, and managed setup
grok version
grok completions bash
grok completions zsh
grok completions fish
grok setupgrok setup primarily fetches and installs organization-managed Grok Build configuration. (SpaceXAI Docs)
Headless & scripting
Run one-shot prompts with plain, JSON, streaming JSON, or JSON Schema output; disable updates in CI and expose Grok through ACP stdio.
One-shot execution
grok -p "Explain this repository"
grok --single "Explain this repository"-p and --single run one task and then exit, which is useful for scripts, CI, bots, and automation. ([SpaceXAI Docs][4])
Output formats
grok -p "List all TODO comments" --output-format plain
grok -p "List all TODO comments" --output-format json
grok -p "Explain the architecture" --output-format streaming-json| Format | Behavior |
|---|---|
plain | Human-readable text. |
json | One JSON object after the task completes. |
streaming-json | A continuous stream of newline-delimited JSON events. |
JSON Schema output
grok -p "Analyze this project" \
--json-schema '{"type":"object","properties":{"language":{"type":"string"}},"required":["language"]}'--json-schema requires Headless mode to return JSON matching the supplied schema instead of free-form text. ([SpaceXAI][1])
CI and ACP
grok --no-auto-update -p "Run the test suite"
grok \
--no-auto-update \
--always-approve \
--output-format json \
-p "Review this pull request"
grok agent stdioACP mode communicates over stdin/stdout using JSON-RPC and is designed for IDEs, editors, and other agent clients. (SpaceXAI Docs)
Global CLI options
Complete global flag matrix for sessions, directories, models, effort, permissions, allow/deny filters, sandbox profiles, prompts, tools, feature switches, and terminal presentation.
Session and directory options
| Option | Purpose |
|---|---|
--cwd <PATH> | Set the working directory. |
-r, --resume [<ID>] | Resume a session; omit the ID to resume the latest session. |
-c, --continue | Continue the latest session for the current directory. |
-s, --session-id <UUID> | Assign a UUID to a new session. |
--fork-session | Create a branched session when resuming. |
-w, --worktree [<NAME>] | Start in a new Git Worktree. |
--ref <REF> | Choose the branch, tag, or commit used as the Worktree base. |
--session-id names a new session; it does not resume an existing one. Use --resume for that. ([SpaceXAI Docs][3])
Model and reasoning options
| Option | Purpose |
|---|---|
-m, --model <MODEL> | Select a model. |
--effort <LEVEL> | Set reasoning effort. |
--reasoning-effort <LEVEL> | Alias for --effort. |
--max-turns <N> | Limit the maximum number of agent turns. |
Available effort levels vary by model. Check with grok models or /effort. --reasoning-effort has been equivalent to --effort since v0.2.89. ([SpaceXAI][1])
Permissions
| Option | Purpose |
|---|---|
--always-approve | Automatically approve every tool call. |
--yolo | Alias for --always-approve. |
--permission-mode <MODE> | Select a permission mode. |
--allow <RULE> | Add an allow rule. |
--deny <RULE> | Add a deny rule. |
--sandbox <PROFILE> | Enable a sandbox profile. |
--no-ask-user | Prevent the agent from asking the user. |
--dangerously-skip-permissions | Claude Code compatibility alias. |
Headless permission modes:
| Value | Behavior |
|---|---|
default | Use the default permission behavior. |
dontAsk | Reject operations that are not explicitly allowed. |
acceptEdits | Auto-approve file edits but still ask about shell commands. |
bypassPermissions | Skip permission checks. |
plan | Plan mode. |
grok -p "Review the API changes" \
--permission-mode dontAsk \
--allow 'Bash(git *)' \
--allow 'Bash(gh *)' \
--allow 'Read' \
--allow 'Grep' \
--deny 'Bash(rm -rf *)'Permission filters include Bash, Edit, Read, Grep, MCPTool, and WebFetch:
--allow 'Bash(git *)'
--allow 'Edit(**/*.ts)'
--allow 'MCPTool(linear__*)'
--deny 'Edit(**/.env)'Deny rules take precedence over allow rules. ([SpaceXAI Docs][5])
Sandbox profiles
grok --sandbox off
grok --sandbox workspace
grok --sandbox read-only
grok --sandbox strict
grok --sandbox my-custom-profile| Profile | Recommended use |
|---|---|
off | Disable sandboxing. |
workspace | Daily development with writes restricted to the workspace and approved locations. |
read-only | Audits and read-only analysis. |
strict | Untrusted repositories and high-security environments. |
devbox | Cloud development environments. |
| Custom name | Load a custom profile from sandbox.toml. |
The sandbox is applied when the process starts and cannot be fully removed in the middle of that process. ([SpaceXAI Docs][5])
Prompt and tool options
| Option | Purpose |
|---|---|
--rules <TEXT> | Append rules to the system prompt. |
--system-prompt-override <TEXT> | Replace the complete system prompt. |
--tools <LIST> | Select allowed built-in tools. |
--disallowed-tools <LIST> | Remove tools. |
--allowedTools | Claude Code compatibility alias. |
--disallowedTools | Claude Code compatibility alias. |
--append-system-prompt | Claude Code compatibility alias. |
--system-prompt | Claude Code compatibility alias. |
grok \
--rules "Do not modify generated files. Run tests after every change." \
-p "Refactor the authentication module"Feature switches
| Option | Purpose |
|---|---|
--no-plan | Disable planning. |
--no-subagents | Disable subagents. |
--no-memory | Disable memory. |
--disable-web-search | Disable web search. |
--experimental-memory | Enable cross-session memory. |
--oauth | Force OAuth on the welcome screen. |
--plugin-dir <PATH> | Load an additional plugin directory. |
--hunk-tracker-mode <MODE> | Configure or disable the code hunk tracker. |
--hunk-tracker-mode is a low-level, versioned option; use local grok --help for its current values. (SpaceXAI Docs)
Interface options
| Option | Purpose |
|---|---|
--no-alt-screen | Run inline instead of using the terminal alternate screen. |
--minimal | Start with the compact terminal layout. |
--fullscreen | Force the full-screen TUI. |
--no-auto-update | Disable the update check for this run. |
The --minimal and --fullscreen preference is remembered for future launches. (SpaceXAI)
Session management
Resume or continue sessions, list/search/delete history, export to files or clipboard, import Claude Code sessions, and capture a new session ID for scripted continuation.
Resume or continue work:
grok --resume <session-id>
grok --resume
grok -cList, search, and delete sessions:
grok sessions list
grok sessions search "authentication"
grok sessions delete <session-id>Export a session to stdout, a file, or the clipboard:
grok export <session-id>
grok export <session-id> output.md
grok export <session-id> --clipboardImport Claude Code sessions:
grok import
grok import <target>
grok import <target1> <target2>Capture a new session ID and continue it later:
SESSION_ID=$(
grok -p "Start the refactor" \
--output-format json |
jq -r '.sessionId'
)
grok -r "$SESSION_ID" -p "Continue and run tests"Git Worktrees
Start isolated Worktree sessions, distinguish named-worktree syntax, inspect or remove managed Worktrees, preview removal, and garbage-collect missing or stale records.
Start a Worktree session
grok -w
grok --worktree
grok --worktree=feat "Refactor module X"
grok -w --ref main "Fix the flaky test"
grok -w -r <session-id>In grok --worktree=feat "Refactor module X", feat is the Worktree name. With grok --worktree feat, some parsers may treat feat as the prompt, so the explicit equals-sign form is recommended.
Manage Worktrees
grok worktree list
grok worktree ls
grok worktree show <id>
grok worktree rm <id>
grok worktree rm <id1> <id2>
grok worktree rm <id> --dry-run
grok worktree gc
grok worktree gc --max-age 7d| Command | Purpose |
|---|---|
list / ls | List Worktrees managed by Grok. |
show | Show details for one Worktree. |
rm | Remove one or more Worktrees. |
rm --dry-run | Preview removal without changing anything. |
gc | Remove records whose directories no longer exist. |
gc --max-age 7d | Remove unused Worktrees idle for more than seven days. |
MCP commands
List MCP servers, add stdio or remote HTTP transports, attach repeatable headers and environment variables, choose project scope, remove servers, and run doctor diagnostics.
List servers
grok mcp list
grok mcp list --jsonAdd a local stdio server
grok mcp add filesystem -- \
npx -y @modelcontextprotocol/server-filesystem /path/to/dirEverything after -- is the real MCP server launch command.
Add a remote HTTP server
grok mcp add \
--transport http \
linear \
https://mcp.linear.app/mcpAdd headers
grok mcp add \
--transport http \
api \
https://mcp.example.com/mcp \
--header "Authorization: Bearer ${API_TOKEN}"
grok mcp add \
--transport http \
example \
https://example.com/mcp \
-H "Authorization: Bearer ${TOKEN}" \
-H "X-Team-ID: ${TEAM_ID}"Headers may be repeated.
Project-scoped MCP
grok mcp add \
--scope project \
filesystem -- \
npx -y @modelcontextprotocol/server-filesystem .This writes .grok/config.toml in the project rather than user-global configuration.
Remove and diagnose
grok mcp remove <name>
grok mcp doctor
grok mcp doctor <name>
grok mcp doctor --json
grok mcp doctor <name> --jsonRelated options include -e for environment variables, -H / --header, --transport, and --scope project. (SpaceXAI Docs)
Plugins & Marketplace
List, install, uninstall, update, enable, disable, inspect, and validate plugins; manage remote or local Marketplace sources and understand extension-provided capabilities.
Plugin commands
grok plugin list
grok plugin install ...
grok plugin uninstall ...
grok plugin update ...
grok plugin enable ...
grok plugin disable ...
grok plugin details ...
grok plugin validate ...| Subcommand | Purpose |
|---|---|
list | Show discovered or installed plugins. |
install | Install a plugin. |
uninstall | Uninstall a plugin. |
update | Update a plugin. |
enable | Enable a plugin. |
disable | Disable a plugin. |
details | Show plugin details. |
validate | Validate plugin structure and configuration. |
Marketplace commands
grok plugin marketplace list
grok plugin marketplace add ...
grok plugin marketplace remove ...
grok plugin marketplace update ...A Marketplace source may be a configured remote source or a local directory. Accepted arguments vary by source, so verify them with:
grok plugin install --help
grok plugin marketplace add --helpPlugins can contribute Skills, Agents, Hooks, MCP servers, LSP servers, and slash commands. (SpaceXAI Docs)
Updates
Check for updates, install a specific version, or switch between Alpha and Stable channels.
grok update
grok update --check
grok update --version <VERSION>
grok update --alpha
grok update --stableExample:
grok update --check
grok update --version 0.2.101
grok update --alpha
grok update --stable| Option | Purpose |
|---|---|
| No option | Update to the latest release on the current channel. |
--check | Check without installing. |
--version <V> | Install a specific version. |
--alpha | Switch to or install the Alpha channel. |
--stable | Switch to or install the Stable channel. |
Terminal proxy: grok wrap
Wrap SSH, Docker, and kubectl terminal commands so remote OSC 52 clipboard data reaches the local clipboard; this feature remains experimental.
grok wrap <command...>Common forms:
grok wrap ssh user@host
grok wrap docker exec -it container bash
grok wrap kubectl exec -it pod-name -- bashgrok wrap runs the target command in a local PTY, receives OSC 52 clipboard content emitted by the remote process, and forwards it to the local clipboard. It is useful when running Grok through SSH, inside Docker containers, in Kubernetes Pods, or whenever remote copy operations cannot reach the local clipboard. The feature is currently marked experimental. (SpaceXAI Docs)
Fixed TUI slash commands
Every fixed TUI command: help and navigation, sessions, context, history, models, permissions, plans, goals, background tasks, media, UI, diagnostics, extensions, memory, account, privacy, feedback, and releases.
Type these commands after entering the interactive grok interface.
1. Help and navigation
| Command | Purpose |
|---|---|
/help | Open command and keyboard-shortcut help. |
/docs | Open the official guide and jump by heading. |
/home | Return to the welcome page. |
/quit | Exit. |
/exit | Alias for /quit. |
/new | Start a new session. |
/clear | Alias for /new. |
/docs was added in v0.2.87 and may be absent from older Modes pages. ([SpaceXAI Docs][10])
2. Sessions
| Command | Purpose |
|---|---|
/resume | Resume a previous session. |
/sessions | Open sessions or the Agent Dashboard. |
/fork | Create a parallel session from the current context. |
/fork --worktree | Fork into an isolated Worktree. |
/fork --no-worktree | Fork without creating a Worktree. |
/rename <title> | Rename the current session. |
/title <title> | Alias for /rename. |
/share | Create a share link for the session. |
/session-info | Show session details. |
/export | Export the current session. |
/recap | Generate a session recap manually. |
Newer versions open the Agent Dashboard directly from /sessions instead of showing only a simple history picker. ([SpaceXAI Docs][10])
3. Context and history
| Command | Purpose |
|---|---|
/context | Show context usage. |
/compact [instructions] | Compact the conversation context. |
/rewind | Return to an earlier user turn and restore file state. |
/copy [N] | Copy the latest or Nth-latest response. |
/find | Search the current scrollback. |
/history | Search prompt history. |
/transcript | Open the full transcript in $PAGER. |
/compact Preserve the API design decisions and unresolved bugs
/copy
/copy 2/history is a newer prompt-history search command. ([SpaceXAI Docs][10])
4. Models and reasoning
| Command | Purpose |
|---|---|
/model <name> | Switch models. |
/m <name> | Alias for /model. |
/effort | Change reasoning effort for the current model. |
/personas | Manage personas. |
/config-agents | Manage agent definitions. |
/agents | Alias for /config-agents. |
5. Permissions and work modes
| Command | Purpose |
|---|---|
/auto | Toggle automatic permission classification. |
/always-approve | Toggle automatic approval for everything. |
/plan [description] | Enter plan mode. |
/view-plan | View the current plan. |
/goal <objective> | Start goal-driven mode. |
/code-review | Run the built-in code-review workflow. |
Run /auto or /always-approve again to turn the mode off. /goal may depend on the account or a feature flag. /code-review has shipped as a built-in command since v0.2.51. ([SpaceXAI][1])
6. Side questions
/btw <question>
/btw Why did you choose Redis instead of PostgreSQL?This asks a side question while minimizing disruption to the main task.
7. Background tasks and queue
| Command | Purpose |
|---|---|
/tasks | Show background commands, subagents, monitors, and scheduled tasks. |
/queue | Show prompts waiting to run. |
/loop [interval] <prompt> | Run a prompt periodically. |
/dashboard | Open the Agent Dashboard. |
/loop 5m Check whether the test suite passes and report failures
/loop 1h Check deployment health
/loop 1d Review new dependency updatesIntervals use Ns, Nm, Nh, or Nd. Seconds have a minimum of 60. Loops can run for at most seven days, with up to 50 scheduled tasks at once. ([SpaceXAI Docs][11])
8. Image and video generation
/imagine <prompt>
/imagine-video <prompt>
/imagine A clean isometric diagram of this system architecture
/imagine-video Animate this product mockup into a short presentationAvailability depends on the account, model, and media-generation access. ([SpaceXAI Docs][10])
9. UI and display
| Command | Purpose |
|---|---|
/settings | Open settings. |
/config | Alias for /settings. |
/theme [name] | Switch themes. |
/t [name] | Alias for /theme. |
/compact-mode | Toggle the compact layout. |
/multiline | Toggle multiline input. |
/ml | Alias for /multiline. |
/vim-mode | Toggle Vim-style scrolling. |
/timestamps | Show or hide message timestamps. |
/minimal | Switch the current session to Minimal mode. |
/fullscreen | Switch the current session to Fullscreen mode. |
Built-in themes:
groknight
dark
grokday
light
day
tokyonight
tokyo
rosepine
rose-pine-moon
oscura
oscura-midnight
auto
system([SpaceXAI Docs][10])
10. Terminal diagnostics
/terminal-setup
/terminal-check
/terminal-infoThese equivalent commands check terminal type, True Color, clipboard transport, OSC 52, tmux/SSH state, Fullscreen support, and likely compatibility problems. ([SpaceXAI Docs][9])
11. Plugins, Skills, Hooks, and MCP
| Command | Purpose |
|---|---|
/hooks | Open the Hooks tab in Extensions. |
/hooks-trust | Trust Hooks in the current project. |
/plugins | Open the Plugins tab. |
/marketplace | Open the Marketplace tab. |
/skills | Open the Skills tab. |
/mcps | Open the MCP tab. |
All six commands open the same Extensions panel with a different default tab.
Inside /mcps:
| Key | Purpose |
|---|---|
Space | Enable or disable an MCP server. |
r | Reload configuration. |
i | Complete OAuth sign-in. |
a | Add an MCP server. |
x | Remove an MCP server. |
Project Hooks in .grok/hooks/ require /hooks-trust first. ([SpaceXAI Docs][12])
12. Memory
| Command | Purpose |
|---|---|
/remember <note> | Save a memory. |
/memory | Browse and manage memory. |
/mem | Alias for /memory. |
/flush | Write session memories to disk immediately. |
/dream | Run memory consolidation. |
/memory, /mem, /flush, and /dream appear only when cross-session memory is enabled.
grok memory clear --workspace
grok memory clear --global
grok memory clear --all13. Account, usage, and privacy
| Command | Purpose |
|---|---|
/login | Sign in again from the TUI. |
/logout | Sign out from the TUI. |
/usage | Show allowance, credits, or billing. |
/cost | Alias for /usage. |
/privacy | View or change data retention for the session. |
/usage and /cost depend on account type and may be hidden for free accounts, some X plans, or API-key sessions. (SpaceXAI Docs)
14. Import, feedback, and release information
| Command | Purpose |
|---|---|
/import-claude | Open Claude settings import. |
/feedback [text] | Send feedback. |
/release-notes | Show release notes for the current version. |
/changelog | Alias for /release-notes. |
Dynamic Skill commands
User-invocable Skills become slash commands, support namespaces for collisions, and may come from project, user, plugin, Agents, or Claude-compatible directories.
Every Skill marked as user-invocable automatically becomes a slash command:
/<skill-name>
/commit
/deploy
/review-pr
/generate-testsIf multiple sources provide the same Skill name, use a namespace:
/local:commit
/plugin-name:deploySkills may come from:
./.grok/skills/
~/.grok/skills/
plugin skills/ directories
~/.agents/skills/
~/.agents/commands/
Claude Code plugins and SkillsThe local slash-command list can therefore be larger than the fixed commands documented here. (SpaceXAI Docs)
TUI shell commands
Prefix a prompt with ! to execute Shell commands directly; long-running processes may move to the background and remain visible through /tasks.
Prefix a prompt with ! to execute a Shell command directly:
!git status
!pnpm test
!npm run build
!docker compose psThis runs the command directly rather than interpreting it as a natural-language task. Long-running commands may move to the background and remain visible through /tasks. (SpaceXAI)
File reference syntax
Use @ paths to attach files or directories to a prompt for explanation, auditing, or refactoring.
Use @ in a prompt to reference files or directories:
@src/main.ts Explain this file
@package.json Check for outdated dependencies
@src/auth/ Refactor this moduleThis is input syntax rather than a separate slash command, but it is one of the most frequently used Grok Build features. (SpaceXAI Docs)
Historical & unstable commands
Treat removed or unstable commands such as /execute-plan and grok agent --leader as unsupported unless the local /help confirms them.
Changelogs have previously mentioned commands or internal options that the current official Reference no longer lists:
/execute-plan
grok agent --leader/execute-plan existed in at least some May 2026 releases. It may have been replaced by Plan mode, /view-plan, and the normal execution flow, or may remain enabled only in some environments. Do not use historical commands in stable automation unless local /help confirms they are still available. (SpaceXAI)
Practical command recipes
Ready-to-run recipes for read-only repository analysis, automated fixes, CI review, parallel Worktree development, schema-constrained JSON, and Git-only permissions.
Analyze an unfamiliar repository safely
grok \
--sandbox read-only \
--permission-mode dontAsk \
-p "Analyze the architecture and identify security risks"Modify code and run tests automatically
grok \
--sandbox workspace \
--always-approve \
-p "Fix the failing tests, run the test suite, and summarize the changes"CI code review
grok \
--no-auto-update \
--sandbox read-only \
--permission-mode dontAsk \
--allow 'Read' \
--allow 'Grep' \
--allow 'Bash(git *)' \
--output-format json \
-p "Review the current diff and return actionable findings"Parallel feature development
grok \
--worktree=feature-auth \
--ref main \
"Implement OAuth login and add tests"Structured output
grok \
-p "Audit this repository" \
--output-format json \
--json-schema '{
"type": "object",
"properties": {
"summary": {"type": "string"},
"risks": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["summary", "risks"]
}'Allow only Git and GitHub CLI
grok \
--permission-mode dontAsk \
--allow 'Read' \
--allow 'Grep' \
--allow 'Bash(git *)' \
--allow 'Bash(gh *)' \
--deny 'Bash(*)' \
-p "Review the open pull request"Summary
The current command surface consists of roughly 20 top-level CLI commands, more than 40 fixed slash commands, over a dozen recent changelog additions, dynamically generated plugin and Skill commands, and the Headless, permission, Sandbox, Worktree, and structured-output options described above.
The most reliable local inventory is:
grok version
grok --help
grok mcp --help
grok plugin --help
grok sessions --help
grok worktree --helpInside the TUI, run:
/help
/docsGrok Build changes frequently, so check weekly for new commands, altered flags, and deprecations.