Grok Build is SpaceXAI’s terminal coding agent. It can inspect a repository, edit files, run commands, search the web, delegate work to subagents, and run non-interactively in scripts or CI.
Its controls are spread across CLI flags, slash commands, keyboard shortcuts, and project files. This Grok Build cheat sheet puts the main commands in one place and includes working examples for worktrees, automation, extensions, and safety settings.
Read More: Grok Build: SpaceXAI’s Open-source Terminal AI Coding Agent
Last audited: July 23, 2026
Grok Build changes quickly. Rungrok --helporgrok <command> --helpif your installed version differs from this reference.
Table Of Contents
- Grok Build essentials
- Install and start Grok Build
- CLI commands and launch options
- Common launch flags
- Sessions and context
- Models, modes, and input
- Extensions, agents, and scheduled work
- Account, diagnostics, and help
- Scrollback navigation
- A practical user configuration
- Project instructions with AGENTS.md
- Custom models
- Structured output and session continuation
- Limit a review to read-only tools
- Compatibility permission modes
- Sandbox profiles
- Block secrets with a custom profile
- FAQs
Grok Build essentials
| Task | Command or shortcut |
|---|---|
| Start in the current project | grok |
| Start with a task | grok "Explain this repository" |
| Attach a file to a prompt | @src/main.rs Explain this file |
| Run a shell command inside the TUI | Type ! on an empty prompt. |
| Plan before changing files | /plan or Shift+Tab |
| Cancel a running turn | Ctrl+C |
| Send a correction immediately | Ctrl+Enter or Ctrl+I |
| Check context usage | /context |
| Compact a long conversation | /compact |
| Resume the latest project session | grok --continue |
| Restore an earlier turn | /rewind |
| Inspect loaded rules and extensions | grok inspect |
| Run one headless task | grok -p "Your task" |
| Start in an isolated worktree | grok --worktree=task-name "Your task" |
Install and start Grok Build
| System | Install command |
|---|---|
| macOS, Linux, WSL, or Git Bash | curl -fsSL https://x.ai/cli/install.sh | bash |
| Windows PowerShell | irm https://x.ai/cli/install.ps1 | iex |
The Windows installer adds %USERPROFILE%\.grok\bin to your user PATH. WSL receives the Linux binary. After installation, confirm that the shell can find Grok Build:
grok --version
grok updateOpen a terminal in your project directory and start the interactive interface:
cd your-project
grokThe first launch opens a browser for sign-in. Grok Build stores the resulting credentials in ~/.grok/auth.json. On a remote machine or another system without a browser, use device authentication:
grok login --device-authCI jobs can authenticate with an API key. Keep the key in your CI secret store:
# macOS, Linux, or WSL
export XAI_API_KEY="xai-..."
# PowerShell
$env:XAI_API_KEY="xai-..."CLI commands and launch options
Shell commands start with grok and run outside the interactive TUI. You can use grok <command> --help to list the available options for a subcommand.
| Command | What it does |
|---|---|
grok | Open the interactive TUI in the current directory. |
grok "prompt" | Open the TUI and submit an initial prompt. |
grok version or grok --version | Print the installed version. |
grok update | Install the latest available version. |
grok setup | Fetch and install configuration managed by your organization. |
grok completions <shell> | Generate completion scripts for a supported shell. |
grok login | Start browser-based sign-in again. |
grok login --device-auth | Use a code and verification URL for remote or headless machines. |
grok logout | Clear cached credentials. |
grok inspect | Show rules, Skills, Plugins, Hooks, MCP servers, and other configuration found for the current directory. |
grok inspect --json | Return the inspection report as JSON. |
grok models | List models available to the current account and configuration. |
grok sessions list | List recent sessions for the current directory. |
grok sessions search "text" | Search session titles and prompts. |
grok sessions delete <session-id> | Delete one saved session. |
grok export <session-id> [output] | Export a session transcript as Markdown. |
grok import [targets...] | Import supported sessions from Claude Code. |
grok memory clear | Clear memory for the current workspace. Memory is an experimental feature. |
grok mcp list | List configured MCP servers. |
grok mcp doctor [name] | Check MCP configuration and connectivity. |
grok plugin list | List installed Plugins. |
grok plugin details <name> | Show the components supplied by one Plugin. |
grok worktree list | List worktrees managed by Grok Build. |
grok worktree show <name> | Show details for one managed worktree. |
grok worktree rm <name> | Remove a managed worktree. |
grok worktree gc | Clean up stale worktree records. |
grok dashboard | Open the agent dashboard from the shell. |
grok agent stdio | Run Grok Build as an ACP agent over standard input and output. |
grok wrap <command...> | Run a command in a local PTY and forward OSC 52 clipboard writes. |
Common launch flags
| Flag | What it changes |
|---|---|
--cwd <PATH> | Use another working directory. |
-m, --model <MODEL> | Select a model for the session. |
--effort <LEVEL> | Set reasoning effort for a model that supports it. |
--rules "TEXT" | Add temporary rules to the session without editing AGENTS.md. |
--resume [ID] | Resume a saved session. Without an ID, it selects the latest session for the directory. |
-c, --continue | Continue the most recent session in the current directory. |
-s, --session-id <UUID> | Assign a specific UUID to a new session. |
--fork-session | Fork the selected session instead of continuing it in place. |
-w, --worktree[=NAME] | Start in a new git worktree. Use --worktree=name when an initial prompt follows. |
--ref <BRANCH> | Base a new worktree on a specific branch. |
--minimal | Use the experimental terminal-scrollback display. |
--fullscreen | Use the standard full-screen TUI. |
--sandbox <PROFILE> | Apply an OS-level filesystem and network profile. |
--always-approve or --yolo | Approve tool calls automatically. Deny rules and blocking Hooks still apply. |
--system-prompt-override "TEXT" | Replace the built-in system prompt for this run. |
--no-plan | Disable Plan Mode for the session. |
--no-subagents | Disable subagent delegation for the session. |
--no-memory | Disable Memory for the session. |
--disable-web-search | Disable the built-in web search tool. |
--experimental-memory | Enable experimental cross-session Memory features. |
--oauth | Use OAuth when the welcome screen starts authentication. |
Slash commands
Type / in the Grok Build prompt to open the command menu. The menu also lists installed user-invocable Skills. Built-in commands take priority when a Skill has the same name.
Sessions and context
| Command | What it does |
|---|---|
/new | Start a new session. Alias: /clear. |
/resume | Open the saved-session picker. |
/fork | Create a peer session from the current history, with an optional worktree. |
/rewind | Return to an earlier turn and restore its file snapshots. |
/compact [focus] | Compress older context and optionally state what the summary must preserve. |
/recap | Generate a quick summary of the current session. |
/context | Show context use, tool definitions, Skills, and MCP token estimates. |
/session-info | Show the current model, turn count, and session details. |
/rename <title> | Rename the current session. Alias: /title. |
/copy [N] | Copy the latest response, or the Nth-latest response. |
/export | Export the current conversation. |
/remember <note> | Save one direct Memory note. |
/memory | Browse and manage experimental cross-session Memory. |
/flush | Save the current session summary to experimental Memory. |
/dream | Consolidate experimental Memory records. |
/find <text> | Search the current transcript. |
/transcript | Open the full session transcript. |
/share | Create a shareable link for the current conversation. |
/home | Leave the session and return to the welcome screen. |
/quit | Exit Grok Build. Alias: /exit. |
Models, modes, and input
| Command | What it does |
|---|---|
/model <name> | Switch models. Alias: /m. |
/effort <level> | Change reasoning effort on the active model. |
/plan [description] | Enter Plan Mode and optionally send the planning request. |
/view-plan | Open the saved plan preview. |
/auto | Toggle automatic approval for actions classified as safe, when the feature is available. |
/always-approve | Toggle approval of all tool calls. |
/multiline | Make Enter insert a new line; use Shift+Enter or Alt+Enter to send. |
/history | Search prompts from the current session. |
/imagine <prompt> | Generate an image when the feature is available. |
/imagine-video <prompt> | Generate a video when the feature is available. |
/vim-mode | Toggle Vim-style scrollback navigation. |
/compact-mode | Reduce TUI padding for denser output. |
/timestamps | Show or hide message timestamps. |
/minimal | Switch to the terminal-scrollback display. |
/fullscreen | Return to the standard full-screen TUI. |
/settings | Open settings. Aliases include /config and /preferences. |
/theme | Choose a TUI theme. |
Extensions, agents, and scheduled work
| Command | What it opens or starts |
|---|---|
/mcps | MCP server status, tools, authentication, and enable controls. |
/plugins | Installed Plugins and their components. |
/marketplace | Configured Plugin marketplaces. |
/skills | Discovered Skills and their enabled state. |
/hooks | Lifecycle Hooks and trust controls. |
/config-agents | Agent definitions. Alias: /agents. |
/personas | Personas that can shape subagent behavior. |
/dashboard | Active sessions, forks, and agents. Alias: /sessions. |
/tasks | Open running and completed background tasks. |
/queue | Open prompts waiting behind the current turn. |
/loop [interval] <prompt> | A recurring prompt with a minimum interval of 60 seconds. |
/goal <objective> | A multi-turn autonomous goal, when the Goal feature is enabled. |
Account, diagnostics, and help
| Command | What it does |
|---|---|
/login | Start sign-in again without leaving the TUI. |
/logout | Sign out and return to the login screen. |
/usage | Show credit use and billing options. |
/privacy | Show or change privacy and data-retention status. |
/terminal-setup | Report color, clipboard, keyboard protocol, and terminal capabilities. |
/docs | Open in-TUI guides. Use /docs web for the online documentation. |
/help | Open help for commands, shortcuts, and core features. |
/release-notes | Show release notes for the installed version. |
/import-claude | Open the Claude Code settings import flow. |
/feedback [message] | Send product feedback. |
/btw <message> | Send an aside without interrupting the main task. |
Memory commands such as /memory, /flush, and /dream require experimental memory to be enabled. /remember is available without that flag and saves a direct note.
Keyboard shortcuts
Bindings can change with the focused pane and terminal. Open the live shortcut panel with Ctrl+.. Use Ctrl+X when your terminal cannot deliver that key combination.
| Shortcut | Action |
|---|---|
Enter | Send the current prompt. |
Tab | Move focus between the prompt and scrollback. |
Shift+Tab | Cycle Normal, Auto, Plan, and Always-approve modes. Available modes can depend on settings. |
Ctrl+P or ? | Open the command palette. |
Ctrl+. or Ctrl+X | Open keyboard shortcut help. |
F2 or Ctrl+, | Open settings. |
Ctrl+M | Toggle multiline input when the prompt has focus; otherwise open the model picker. |
Ctrl+R | Search prompt history. |
Ctrl+O | Toggle Always-approve mode. |
Ctrl+S | Open the session picker. |
Ctrl+L | Open extensions. In VS Code family terminals, this key interjects instead. |
Ctrl+G | Send the running task to the background. |
Ctrl+B | Toggle the tasks pane. |
Ctrl+; or Ctrl+' | Toggle the prompt queue. |
Ctrl+\ | Open the agent dashboard. |
Ctrl+T | Toggle the todo pane. |
Ctrl+N | Start a new session after confirmation. |
Esc | Dismiss an open panel or move back. It does not cancel a running turn. |
Ctrl+C | Cancel the running turn. If a draft is present, the first press clears it and the next press cancels. |
Esc Esc | While idle, press twice within 800 ms to clear a draft or open Rewind when the prompt is empty. |
Ctrl+Q or Ctrl+D | Quit after confirmation. VS Code family terminals use Ctrl+D. |
| Shortcut | Action |
|---|---|
Up / Down | Select the previous or next entry in Simple mode. |
Left / Right | Collapse or expand the selected entry. |
PageUp / PageDown | Scroll one page. These also work while the normal prompt has focus. |
Shift+Left / Shift+Right | Move to the previous or next turn. |
Shift+K / Shift+J | Move to the previous or next response. |
Ctrl+K / Ctrl+J | Scroll one line without changing the selected entry. |
Ctrl+U / Ctrl+D | Scroll half a page. In VS Code family terminals, use Shift+D for half-page down. |
Enter | Open the selected block in the full-screen viewer. |
e / Shift+E | Expand or collapse one entry, or all entries, in Vim mode. |
Ctrl+E | Toggle all thinking blocks. |
r | Toggle raw Markdown in Vim mode. |
y / Shift+Y | Copy content, a command, or a path in Vim mode. |
x | Kill the selected background task in Vim mode. |
Vim scrollback mode replaces the arrow-first navigation with j, k, h, l, g, and G. Enable it with /vim-mode or set vim_mode = true under [ui].
While a turn is running, plain Enter queues a follow-up. On most terminals, Ctrl+Enter or Ctrl+I interjects so Grok Build handles the new instruction immediately. VS Code, Cursor, Windsurf, and Zed use Ctrl+L for that action.
Prompt syntax and mid-turn control
Type @ in a prompt to search for a file or directory. Grok Build respects .gitignore in this picker and hides dotfiles by default.
@src/main.rs Explain this file.
@src/main.rs:10-50 Review these lines.
@src/ Find the authentication flow in this directory.
@!.github Explain the CI workflows.The ! after @ includes hidden files in the search. Attaching .env, private keys, or credential files can expose their contents to the active model. Inspect sensitive files yourself and pass only the lines the task requires.
Type ! on an empty prompt to enter shell mode. Use shell mode for a command you want to run yourself inside the TUI. When Grok Build runs a command as a tool, its permission and sandbox rules still apply.
Configuration and project rules
CLI flags win over environment variables, which win over ~/.grok/config.toml. The user config is the right place for defaults that should follow you across projects. Repository settings belong in .grok/ or AGENTS.md.
| Path | Purpose |
|---|---|
~/.grok/config.toml | User defaults, models, UI, tools, authentication, and extension settings. |
~/.grok/pager.toml | TUI appearance and rendering details. |
~/.grok/auth.json | Cached credentials. Grok Build manages this file. |
~/.grok/sessions/ | Saved sessions, tool history, plans, and rewind data. |
~/.grok/skills/ | Personal Skills available in every project. |
~/.grok/plugins/ | Personal Plugins. |
.grok/config.toml | Project MCP servers, Plugins, permission rules, and MCP output limits. |
.grok/skills/ | Skills shared with one project. |
.grok/hooks/ | Project lifecycle Hooks. |
.grok/agents/ | Project agent definitions. |
.grok/sandbox.toml | Custom sandbox profiles. |
AGENTS.md | Project instructions loaded into the session context. |
A practical user configuration
Start with a short config and add settings only after you know why you need them:
# ~/.grok/config.toml
[models]
default = "grok-build"
[ui]
vim_mode = false
show_thinking_blocks = true
remember_tool_approvals = true
[session]
auto_compact_threshold_percent = 85
[tools]
respect_gitignore = trueRun grok inspect after changing configuration. It shows the files and extension sources Grok Build discovered in the current directory, which is more reliable than guessing which layer won.
Project instructions with AGENTS.md
Put stable, actionable rules in AGENTS.md. Build commands, test commands, directory boundaries, and coding conventions belong there. General project history does not.
Grok Build reads instruction files from the repository root down to the current directory. Deeper files appear later in context and take precedence when rules conflict. It also reads recognized Claude instruction files for compatibility. Keep each file short because every loaded rule uses context.
# Project instructions
- Use TypeScript for new source files.
- Run `npm test` and `npm run lint` before finishing.
- Keep database queries in `src/repositories/`.
- Do not edit generated files under `dist/`.Custom models
Custom models use OpenAI-compatible or supported provider endpoints. Store the key in an environment variable:
[model.my-model]
model = "model-id"
base_url = "https://api.example.com/v1"
name = "My Model"
env_key = "MY_MODEL_API_KEY"
context_window = 128000
[models]
default = "my-model"Check the result with grok models, select it in the TUI with /model my-model, or use it for one run with grok -m my-model.
MCP, Skills, Plugins, and Hooks
| Extension | Use it for |
|---|---|
| MCP server | Connect Grok Build to an external service or local tool through the Model Context Protocol. |
| Skill | Save task instructions that Grok can select automatically or run as a slash command. |
| Plugin | Package Skills, commands, agents, Hooks, MCP servers, and LSP servers together. |
| Hook | Run a command or HTTP callback at a lifecycle event, such as before or after a tool call. |
Add and check MCP servers
# List servers
grok mcp list
# Add a local stdio server
grok mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/dir
# Add a project-scoped server
grok mcp add --scope project filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/dir
# Add a remote HTTP server
grok mcp add --transport http sentry https://mcp.sentry.dev/mcp
# Diagnose all servers or one server
grok mcp doctor
grok mcp doctor filesystem
# Remove a server
grok mcp remove filesystemUser-scoped MCP definitions go into ~/.grok/config.toml. The --scope project option writes to .grok/config.toml. Do not commit tokens in headers or environment maps. Reference a secret through ${VAR} instead.
Create a Skill
A Skill is a folder with a SKILL.md file. Put personal Skills under ~/.grok/skills/ and team Skills under .grok/skills/.
---
name: review-pr
description: Review a pull request for correctness and regressions. Use when asked to review a PR.
argument-hint: PR number or branch
user-invocable: true
---
# Review a pull request
1. Read the diff and surrounding code.
2. Check tests and error paths.
3. Report only actionable findings with file paths.Manage Plugins
| Command | Action |
|---|---|
grok plugin list | List installed Plugins. |
grok plugin install <source> --trust | Install a Plugin after accepting that its executable components may run. |
grok plugin details <name> | Show Skills, agents, Hooks, MCP servers, and other components. |
grok plugin enable <name> | Enable a Plugin. |
grok plugin disable <name> | Disable a Plugin without removing it. |
grok plugin update [name] | Update one Plugin or all installed Plugins. |
grok plugin uninstall <name> | Remove a Plugin. |
grok plugin marketplace list | List marketplace sources. |
grok plugin marketplace add <source> | Add a Git or local marketplace. |
Enabling a Plugin loads its instructions and agent definitions. Trust controls code execution: project Plugin Hooks, MCP servers, and LSP servers stay inactive until you trust that Plugin. Inspect the source before adding --trust.
Use Hooks carefully
Hooks can approve, reject, observe, or modify tool flows. A project Hook is code from the repository, not a harmless text preference. Review .grok/hooks/, Plugin Hooks, and compatible Claude or Cursor Hook files before trusting an unfamiliar project.
Plans, subagents, and background work
Plan Mode
Plan Mode is for changes where architecture or requirements remain unsettled. Enter it with /plan or cycle to Plan with Shift+Tab. Grok Build reads the project, writes a session plan.md, and presents the plan for approval before implementation.
Normal file-edit tools cannot change project files while Plan Mode is active. The plan file is the exception. Shell commands and write-capable subagents require separate care because the parent plan gate does not inspect shell redirection or impose itself on child sessions.
| Plan review key | Action |
|---|---|
a | Approve the plan and begin implementation. |
s | Send revision notes and keep planning. |
c | Comment on the selected plan line or range. |
q | Abandon the plan and leave Plan Mode. |
Subagents
| Built-in type | Best fit |
|---|---|
general-purpose | Implementation or another task that needs the full toolset. |
explore | Repository research without file edits. |
plan | A structured implementation plan without file edits. |
Subagents have separate context windows and report back to the parent. They can run in the shared workspace or in an isolated git worktree. Use worktree isolation for independent editing tasks that might otherwise touch the same files.
Press Ctrl+B to see subagents and background commands in the tasks pane. Open /dashboard for active parent sessions and forks.
Background commands and recurring checks
| Need | Use |
|---|---|
| Keep one long command running | Ask Grok to run it in the background, or press Ctrl+G after it starts. |
| Repeat a check on an interval | /loop 5m Check whether the test suite passes |
| Receive selected lines from a live stream | Ask Grok to use the monitor tool with a tightly filtered command. |
| See task status | Press Ctrl+B. |
A /loop fires immediately and then repeats. The minimum interval is 60 seconds, recurring jobs expire after seven days, and one session can keep up to 50 scheduled tasks. Use a background command for a dev server or one long test run. Use /loop for periodic checks. Use monitor only when each selected output line deserves a notification.
Headless mode and scripting
Headless mode sends one prompt, lets the agent use its available tools, prints the result, and exits. A new session is created by default.
grok -p "Explain this codebase"| Flag | Headless behavior |
|---|---|
-p, --single "PROMPT" | Send one prompt. |
--prompt-file <PATH> | Read the prompt from a file. Piped stdin is not read as the prompt. |
--output-format plain | Print human-readable text. |
--output-format json | Print one JSON object after completion. |
--output-format streaming-json | Print newline-delimited events as work proceeds. |
--tools "read_file,grep,list_dir" | Keep only selected built-in tools. |
--disallowed-tools "run_terminal_cmd" | Remove specific tools from the run. |
--max-turns <N> | Stop after a maximum number of agent turns. |
-r, --resume <ID> | Continue an existing headless session. |
-c, --continue | Continue the latest session for the working directory. |
--allow "RULE" | Approve matching operations without removing other tools. |
--deny "RULE" | Block matching operations. Deny wins over allow. |
--permission-mode <MODE> | Use default for normal prompting or bypassPermissions for automatic approval. |
--yolo | Approve tool calls automatically. Reserve it for controlled environments. |
Structured output and session continuation
The final JSON object can include response text, stop reason, session ID, token use, model use, and cost fields when the server supplies complete data. Do not treat a missing cost field as zero cost.
# Capture the session ID
grok -p "Review the current diff" --output-format json
# Continue that exact session
grok -p "Now check the error paths" --resume <session-id>
# Continue the newest session in this directory
grok -p "Continue the task" -c
# Stream events for a bot or integration
grok -p "Run the tests and summarize failures" --output-format streaming-jsonLimit a review to read-only tools
On PowerShell, put the command on one line or replace Bash line continuations with PowerShell backticks.
grok -p "Review this repository for correctness issues" \
--tools "read_file,grep,list_dir" \
--sandbox read-only \
--output-format jsonPermissions and sandboxing
Permissions decide whether a requested action is approved, denied, or shown for confirmation. The sandbox limits what the process can access after an action is approved. Use both layers for unfamiliar code.
For a predictable daily default, keep approval prompts enabled in ~/.grok/config.toml. Change the value to "always-approve" only in an environment where automatic tool approval is acceptable.
[ui]
permission_mode = "ask"Compatibility permission modes
Grok Build also reads permissions.defaultMode from compatible .claude/settings.json files. That setting accepts the following modes:
| Permission mode | Behavior |
|---|---|
default | Prompt for actions that do not have an allow rule or built-in approval. |
dontAsk | Deny anything without an explicit allow rule or built-in approval. Configure it through compatible settings for CI or restricted work. |
acceptEdits | Approve file edits while other actions follow normal rules. |
bypassPermissions | Approve tool calls automatically. Explicit deny rules, ask rules, and blocking Hooks can still stop an action. |
plan | Keep standard prompting. Plan sessions are controlled separately through Plan Mode. |
For daily interactive work, keep the default prompt behavior and add narrow rules for commands you run often. Avoid a broad Bash allow rule.
# .grok/config.toml
[permission]
allow = [
"Bash(git *)",
"Bash(npm test*)",
"Read(src/**)",
"Grep",
]
deny = [
"Bash(rm -rf *)",
"Read(**/.env)",
"Edit(**/.env)",
]Deny rules take precedence over ask and allow rules, regardless of which config file contains them. Shell rules can be subtle around chained commands, wrappers, and wildcards. Pair narrow allows with explicit denials for destructive commands, then test representative cases before using the policy in automation.
Sandbox profiles
Sandboxing is off by default. Linux uses Landlock and related kernel controls; macOS uses Seatbelt. Network restrictions apply to child processes on Linux, but not to built-in web tools or the model connection. macOS sandbox profiles do not block child-process network access.
| Profile | Access |
|---|---|
off | No sandbox. Filesystem and child-process network access are unrestricted. |
workspace | Read anywhere; write to the working directory, ~/.grok/, and temp directories. Child network is allowed. |
read-only | Read anywhere; write only to ~/.grok/ and temp directories. Linux blocks child-process network access. |
strict | Read the working directory and system paths; write to the working directory, ~/.grok/, and temp directories. Linux blocks child-process network access. |
devbox | Broad write access for a disposable development VM, except protected top-level paths. |
Block secrets with a custom profile
# .grok/sandbox.toml
[profiles.project]
extends = "workspace"
restrict_network = true
deny = ["**/.env", "**/*.pem", "**/*.key"]grok --sandbox projectA non-empty deny list blocks reads and writes at the OS level. Linux expands deny globs against files that exist at launch. Use exact paths for secrets that must remain blocked even if files appear later. Grok Build refuses to start when an explicitly requested custom profile cannot be applied.
A session keeps the sandbox profile it started with. Resume will reject a different profile. Start a new session if you need a different access boundary.
Sessions, Rewind, and Memory
Grok Build saves each conversation automatically under ~/.grok/sessions/. A session includes messages, tool results, task state, token counters, file snapshots for Rewind, and child-session records.
| Action | Command |
|---|---|
| Browse saved sessions in the TUI | /resume |
| Resume the newest session for this directory | grok --resume |
| Resume a known session | grok --resume <session-id> |
| Search saved prompts and titles | grok sessions search "keyword" |
| Fork the current conversation | /fork |
| Restore an earlier turn and its files | /rewind |
| Reduce context use | /compact keep the decisions about authentication |
| Save one direct memory note | /remember the staging region is eu-west-1 |
Rewind restores file snapshots and truncates later conversation history. Git remains the safer long-term recovery mechanism because a Rewind discards the later state. Commit or stash work you may need again.
Cross-session Memory is experimental. Enable it with --experimental-memory, GROK_MEMORY=1, or the documented config setting before using /memory, /flush, and /dream. Review saved memories instead of assuming every old detail still applies.
Grok Build workflow examples
Understand an unfamiliar repository
grok --sandbox read-only "Map this repository. Explain the entry points, main modules, test setup, and the path a request follows through the application. Cite file paths."The read-only sandbox protects project files while Grok Build explores. Follow with a narrower prompt about the module you plan to change.
Plan a feature before editing
/plan Add passwordless email login. Reuse the current session middleware and identify the database, route, UI, and test changes.Read the proposed file paths and verification steps before pressing a. Press s and send corrections when the plan ignores an existing utility or chooses the wrong boundary.
Fix a failing test
Run the failing auth tests. Find the first real failure, explain the cause, make the smallest justified fix, then rerun the focused tests and the related suite.Ask for the cause before authorizing a change, then require both the focused test and the full suite. A single passing test is not enough to verify the fix.
Review the current diff without changing files
grok -p "Review the current git diff for correctness, regressions, missing tests, and unsafe error handling. Report only actionable findings with file paths and line numbers." --tools "read_file,grep,list_dir,run_terminal_cmd" --deny "Bash(git push*)" --sandbox read-onlyThe read-only sandbox blocks project edits. The explicit push denial adds another boundary around the shell tool.
Refactor in an isolated worktree
grok --worktree=auth-cleanup --ref main "Refactor the authentication middleware to remove duplication. Preserve behavior, add focused tests, and show the final diff."The named worktree keeps the refactor separate from your main checkout. Review and merge its changes only after the tests and diff look right.
Keep a long session focused
/context
/compact preserve the accepted API contract, changed file list, open test failure, and remaining tasksCheck context before compacting. A specific compact instruction protects decisions that a generic summary might omit.
Add a project MCP server
grok mcp add --scope project --transport http sentry https://mcp.sentry.dev/mcp
grok mcp doctor sentry
grok inspectThe project scope makes the server discoverable from the repository config. Review the file before committing it, especially headers and environment values.
Delegate repository research
Use an explore subagent to trace every caller of the payment retry function. Return the call paths, tests that cover them, and any inconsistent retry limits. Do not edit files.An explore subagent can search and run inspection commands without editing. The parent keeps its context for the main task and receives a summary when research finishes.
Run a dev server in the background
Start `npm run dev` in the background. Wait for the ready message, then implement the login form and verify it against the running app.Press Ctrl+B to inspect the server task. Ask Grok Build to stop it when verification ends so the process does not keep the port open.
Watch a CI run
/loop 2m Check the GitHub Actions run for this branch. Report only when its status changes or when it finishes.The instruction limits repeated noise. Delete the scheduled task after the run completes if Grok Build does not remove it as part of the task.
Run an unattended formatting task
grok -p "Format the changed source files, run the formatter check, and report the files changed." --yolo --sandbox workspace --deny "Bash(git push*)" --deny "Bash(rm -rf *)"Always-approve removes interactive prompts. Run unattended edits only in a clean checkout where you can inspect or discard the diff.
Move from Claude Code without copying assumptions
/import-claude
# Then check what Grok Build loaded
grok inspectThe import can bring over supported permissions, environment variables, MCP servers, Hooks, and paths. Inspect the result because compatibility does not mean every Claude Code command or behavior has a Grok Build equivalent.
Troubleshooting
| Problem | What to check |
|---|---|
grok is not found after installation | Open a new terminal and confirm that ~/.grok/bin or %USERPROFILE%\.grok\bin is on PATH. |
| Browser sign-in fails | Run grok logout, then grok login. On remote machines, use grok login --device-auth. |
| Grok ignores AGENTS.md | Run grok inspect. Check the filename, current directory, git root, and .gitignore. |
| A config change has no effect | Confirm the file and scope with grok inspect. Start a new session for settings that load only at session creation. |
| An MCP server will not start | Run grok mcp doctor <name>, test the server command directly, and inspect ~/.grok/logs/mcp/<server>.stderr.log. |
An npx MCP server times out | Its first launch may download packages. Increase startup_timeout_sec for that server. |
| Colors or clipboard behavior is wrong | Run /terminal-setup. It reports truecolor, clipboard routes, keyboard protocol, and tmux fixes. |
Ctrl+. does nothing | Use Ctrl+X. Some terminals cannot send the modified punctuation key. |
Ctrl+Enter does not interrupt | Use Ctrl+I on many terminals or Ctrl+L in VS Code, Cursor, Windsurf, and Zed. |
| Grok cannot install dependencies in a sandbox | Linux network restrictions may block child commands. Start a new session with a profile that permits the required access. |
| Resume rejects a new sandbox profile | The sandbox is fixed for the session. Start a new session under the new profile. |
| A documented command is missing | Run grok update, then check /release-notes and grok --help. |
FAQs
What is Grok Build?
Grok Build is SpaceXAI’s terminal-based AI coding agent. It has an interactive TUI, a headless mode for scripts and CI, and an ACP mode for compatible editors and clients. It can inspect code, edit files, execute commands, search the web, and coordinate longer tasks.
Is Grok Build the same as Grok on the web?
No. Grok Build is the coding agent and CLI that runs from a terminal or integration client. Grok on the web is the general chat product. Their accounts and models are related, but their commands and interfaces are different.
Does Grok Build work on Windows?
Yes. The official PowerShell installer provides a native Windows binary. Git Bash and WSL are also supported installation paths. Some keyboard combinations differ in Windows Terminal and editor-integrated terminals. Use /terminal-setup when a shortcut does not work.
Do I need an xAI API key?
Not for the normal browser sign-in flow. An API key is the practical choice for CI, containers, and other environments where interactive account login is unavailable. Device authentication is another option for a remote machine.
Where does Grok Build store its configuration?
User configuration lives under ~/.grok/, or %USERPROFILE%\.grok\ on Windows. The main files are config.toml and pager.toml. Project extensions and rules can live under .grok/ in the repository.
Does Grok Build support AGENTS.md?
Yes. Grok Build loads project instruction files from the repository root to the current directory. Deeper instructions take precedence when files conflict. It also supports several Claude instruction filenames for compatibility.
How do I run Grok Build without the TUI?
Use grok -p "Your prompt". Add --output-format json for one machine-readable result or --output-format streaming-json for a live event stream. Headless runs create fresh sessions unless you resume or continue one.
What is the difference between Plan Mode and an explore subagent?
Plan Mode prepares an implementation plan for the current session and waits for approval before normal edit tools can change project files. An explore subagent investigates a bounded question in a separate context and returns a summary. Use Plan Mode for a change that needs your approval. Use an explore subagent for parallel research.
Does Always-approve disable every safety control?
No. Always-approve removes normal confirmation prompts, but explicit deny rules, ask rules, restrictive Hooks, and the OS sandbox can still block actions. It still deserves care because any action without one of those restrictions can proceed automatically.
Can Grok Build use Claude Code Skills and settings?
Grok Build includes compatibility for several Claude Code rule, Skill, command, MCP, Hook, and session locations. It also provides /import-claude. You can use grok inspect to confirm what loaded and do not assume a Claude slash command exists in Grok Build.
How is Grok Build different from Codex CLI and Claude Code?
All three are coding agents that can inspect repositories, edit files, and run commands. Grok Build has its own TUI, models, permission system, sandbox profiles, slash commands, extension discovery, session storage, subagents, and ACP interface. Use the cheatsheet for the tool you are running instead of carrying commands across products.
Related resources
- Grok Build documentation: Official setup, modes, features, settings, and CLI pages.
- Grok Build on GitHub: Source code, installation commands, repository notes, and license.
- Grok Build user guide: Detailed reference for configuration, extensions, sessions, sandboxing, and advanced use.
- Grok Build changelog: Current releases, command changes, fixes, and TUI updates.
- Claude Code Commands Cheat Sheet: Claude Code slash commands, CLI options, permissions, Skills, Plugins, agents, and workflows.
- OpenAI Codex Commands Cheat Sheet: Codex CLI commands, flags, configuration, MCP, sandbox settings, and practical workflows.








