Grok Build CLI Cheatsheet: Commands, Shortcuts, Config, and Workflows

Use Grok Build with fewer detours. This cheatsheet puts the commands behind everyday repository work in one place, from the first prompt and plan review to worktrees, MCP servers, safe permissions, and headless jobs.

Grok Build CLI 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: September 10, 2026

This reference was checked against Grok Build v1.0.25. Run grok --help, grok <command> --help, or /release-notes after an update because commands can change between versions.

Grok Build essentials

TaskCommand or shortcut
Start in the current projectgrok
Start with a taskgrok "Explain this repository"
Attach a file to a prompt@src/main.rs Explain this file
Run a shell command inside the TUIType ! on an empty prompt.
Plan before changing files/plan or Shift+Tab
Cancel a running turnCtrl+C
Send a correction immediatelyCtrl+Enter or Ctrl+I
Check context usage/context
Compact a long conversation/compact
Resume the latest project sessiongrok --continue
Restore an earlier turn/rewind
Manage agent-launched background work/workflow
Inspect loaded rules and extensionsgrok inspect
Run one headless taskgrok -p "Your task"
Start in an isolated worktreegrok --worktree=task-name "Your task"
Remove the current session’s history/delete

Install and start Grok Build

SystemInstall command
macOS, Linux, WSL, or Git Bashcurl -fsSL https://x.ai/cli/install.sh | bash
Windows PowerShellirm https://x.ai/cli/install.ps1 | iex

On Windows, the installer places the binary in %USERPROFILE%\.grok\bin. Open a new PowerShell tab after installation, then confirm that the shell can find Grok Build:

grok --version
grok update

Open a terminal in your project directory and start the interactive interface:

cd your-project
grok

The 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-auth

CI 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.

CommandWhat it does
grok or grok "prompt"Open the interactive TUI, optionally with an initial task.
grok agentRun without the interactive UI. Subcommands: headless, leader, serve, and stdio.
grok completions <shell>Generate shell completion scripts.
grok dashboard, doctor, or doctor fixOpen the dashboard or check terminal, clipboard, color, and input support.
grok export <session-id> [output]Export a session transcript as Markdown. Add --clipboard to copy it.
grok inspect [--json]Show rules, Skills, Plugins, Hooks, MCP servers, and other configuration found for the current directory.
grok leader list|info|killManage running leader processes.
grok login [--device-auth] or grok logoutSign in, use device authentication on a remote machine, or clear cached credentials.
grok mcp add|list|doctor|removeManage MCP server configurations.
grok memory clearClear workspace, global, or all cross-session memory files.
grok modelsList available models and exit.
grok pluginManage plugins and marketplaces: install, list, enable, disable, update, uninstall, validate, and marketplace commands.
grok sessions list|search|deleteList, search, or remove saved sessions.
grok setup or grok updateInstall managed configuration, check for updates, or install a specified version.
grok traceExport or upload session trace data.
grok worktreeManage worktrees with list, show, rm, gc, and worktree database commands.
grok wrap <command...>Run a command with local clipboard support.
grok version or grok --versionPrint the installed version.

Common launch flags

FlagWhat it changes
--cwd <PATH>Use another working directory.
-m, --model <MODEL>Select a model for the session.
--reasoning-effort <LEVEL> or --effortSet reasoning effort for a supported model.
--rules "TEXT"Add temporary rules without editing project instructions.
--resume [ID] or -c, --continueResume a saved session or continue the latest one in the current directory.
--fork-sessionCreate a new session ID when resuming.
-s, --session-id <UUID>Set the ID for a new session or a fork.
-w, --worktree[=NAME]Start in a new git worktree.
--worktree-ref <REF> or --refChoose the branch, tag, or commit used as the worktree base.
--minimal or --fullscreenChoose the scrollback-native or standard full-screen TUI for this session.
--sandbox <PROFILE>Apply a filesystem and network sandbox profile.
--allow <RULE> or --deny <RULE>Add permission rules for this session.
--always-approveApprove tool executions automatically.
--permission-mode <MODE>Choose default, acceptEdits, auto, dontAsk, bypassPermissions, or plan.
-p, --single <PROMPT>Run one headless prompt, print the response, and exit.
--output-format plain|json|streaming-jsonSet output format for headless mode.
--no-plan, --no-subagents, or --no-memoryDisable the named feature for one session.
--experimental-memoryEnable cross-session memory.
--disable-web-searchDisable built-in web search and fetch tools.

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

CommandWhat it does
/newStart a fresh session. Alias: /clear.
/resumeOpen the saved-session picker.
/forkBranch the current session into a new agent while retaining its history.
/rewindRoll the conversation back to an earlier turn.
/compact [context]Compress conversation history; add a note about what to preserve.
/contextShow context use and estimated token cost for tools, Skills, and MCP servers.
/session-infoShow authentication method, model, turn count, and context use. Aliases: /status and /info.
/rename <title>Rename the current session. Alias: /title.
/edit-promptOpen an external editor for an empty prompt in minimal mode.
/copy [N|path]Copy a recent response or write it to a file.
/exportExport the current conversation to a file or the clipboard.
/homeLeave the session and return to the welcome screen. Alias: /welcome.
/quitExit Grok Build. Alias: /exit.
/remember <note>Save a direct memory note.
/memoryBrowse or enable cross-session memory. Alias: /mem.
/flush or /dreamSave the current session to memory or consolidate memory records. Both require memory to be enabled.
/deleteRemove the current session’s history after confirmation.
/undoRestore files and chat to an earlier turn, same as /rewind.

Models, modes, and input

CommandWhat 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-planOpen the saved plan preview.
/autoToggle automatic approval for actions classified as safe, when the feature is available.
/always-approveToggle approval of all tool calls.
/multilineMake Enter insert a new line; use Shift+Enter or Alt+Enter to send.
/historySearch 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.
/voiceStart voice dictation. Dictated text is inserted at the cursor.
/vim-modeToggle Vim-style scrollback navigation.
/compact-modeReduce TUI padding for denser output.
/timestampsShow or hide message timestamps.
/minimalSwitch to the terminal-scrollback display.
/fullscreenReturn to the standard full-screen TUI.
/settingsOpen settings. Aliases include /config and /preferences.
/themeChoose a TUI theme. The picker accepts aliases such as transparent, dark, and system.

Extensions, agents, and scheduled work

CommandWhat it opens or starts
/mcpsOpen the MCP server management modal.
/pluginsOpen the extensions modal on the Plugins tab. The shell also supports /plugins list|install|uninstall|update|reload.
/marketplaceOpen the Marketplace tab in the extensions modal.
/skillsOpen the Skills tab in the extensions modal.
/hooksOpen the Hooks tab in the extensions modal.
/config-agentsOpen agent definitions and choose the active agent. Alias: /agents.
/personasCreate, edit, and delete subagent personas.
/loop [interval] <prompt>Run a recurring prompt. The minimum interval is 60 seconds and jobs expire after seven days.
/goalSet, check, pause, resume, or clear an autonomous goal when goal mode is available.
/deep-research <query>Start a background research workflow.
/workflow or /workflowsLaunch or manage saved workflows, view active and retained runs, and pause or stop agent-launched background runs.

Account, diagnostics, and help

CommandWhat it does
/login or /logoutSign in again without leaving the TUI, or sign out and return to the login screen.
/usageView credit usage or manage billing. Alias: /cost.
/privacyShow or change privacy and data-retention status.
/doctorCheck terminal, clipboard, color, input, notification, and sandbox issues. Aliases: /terminal-setup, /terminal-check, and /terminal-info.
/docsOpen in-TUI guides, the online documentation, or a specific guide. Aliases: /howto and /guides.
/release-notesView release notes for the installed version. Alias: /changelog.
/tutorialOpen the onboarding tutorial. Aliases: /tour and /onboarding.
/import-claudeOpen the Claude Code settings import flow.
/feedback [message]Send product feedback immediately. Failed submissions are saved to Drafts.
/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.

ShortcutAction
EnterSend the current prompt.
TabMove focus between the prompt and scrollback.
Shift+TabCycle Normal, Auto, Plan, and Always-approve modes. Available modes can depend on settings.
Ctrl+P or ?Open the command palette.
Ctrl+. or Ctrl+XOpen keyboard shortcut help.
F2 or Ctrl+,Open settings.
Ctrl+MToggle multiline input when the prompt has focus; otherwise open the model picker.
Ctrl+RSearch prompt history.
Ctrl+OToggle Always-approve mode.
Ctrl+SOpen the session picker.
Ctrl+LOpen extensions. In VS Code family terminals, this key interjects instead.
Ctrl+GSend the running task to the background.
Ctrl+BToggle the tasks pane.
Ctrl+; or Ctrl+'Toggle the prompt queue.
Ctrl+\Open the agent dashboard. Use arrow keys to select dashboard actions and Enter to run one.
Ctrl+TToggle the todo pane.
Ctrl+NStart a new session after confirmation.
EscDismiss an open panel or move back. It does not cancel a running turn.
Ctrl+CCancel the running turn. If a draft is present, the first press clears it and the next press cancels.
Esc EscWhile idle, press twice within 800 ms to clear a draft or open Rewind when the prompt is empty.
Ctrl+Q or Ctrl+DQuit after confirmation. VS Code family terminals use Ctrl+D.

Scrollback navigation

ShortcutAction
Up / DownSelect the previous or next entry in Simple mode.
Left / RightCollapse or expand the selected entry.
PageUp / PageDownScroll one page. These also work while the normal prompt has focus.
Shift+Left / Shift+RightMove to the previous or next turn.
Shift+J / Shift+KJump to the next or previous turn and place it at the top of the viewport in Vim mode.
Ctrl+K / Ctrl+JScroll one line without changing the selected entry.
Ctrl+U / Ctrl+DScroll half a page. In VS Code family terminals, use Shift+D for half-page down.
EnterOpen the selected block in the full-screen viewer.
e / Shift+EExpand or collapse one entry, or all entries, in Vim mode.
Ctrl+EToggle all thinking blocks.
rToggle raw Markdown in Vim mode.
y / Shift+YCopy content, a command, or a path in Vim mode.
xKill 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.

PathPurpose
~/.grok/config.tomlUser defaults, models, UI, tools, authentication, and extension settings.
~/.grok/pager.tomlTUI appearance and rendering details.
~/.grok/auth.jsonCached 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.tomlProject 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.tomlCustom sandbox profiles.
AGENTS.mdProject 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 = true

Run 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

ExtensionUse it for
MCP serverConnect Grok Build to an external service or local tool through the Model Context Protocol.
SkillSave task instructions that Grok can select automatically or run as a slash command.
PluginPackage Skills, commands, agents, Hooks, MCP servers, and LSP servers together.
HookRun 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 filesystem

User-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

CommandAction
grok plugin listList installed Plugins.
grok plugin install <source> --trustInstall 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 listList 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. Successful Hook runs stay silent; Grok Build shows status only when a Hook blocks or fails.

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 keyAction
aApprove the plan and begin implementation.
sSend revision notes and keep planning.
cComment on the selected plan line or range.
qAbandon the plan and leave Plan Mode.

Subagents

Built-in typeBest fit
general-purposeImplementation or another task that needs the full toolset.
exploreRepository research without file edits.
planA 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. Use /workflows to inspect active workflow runs, or /workflow to pause or stop a background run the agent launched.

Background commands and recurring checks

NeedUse
Keep one long command runningAsk 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 streamAsk Grok to use the monitor tool with a tightly filtered command.
See task statusPress 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. Scheduled tasks remind the agent to check results and finish, remove, or update the schedule. 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"
FlagHeadless behavior
-p, --single "PROMPT"Send one prompt.
--prompt-file <PATH>Read the prompt from a file.
--prompt-json <JSON>Send structured prompt content blocks.
--output-format plain|json|streaming-jsonChoose human-readable, final JSON, or streaming JSON output.
--json-schema <SCHEMA>Constrain output to a JSON Schema and imply JSON output.
--tools "tool1,tool2" or --disallowed-tools "tool1"Keep only selected built-in tools or remove named ones.
--max-turns <N>Stop after a maximum number of agent turns.
-r, --resume <ID> or -c, --continueContinue an existing session or the latest one for the working directory.
--allow "RULE" or --deny "RULE"Add permission rules. Deny rules take priority.
--permission-mode <MODE>Choose a supported permission mode such as default, auto, or bypassPermissions.
--always-approveApprove tool executions automatically. Use it only in a controlled environment.

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-json

Limit 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 json

Permissions 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 modeBehavior
defaultPrompt for actions that do not have an allow rule or built-in approval.
dontAskDeny anything without an explicit allow rule or built-in approval. Configure it through compatible settings for CI or restricted work.
acceptEditsApprove file edits while other actions follow normal rules.
bypassPermissionsApprove tool calls automatically. Explicit deny rules, ask rules, and blocking Hooks can still stop an action.
planKeep 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.

ProfileAccess
offNo sandbox. Filesystem and child-process network access are unrestricted.
workspaceRead anywhere; write to the working directory, ~/.grok/, and temp directories. Child network is allowed.
read-onlyRead anywhere; write only to ~/.grok/ and temp directories. Linux blocks child-process network access.
strictRead the working directory and system paths; write to the working directory, ~/.grok/, and temp directories. Linux blocks child-process network access.
devboxBroad 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 project

A 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.

ActionCommand
Browse saved sessions in the TUI/resume
Resume the newest session for this directorygrok --resume
Resume a known sessiongrok --resume <session-id>
Search saved prompts and titlesgrok 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-only

The 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 tasks

Check 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 inspect

The 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." --always-approve --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 inspect

The 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

ProblemWhat to check
grok is not found after installationOpen a new terminal and confirm that ~/.grok/bin or %USERPROFILE%\.grok\bin is on PATH.
Browser sign-in failsRun grok logout, then grok login. On remote machines, use grok login --device-auth.
Grok ignores AGENTS.mdRun grok inspect. Check the filename, current directory, git root, and .gitignore.
A config change has no effectConfirm the file and scope with grok inspect. Start a new session for settings that load only at session creation.
An MCP server will not startRun grok mcp doctor <name>, test the server command directly, and inspect ~/.grok/logs/mcp/<server>.stderr.log.
An npx MCP server times outIts first launch may download packages. Increase startup_timeout_sec for that server.
Colors or clipboard behavior is wrongRun /terminal-setup. It reports truecolor, clipboard routes, keyboard protocol, and tmux fixes.
Ctrl+. does nothingUse Ctrl+X. Some terminals cannot send the modified punctuation key.
Ctrl+Enter does not interruptUse Ctrl+I on many terminals or Ctrl+L in VS Code, Cursor, Windsurf, and Zed.
Grok cannot install dependencies in a sandboxLinux network restrictions may block child commands. Start a new session with a profile that permits the required access.
Resume rejects a new sandbox profileThe sandbox is fixed for the session. Start a new session under the new profile.
A documented command is missingRun 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest & top AI tools sent directly to your email.

Subscribe now to explore the latest & top AI tools and resources, all in one convenient newsletter. No spam, we promise!