Grok Build: SpaceXAI’s Open-source Terminal AI Coding Agent

Install Grok Build and explore its terminal UI, sessions, Plan mode, worktrees, extensions, automation commands, and security controls.

Grok Build CLI is a terminal-based AI coding agent and the command-line companion to the Grok Build desktop app (formerly Cursor). Launch it inside your project directory and describe what you want to build or fix. The agent examines your codebase, edits files, and runs commands and tests to check the changes.

Grok Build 2.0 brings Cursor’s updated coding-agent runtime to the original Grok terminal interface. Subagents can now exchange messages and findings as they work on different parts of the same task. Premium, Super, and Ultra subscribers can also choose models such as Claude and Gemini instead of Grok.

Saved sessions and memory carry project context from one coding session to the next. With 2.0, you can also steer an agent from another device or send a task to the cloud so work continues after you close the terminal. Explore the guide below to install Grok Build CLI and put these features to work in your own projects.

Key Features

  • Full-screen terminal workspace: The TUI combines the conversation, tool activity, diffs, tasks, subagents, session controls, model selection, and extension management in one terminal application.
  • Repository-aware editing: Grok Build reads directory structures, searches symbols and text, opens files, applies multi-file changes, runs commands, and inspects Git state from the current working directory.
  • Plan mode: Review an implementation plan before approving edits to your project. During plan approval or preview, press y to copy the complete plan as Markdown.
  • Parallel subagents: Agents handle different parts of a task simultaneously and exchange findings or requests directly in Grok Build 2.0.
  • Git worktree sessions: Give each worktree session its own Git working directory and branch so parallel agents can edit files without overwriting one another’s changes.
  • Agent Dashboard: A live overview groups sessions by status, summarizes the previous turn, surfaces questions and approval requests, accepts replies, and dispatches new work to regular directories or worktrees.
  • Persistent sessions and memory: Resume, fork, search, or export previous sessions and carry useful project knowledge into new conversations.
  • Background task management: Development servers, test suites, builds, subagents, monitors, background /loop tasks, and queued messages continue while the main conversation stays active. The CLI can recover from repetitive model-output loops by default.
  • Headless automation: Run agent prompts from scripts, bots, and CI jobs. Choose plain text or structured JSON output, resume sessions, limit turns, define tool permissions, and constrain responses with a JSON schema.
  • ACP integration: grok agent stdio exposes the runtime as an Agent Client Protocol server over JSON-RPC.
  • Project instruction discovery: Repository conventions, architecture notes, build commands, and package-specific rules load from AGENTS.md, CLAUDE.md, and repository rules.
  • Extensible agent system: Skills, plugins, custom agents, hooks, LSP servers, and MCP integrations add reusable workflows and external tools.
  • CLI migration: Import Claude Code settings, resume Claude Code or Codex sessions, and switch from the legacy Cursor CLI without rebuilding your setup.
  • Model selection: Switch models during a session. Choose Grok or Composer on Free and paid plans, or select third-party models such as Claude and Gemini on Premium, Super, and Ultra.
  • JavaScript workflows: Run repeatable multi-agent tasks, such as reviewing every component affected by an API migration.
  • Remote control: Steer a running local session from Grok Build for iOS or another computer.
  • Cloud agents: Transfer a coding task to the cloud so it can continue after you close the terminal.
  • Permission and sandbox controls: Tool policies govern requested actions, while sandbox profiles restrict filesystem and process capabilities at the operating-system level.

Pricing and Free Access

Grok Build is part of The X Subscription. Free includes limited use of Grok and Composer. Plus costs $8 per month and establishes the base weekly usage allowance. Premium ($30/month) includes four times the Plus allowance, Super ($100/month) includes 15 times, and Ultra ($200/month) includes 50 times. Paid plans share that weekly allowance across Grok and Grok Build for first-party models.

On Plus, first-party models run at medium effort with Fast disabled. Premium, Super, and Ultra add Auto, cloud agents, and third-party model selection. Claude, Gemini, and other third-party model requests consume prepaid credit at the model provider’s API price. Existing subscribers on legacy Cursor or Grok Build plans retain their original pricing and allowances until they switch or cancel.

How to Install Grok Build

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

NPM Distribution

The CLI is also distributed through npm:

npm install -g @xai-official/grok

Check the installed version:

grok --version

Launch Grok from your project folder to sign in. You can also start authentication manually:

grok login

Remote terminals can use device authentication:

grok login --device-auth

Upgrade to Grok Build 2.0

If you already use Grok Build 1.x, launch the CLI once, sign in, and run the updater:

grok update
grok --version

A version beginning with 2. identifies the new runtime. If a package-manager installation remains on 1.x after updating, uninstall the old package using the command for your installation method:

  • Homebrew: brew uninstall --cask grok-build
  • npm: npm uninstall -g @xai-official/grok
  • WinGet: winget uninstall --id xAI.GrokBuild -e

Reinstall the CLI using the installer for your operating system above, open a new terminal, launch Grok, and run grok update again. If the version still begins with 1., the rollout has not reached your account yet. Run the same update command when the rollout reaches you. For organization-managed installations, the administrator controls the upgrade.

Sign in again on your first 2.0 launch. Your existing ~/.grok/config.toml, MCP servers, skills, hooks, AGENTS.md files, and previous sessions carry over.

If you previously selected the legacy build, remove build = "legacy" under [cli] in ~/.grok/config.toml before updating. To return to 1.x, add or update the following settings in that file:

[cli]
channel = "stable"
build = "legacy"

Keep channel = "alpha" if you previously used the alpha release. Edit the existing [cli] section rather than creating a duplicate. Apply the change and identify the installed version:

grok update
grok --version

If the version still begins with 2., rerun the installer from the installation section above, restore your alpha channel setting if you used it, and run grok update again. Your settings, saved conversations, and sign-in records remain on disk. In 1.x, /resume opens a 2.0 session as a copy. The 1.x runtime lacks remote control, cloud send, and JavaScript workflows.

Users of the old Cursor CLI can switch to the new terminal runtime with:

cursor-agent update --channel grok

To return to the old Cursor CLI, run cursor-agent update --channel cursor, followed by agent --version. A version line beginning with grok identifies the new runtime; otherwise you are running the legacy Cursor CLI. Existing scripts that invoke agent continue to work. Starting December 7, 2026, tag @Build in place of @Cursor in GitHub, Slack, Linear, and Jira.

Your First Grok Build Workflow

Open the repository:

cd path/to/project
grok

Type /tutorial to open Grok Build’s optional nine-topic onboarding tour.

Begin with a bounded inspection task:

Map the repository architecture.
Identify:
- application entry points
- major packages
- build and test commands
- external services
- generated code
- areas with missing tests
Do not edit files.

Review the response, then open Plan mode for a real change:

/plan Add rate limiting to the public API.
Inspect the current request path, choose the correct integration point, identify configuration changes, and list the required tests.

Revise the plan until its file scope and acceptance criteria are clear.

Approve implementation, then request verification:

Run the tests for the changed code and run the project’s linter. Review the final diff for unrelated changes, missing error handling, and incomplete test coverage.

Check Git state before ending the session:

Show the changed files, summarize each change, and list any unresolved risks.

Reopen the session with grok -c after leaving the TUI.

How Grok Build Handles a Coding Task

1. It loads the working context

The current directory determines the repository, project rules, local configuration, skills, plugins, hooks, MCP servers, and saved sessions that belong to the workspace.

A prompt can reference a file directly:

@src/auth/session.ts Trace the authentication flow and identify every caller.

The agent then reads related files, searches the repository, and inspects surrounding code before proposing or applying changes.

2. It chooses tools during the task

Repository work can call file-reading, search, editing, terminal, Git, web, MCP, or plugin tools. Permission rules evaluate each request before execution. Tool output returns to the same conversation and becomes part of the ongoing task context.

3. It records work as a session

The session stores the conversation and file snapshots under ~/.grok/sessions/. A later terminal, headless process, or ACP client can continue the same work.

4. It tracks unfinished operations

Builds, servers, monitors, subagents, and queued prompts stay attached to the session. The task pane and dashboard show which work is active, blocked, idle, completed, or failed.

5. Review changes and recover from mistakes

Diffs expose code changes during implementation. Use rewind to revisit an earlier conversation turn and Git to review or undo changes to your files.

Interactive TUI, Headless Mode, and ACP

ModeInvocationTypical Role
Interactive TUIgrokRepository exploration, implementation, review, and multi-agent supervision
Headless CLIgrok -p "..."CI, scripts, bots, scheduled checks, and machine-readable tasks
ACP agentgrok agent stdioEditor integration and application-controlled agent sessions

Interactive TUI

Running grok opens a full-screen terminal application. It contains scrollback, prompt input, tool cards, diffs, task panels, extension controls, session navigation, and the Agent Dashboard.

Automatic theme detection works through SSH and tmux, and the theme picker accepts aliases such as transparent, dark, and system. Typing exit or quit from the Dashboard closes the CLI.

Available shortcuts:

KeyAction
Shift+TabCycle Normal, Plan, and approval modes
Ctrl+BOpen background tasks
Ctrl+;Open the prompt queue
Ctrl+SOpen sessions
Ctrl+LOpen extensions
Ctrl+\Open the Agent Dashboard
EscShows a reminder to use Ctrl+C during a running turn
Ctrl+CCancel the current turn
Esc EscOpen rewind from an empty prompt
Ctrl+GMove a foreground command to the background

Headless CLI

Headless mode sends one prompt and returns output through standard streams:

grok -p "Review the current diff and list possible regressions"

The output format controls how another process consumes the result:

grok -p "List unresolved TODO comments" \
  --output-format json
grok -p "Explain the service architecture" \
  --output-format streaming-json

plain returns readable text. json emits one final object. streaming-json emits newline-delimited events as the task progresses.

A JSON Schema can constrain the final response for downstream automation:

grok -p "Audit the changed API routes" \
  --output-format json \
  --json-schema audit-schema.json

Headless sessions use the same storage system as interactive work. A script can start a task, capture its session ID, then resume it during another stage.

Headless grok -p waits for background goals and for the follow-up turn triggered by a completed background task. Set --background-wait-timeout to bound that wait. If the timeout stops pending work, the command exits with an error. Approval requests that cannot run are reported to standard error.

ACP Agent Mode

The ACP entry point runs over JSON-RPC through standard input and output:

grok agent stdio

An editor or host application manages the visible interface. Grok Build manages the session, repository tools, project context, permissions, model calls, and task state.

Plan Mode and Approval Modes

Plan mode places a review step between repository analysis and implementation.

Enter it from the TUI:

/plan Migrate the REST API from Express to Fastify

The agent can search the repository, inspect dependencies, identify affected files, and write a structured session plan. Project file changes require approval. /view-plan reopens the current plan during the session.

During plan approval or preview, press y to copy the complete plan as Markdown.

A useful plan request includes the expected outcome and the decisions that need investigation:

Plan the migration from session cookies to rotating JWT authentication.
Cover:
- affected middleware and routes
- token storage and rotation
- database changes
- test updates
- deployment order
- rollback path

The execution mode controls how Grok Build handles tool approvals.

ModeBehavior
PlanFocuses on planning and restricts normal write flow
AskPrompts before actions that require approval
Always-approveExecutes requested tools without interactive prompts
Accept editsApproves file edits while retaining prompts for shell commands
Don’t askDenies actions that lack an explicit allow rule

Always-approve removes interactive approval requests. Sandbox restrictions and explicit deny rules still apply.

Unattended jobs need stricter policies than an interactive development session. A CI review can use dontAsk, grant a narrow set of commands, and deny destructive operations:

grok -p "Review the API changes and run approved checks" \
  --permission-mode dontAsk \
  --allow 'Bash(git *)' \
  --allow 'Bash(cargo check*)' \
  --allow 'Read' \
  --allow 'Grep' \
  --deny 'Bash(git push*)' \
  --deny 'Bash(rm -rf *)'

Deny rules take priority over allow rules. Command chains are evaluated by segment, which prevents an approved read command from carrying an unapproved destructive command in the same shell expression. Permission prompts display the complete script. Press Ctrl+F to expand a long Bash body before approving it.

Subagents, Worktrees, and the Agent Dashboard

Large coding tasks often contain several independent investigations. Grok Build represents these branches of work as subagents and peer sessions.

A parent session can delegate tasks such as:

  • tracing an authentication flow
  • examining database migrations
  • updating tests
  • reviewing a proposed patch
  • checking documentation or external APIs
  • checking another package for regressions

Each subagent receives its own conversation context. The parent can track its status and receive the result when it finishes. A follow-up can resume work in a completed subagent session.

In Grok Build 2.0, subagents can send messages to one another during a run. For example, an agent reviewing API routes can share a suspected authentication issue with an agent writing tests. Open a running subagent to send your own instructions as it works.

Git Worktree Isolation

Parallel file editing becomes risky when several agents share one working directory. Grok Build addresses this with worktree sessions.

Start an isolated session from the shell:

grok -w

Name the worktree and assign a task:

grok --worktree=auth-refactor "Refactor the authentication middleware"

Choose the base reference:

grok -w --ref main "Fix the intermittent integration test"

A worktree session lives under:

~/.grok/worktrees/<repository>/<name>

It starts from the selected Git state and receives an isolated working directory. Worktrees created from the current state include uncommitted changes. A clean --ref start uses the selected branch, tag, or commit.

The worktree is a normal Git checkout. Review its changes, create commits, push the branch, or merge it through the team’s existing Git process.

Use grok worktree create to prepare a managed worktree without opening an interactive session. The worktree commands also work inside Jujutsu repositories.

Worktrees persist after their sessions end. Cleanup requires an explicit command:

grok worktree list
grok worktree show <id>
grok worktree rm <id>
grok worktree gc --max-age 7d

Forking a Session

/fork copies the current conversation into a peer session. A directive can send the fork toward a different solution:

/fork Explore a database-backed token store instead.

Add worktree isolation when both branches will edit files:

/fork --worktree Implement the alternative design in an isolated branch.

Forking preserves the shared history up to the split. Each branch then develops its own tool activity, changes, and conclusions.

Worktree forks run inside the new worktree path. Forking is blocked while an approval request is open. Cleanup commands refuse worktrees used by an open session, and grok worktree rm without -f refuses worktrees with unsaved changes or an incomplete safety check.

Agent Dashboard

The Dashboard presents all sessions in a full-screen control view:

grok dashboard

From an active session, open the dashboard with /dashboard or Ctrl+\.

Sessions appear under states such as:

  • Needs input
  • Working
  • Idle
  • Inactive
  • Completed
  • Failed

Selecting a session opens a live preview of its latest activity, and each Dashboard row summarizes what the agent did in the previous turn. A reply sent to an idle session arrives immediately. A reply sent to a busy session enters its prompt queue. Permission questions can be answered from the Dashboard without opening the full conversation.

The bottom input bar starts a new session. Directory and worktree controls determine where the new agent operates. The terminal acts as a lightweight supervisor for several repository tasks.

Pinned sessions keep their chosen order across restarts. The Dashboard identifies each session’s worktree, and dragging across peek text copies the selected passage when you release the mouse.

Sessions, Rewind, Forking, and Context Management

Every interaction creates a persistent session tied to the working directory.

The UI now appears immediately on cold starts while models and settings continue loading in the background. Large session forks and resumes also use less memory.

Resume a specific session by its ID or title:

Title matching accepts different word separators, so fix-login-bug finds a session named Fix login bug. Multiple matches are listed newest first with their last-update times. A title with no local match produces an immediate message and suggestions. Inside a session, /resume <id or title> opens a unique exact match directly or filters the picker. Picker searches match every typed word in any order.

grok --resume <session-id>

Resume the most recent session for the directory:

grok --resume

Continue through the shorthand flag:

grok -c

Remote resume restores the conversation only. Add --restore-code when the resumed session must also restore its saved code state. Grok leaves the working tree unchanged unless you pass that flag.

Headless automations can assign a UUID with --session-id. Resuming with --fork-session copies the prior context into a new session ID.

Session Search and Export

The CLI includes commands for reviewing past work:

grok sessions list
grok sessions search "authentication migration"
grok sessions delete <session-id>
grok export <session-id> migration-review.md

An exported transcript creates a Markdown record of the conversation. File changes belong in Git.

In Grok Build 1.x, export and copy operations refuse to overwrite an existing file, and session sharing via /share was removed in version 1.0.51.

Rewind

In Grok Build 2.0, enter /rewind or press Esc twice when the agent is idle. Select an earlier prompt from the rewind list. Grok removes the conversation turns after that point but leaves every file change on disk.

To undo unstaged changes to a tracked file, review the diff and use Git’s interactive restore to select individual changes:

git diff -- path/to/file
git restore -p -- path/to/file

Context Compaction

Long sessions eventually approach the model’s context limit. /compact summarizes earlier conversation history and retains a shorter working state.

Optional instructions can protect important details:

/compact Preserve the approved architecture, unresolved test failures, and rollout constraints.

/context reports context usage. Use /context-window to choose a context window size when the selected model offers options. Automatic compaction runs as the session grows and can recover from context-overflow errors. Repeated refills stop after three consecutive attempts. Earlier image attachments survive multiple compactions.

Cross-Session Memory

Dynamic memory in Grok Build 2.0 carries useful knowledge from one session to the next. For example, an agent can recall a project’s architecture and earlier implementation decisions when you return to the repository.

In the original 1.x runtime, /memory opens saved Markdown notes and /dream organizes recent notes by topic. The [memory] section of config.toml controls memory through enabled, and --no-memory disables it for a session.

Background Tasks, Loops, Monitors, and Prompt Queues

Repository agents often start operations that outlive a model response. Grok Build tracks these operations as first-class session objects.

Background Commands

Development servers, builds, tests, and other long-running commands can run in the background. Ctrl+B opens the task pane. /tasks inserts a task summary into the conversation.

A foreground process can move to the background with Ctrl+G. Selecting a task and pressing x stops it.

This fits commands such as:

npm run dev
cargo test --workspace
docker compose up
pytest -x

The agent can return to their output after working on another part of the task.

Background shell commands appear as live task rows with streaming output. Quitting Grok stops its shell commands, and quitting with a running workflow requires a second confirmation.

Scheduled Prompts

/loop repeats an agent request at the interval you enter:

/loop 5m Run the test suite and report new failures.

The scheduler accepts seconds, minutes, hours, and days, with a minimum interval of 60 seconds. Scheduled /loop tasks run in the background. Current loops expire after seven days, and the scheduler caps the number of active entries. A loop can include a stop condition so a recurring task ends when its work is complete.

Scheduled tasks also remind the agent to check results and clean up or update recurring schedules.

A loop handles periodic state checks. It is a poor fit for a noisy real-time log.

Goals and Workflows

Use /goal <objective> for work that needs repeated turns and a verifiable completion condition. /goal pause pauses it, and /goal resume continues it. Three consecutive continuations with no tool call pause the goal automatically.

Workflows in Grok Build 2.0 run multiple subagents from a JavaScript module and collect their findings in one result. For example, ask Grok to audit every API route for missing authentication checks and verify each finding.

Save reusable scripts as .grok/workflows/<name>.js in a trusted project, or in ~/.grok/workflows/ for use across projects. Run /<name> to start a workflow and /workflow runs to inspect its progress.

When you invoke an older Rhai workflow by name in 2.0, Grok creates a JavaScript copy beside the original script. In 1.x, use /create-workflow and /workflow <name> to create and start a workflow, and /workflow pause, /workflow resume, or /workflow stop to manage its run.

Monitors

A monitor connects a script or event stream to the conversation. Each output line becomes a notification.

Examples include:

  • watching deployment logs
  • tracking a CI job
  • detecting changes on a port
  • observing a file-generation pipeline
  • waiting for an external process to reach a known state

Prompt Queue

New prompts sent during an active turn enter a queue. The current task keeps running, and the queued instructions wait in order.

Ctrl+; opens the queue panel. /queue prints its current contents.

Send follow-up instructions while the agent is working. Queued prompts stay visible while Grok waits for subagents, and slash-command or image rows can be reordered before they run. Rapid send-now actions retain earlier queued messages.

Remote Control and Cloud Agents

Grok Build 2.0 offers two ways to continue working away from your terminal.

Control a Local Session Remotely

Open /remote in an active full-screen session and press Enter on the Remote Control row to enable it. Sign in to Grok Build on your iOS device or another computer with the same account, request access, and approve the matching pairing code on the host.

Send prompts, follow progress, and respond to approval requests from the paired device. Commands and edits still run on the host, which must stay online with Grok running.

Send a Task to a Cloud Agent

On a plan with cloud agents, press & at an empty prompt and submit a message to transfer your session to the cloud. Start a new cloud task directly from the shell with:

grok cloud send -m "Review the current feature for missing tests"

Both methods require a Git repository with an origin remote. Grok pushes your current changes, including uncommitted files and unpushed commits, to a new branch. Check for secrets before sending. Ignored files are excluded.

Project Rules with AGENTS.md

Grok Build loads repository instructions into each session before work begins.

A root AGENTS.md can contain:

# Project Rules
- Use TypeScript for application code.
- Run `npm test` before completing a task.
- Keep API handlers under `src/routes/`.
- Use Zod for request validation.
- Do not modify generated files under `src/generated/`.

Nested files add package-specific rules:

my-monorepo/
├── AGENTS.md
└── packages/
    ├── frontend/
    │   └── AGENTS.md
    └── backend/
        └── AGENTS.md

A session inside packages/frontend/ receives the repository rules and the frontend rules. Deeper files take priority when instructions conflict.

Grok Build recognizes several instruction formats:

  • AGENTS.md
  • Agents.md
  • AGENT.md
  • CLAUDE.md
  • Claude.md
  • CLAUDE.local.md
  • Markdown files under .grok/rules/
  • Markdown files under .claude/rules/
  • Markdown files under .cursor/rules/

Rule files load in full. Concise instructions protect the context budget and reduce conflicts.

You can pass temporary rules for one session:

grok --rules "Use TypeScript. Do not edit database migrations."

--system-prompt-override replaces the normal system prompt and requires greater care.

Inspect the effective project configuration before starting a sensitive task. The report identifies loaded rules, skills, plugins, hooks, MCP servers, compatibility settings, and their origins.

grok inspect

Skills, Plugins, Marketplaces, MCP Servers, and Hooks

Grok Build’s extension system operates at several levels. Each level solves a different type of customization problem.

Skills

A skill packages reusable instructions, scripts, and other assets for a repeated task.

Grok Build discovers skills from:

./.grok/skills/
~/.grok/skills/
enabled plugin skill directories
additional configured skill paths

An invocable skill appears as a slash command. The agent can also select a skill when the current task matches its purpose.

Examples include:

  • preparing a release
  • reviewing database migrations
  • generating API documentation
  • checking accessibility
  • running a repository-specific deployment process

/skillify converts an existing session into a starting point for a reusable skill. The generated result needs editorial review because a successful one-time conversation can contain assumptions that do not belong in a general workflow.

Plugins

A plugin bundles several extension types:

  • skills
  • custom agents
  • slash commands
  • hooks
  • MCP servers
  • LSP servers

Local plugins can live inside the repository or your Grok directory. Marketplace plugins install under the configured marketplace storage path.

Manage them from the CLI:

grok plugin list
grok plugin install <plugin>
grok plugin update <plugin>
grok plugin disable <plugin>
grok plugin details <plugin>
grok plugin validate <path>

The TUI combines plugins, hooks, skills, and MCP servers in one extensions modal. The modal sorts items alphabetically and places skills in collapsible sections for quicker navigation through larger installations.

A plugin expands the agent’s code and data access. Review its manifest, commands, hooks, server definitions, and external connections before enabling it in a sensitive repository.

Marketplaces

A marketplace is a configured source of plugins. The TUI contains a Marketplace tab, while the CLI manages sources directly:

grok plugin marketplace list
grok plugin marketplace add <source>
grok plugin marketplace update

Marketplace installation reduces setup work across related integrations. Trust belongs to each installed package and its dependencies.

MCP Servers

Model Context Protocol servers expose external tools beside Grok Build’s built-in tools. Their names follow the pattern:

<server>__<tool>

Add a local stdio server:

grok mcp add filesystem -- \
  npx -y @modelcontextprotocol/server-filesystem /path/to/dir

Add a remote HTTP server:

grok mcp add --transport http \
  linear https://mcp.linear.app/mcp

Add a static authorization header:

grok mcp add --transport http \
  internal-api https://mcp.example.com/mcp \
  --header "Authorization: Bearer ${API_TOKEN}"

Inspect and diagnose servers:

grok mcp list
grok mcp doctor
grok mcp enable <name>
grok mcp disable <name>
grok mcp remove <name>

Remote servers that use OAuth start an authentication flow on first use. Grok stores local credentials under its configuration directory.

MCP results can include structured JSON data. Token-file authentication re-reads the file for each request, so you can rotate credentials without restarting the agent. Parallel MCP calls that request input each receive their own prompt.

The MCP view identifies connectors that need re-authentication. Built-in agent tools take precedence when an MCP server exposes a tool with the same name.

Project-scoped MCP definitions live in .grok/config.toml. Grok Build also reads common Claude and Cursor MCP files. A project server with the same name as a personal server replaces the personal definition for that workspace.

Invalid MCP entries in config.toml no longer prevent Grok Build from starting. Run grok inspect to identify configuration problems.

Project MCP and LSP servers belong to the repository trust boundary. Review them before granting folder trust.

Hooks

Hooks run a shell command or call an HTTP endpoint during session and tool lifecycle events.

Common applications include:

  • blocking unsafe commands
  • logging tool calls
  • formatting changed files
  • validating generated code
  • notifying an external service
  • starting a review after a subagent completes

A PreToolUse hook can block execution. Post-use hooks observe successful or failed operations. Other events cover session start, session end, prompts, permission denials, notifications, and subagent activity.

Store personal hook JSON files in ~/.grok/hooks/ or project hooks in .grok/hooks/. In the 1.x runtime, you can also define hooks in TOML configuration files. Grok reads Claude’s .claude/settings.json and Cursor’s .cursor/hooks.json. After reviewing the project’s hooks, run /hooks-trust to permit them to execute. The trust decision also applies to project MCP and LSP servers.

Hooks in a repository subfolder load when Grok starts there. /hooks lists inline and plugin load errors. HTTP hooks can call localhost, and a hook response with continue: false stops the turn. Windows spawn errors identify the shell or program that failed to start.

Hooks execute outside the model’s prose response. A small hook can enforce a policy more reliably than repeated instructions in prompts.

Claude Code and Cursor Compatibility

Grok Build 2.0 can import settings from Claude Code and continue saved conversations from other coding CLIs. Run these commands inside the TUI:

/import-claude
/resume-claude
/resume-codex

The first command imports Claude Code settings such as permissions, environment variables, MCP servers, and hooks. The other two open past Claude Code and Codex sessions, respectively.

Grok Build can also load configuration files already stored in your Claude Code and Cursor project directories.

Claude Code compatibility covers:

  • instruction files
  • rules
  • skills
  • agents
  • hooks
  • plugins
  • marketplaces
  • MCP servers

For Cursor projects, Grok reads files in .cursor/rules/, .cursor/hooks.json, and .cursor/mcp.json.

Run grok inspect in the project directory to list the rules, skills, hooks, plugins, and MCP servers Grok loaded, along with their source paths. Use the output to identify duplicate definitions and overrides.

Before running imported automation in production, exercise its hooks, tool permissions, and commands in a test repository. A hook that references a tool or permission from another agent can behave differently in Grok.

Custom Models and Configuration

In Grok Build 2.0, use /model to switch models during an active session without restarting the conversation:

/model grok-4.6

The subscription’s first-party models include Grok 4.7, Grok 4.6, Grok 4.5, and Composer 2.5. Premium, Super, and Ultra add third-party models, including Claude, Gemini, and hosted open-weight models.

Custom Model Endpoints (1.x)

In Grok Build 1.x, you can define your own model API endpoints, including a model server on your computer.

Personal settings live in:

~/.grok/config.toml

Windows uses:

%USERPROFILE%\.grok\config.toml

GROK_HOME selects another configuration directory.

A custom model profile should look like this:

[model.my-model]
model = "model-id"
base_url = "https://api.example.com/v1"
name = "My Coding Model"
env_key = "MODEL_API_KEY"
api_backend = "responses"
[models]
default = "my-model"

Set api_backend to "responses" for the Responses API, "chat_completions" for Chat Completions, or "messages" for the Anthropic Messages API. Replace model-id and base_url with your provider’s model ID and API endpoint. Set the MODEL_API_KEY environment variable before launching Grok. The model must also handle tool calls for agent-driven file editing and command execution.

For a local model server exposing the Chat Completions API on port 11434, add this profile to your configuration:

[model.local-coder]
model = "local-model-name"
base_url = "http://127.0.0.1:11434/v1"
name = "Local Coder"
env_key = "LOCAL_API_KEY"
api_backend = "chat_completions"

Replace local-model-name with the ID of your running model and set LOCAL_API_KEY to the credential your server expects. Inspect the loaded model:

grok inspect
grok models

Select it from the shell:

grok -m local-coder

Select it inside the TUI:

/model local-coder

With a local model, inference runs on your own machine. Web search, remote MCP servers, marketplace downloads, remote hooks, update checks, and remote session restoration still use the network when invoked.

Configuration Scopes

Grok Build merges configuration from several scopes:

ScopeTypical LocationPurpose
EnvironmentGROK_* variablesSession and CI overrides
Personal~/.grok/config.tomlPersonal settings
Project.grok/config.tomlShared MCP, plugin, and permission rules
Managed~/.grok/managed_config.toml or /etc/grok/managed_config.tomlOrganization defaults
Requirements~/.grok/requirements.toml or /etc/grok/requirements.tomlPinned policies

System requirements have the highest authority in managed deployments. A root-owned requirements file can lock authentication, sandbox, permission, telemetry, plugin, and marketplace policies.

Permissions, Sandboxing, and Data Boundaries

Grok Build separates model requests, local tool execution, permission decisions, and operating-system restrictions.

Permission Rules

Permissions decide which tools the model can request.

Rules can target:

  • shell commands
  • file edits
  • file reads
  • repository searches
  • MCP tools
  • web fetches

Use this configuration to allow Git inspection and file reads. In headless mode, --permission-mode dontAsk denies requests without an explicit allow rule:

[permission]
rules = [
  { action = "allow", tool = "bash", pattern = "git status*" },
  { action = "allow", tool = "bash", pattern = "git diff*" },
  { action = "allow", tool = "read" }
]

Commands such as rm, permission changes, process termination, and git push receive special treatment in approval-based sessions. Always-approve mode removes those prompts unless an explicit rule blocks the operation.

Sandbox Profiles

The sandbox restricts process access after Grok Build starts.

ProfileFilesystem and Child NetworkTypical Role
offUnrestricted filesystem, network allowedNo sandbox
workspaceWrites limited to the workspace, temp, and Grok data, network allowedNormal development
devboxWrites to top-level directories except /data, network allowedCloud development boxes
read-onlyWrites limited to temp and ~/.grok/; child network blocked on LinuxReview and audit
strictReads limited to the workspace and system paths; writes allowed in workspace, ~/.grok/, and temp; child network blocked on LinuxUntrusted repositories

Start a workspace sandbox:

grok --sandbox workspace

Start a stricter review session:

grok --sandbox strict

The sandbox profile is off unless you or your organization changes it.

To block access to SSH credentials, .env files, and PEM keys, create ~/.grok/sandbox.toml (or .grok/sandbox.toml inside a project) with a custom profile. The built-in profiles leave credential paths readable in some cases.

[profiles.protect-secrets]
extends = "workspace"
restrict_network = true
deny = ["/home/your-user/.ssh", "**/.env", "**/*.pem"]

Replace /home/your-user/.ssh with the absolute path to your SSH directory, such as /Users/your-user/.ssh on macOS. On Linux, install bubblewrap to enforce read denials. Launch Grok with the profile:

grok --sandbox protect-secrets

To make this profile your default, add profile = "protect-secrets" to the [sandbox] section of ~/.grok/config.toml.

On Linux, restrict_network = true blocks child-process network access through kernel controls. On macOS, Seatbelt restricts filesystem access, but the child-process network block does not take effect. Model API requests and Grok’s built-in web tools can still make network requests on either platform.

Permissions and sandboxing address different risks. A permission rule limits the actions the agent can request. A sandbox limits what an approved process can reach.

Authentication

Choose a sign-in method for your environment:

  • interactive account login
  • device-code login
  • external organization authentication
  • API keys

Device authentication fits SSH sessions, containers, and remote development environments:

grok login --device-auth

CI commonly supplies an API key through an environment variable:

export XAI_API_KEY="xai-..."

Managed deployments can require a specific identity provider or team and reject personal credentials.

Local and Remote Data

In a local session, file reads, edits, shell commands, Git operations, and local MCP processes run on the host machine. A task sent to a cloud agent runs in its cloud environment.

First-party model inference sends the assembled prompt and selected file context over an encrypted connection to the inference service. Responses stream back to the local session. Local session history stays under ~/.grok/.

Remote session restoration and cloud agents use additional network services. Model providers and external integrations have their own data paths.

When a team administrator enables Zero Data Retention (ZDR), the inference service does not retain prompts, code, or responses. Without ZDR, open /privacy or /settings to manage code-data retention. Local session history remains on your machine.

With a custom local model endpoint in 1.x, inference can run locally. External tools and integrations may still communicate over the network.

Headless Workflows for CI and Scripts

Review a Pull Request Diff

grok -p "Review the current diff for regressions, security issues, and missing tests" \
  --output-format json \
  --sandbox read-only \
  --permission-mode dontAsk \
  --allow 'Read' \
  --allow 'Grep' \
  --allow 'Bash(git diff*)' \
  --allow 'Bash(git status*)'

Generate a Structured Repository Report

grok -p "Audit this repository against the supplied schema" \
  --output-format json \
  --json-schema repository-audit.json

Continue a Multi-Step Automation

Start a session and capture its ID:

SESSION_ID=$(
  grok -p "Inspect the migration and propose a test plan" \
    --output-format json |
  jq -r '.sessionId'
)

Resume during the next stage:

grok --resume "$SESSION_ID" \
  -p "Run the approved checks and summarize the failures" \
  --output-format json

Disable Update Checks in Automation

grok --no-auto-update \
  -p "Check the generated API client" \
  --output-format json

Unattended automation should pin the CLI version, model, permissions, sandbox profile, working directory, and expected output structure.

Core CLI Reference

This table includes the original 1.x command set and the cloud-send command introduced in 2.0.

Main Commands

CommandPurpose
grokStart the interactive TUI
grok loginAuthenticate
grok logoutClear cached authentication
grok inspectShow effective configuration
grok doctorDiagnose terminal, tmux, clipboard, keyboard, and environment issues
grok modelsList models for your account
grok mcpManage MCP servers
grok pluginManage plugins
grok plugin marketplaceManage marketplace sources
grok sessionsList, search, or delete sessions
grok exportExport a session transcript
grok importImport sessions from Claude Code
grok memory clearClear workspace or global memory
grok worktreeManage Grok worktrees
grok dashboardOpen the Agent Dashboard
grok agent stdioStart the ACP agent
grok wrapRun a command with terminal clipboard access
grok updateCheck or install CLI updates
grok --versionIdentify the installed version
grok cloud send -m "<task>"Start a cloud agent (2.0)
grok completionsGenerate shell completions
grok setupInstall managed configuration

Common Session and Execution Flags

FlagPurpose
--cwd <PATH>Set the working directory
-r, --resume [ID or title]Resume a session
-c, --continueContinue the latest directory session
-s, --session-id <UUID>Assign a session ID
--fork-sessionFork a resumed session
-w, --worktree [NAME]Start in a new worktree
--ref <REF>Choose the worktree base
-m, --model <MODEL>Select a model
-p, --single <PROMPT>Run a headless prompt
--output-format <FORMAT>Select plain, JSON, or streaming JSON
--json-schema <FILE>Constrain structured output
--background-wait-timeoutLimit the wait for headless background work
--permission-mode <MODE>Select a permission policy
--allow <RULE>Add an allow rule
--deny <RULE>Add a deny rule
--sandbox <PROFILE>Select a sandbox profile
--no-auto-updateSkip background update checks
--no-planDisable planning behavior
--no-subagentsDisable subagent delegation
--no-memoryDisable memory use
--disable-web-searchRemove web-search access

Run the built-in help for the complete command surface:

grok --help
grok <subcommand> --help

Pros

  • Full-screen terminal agent workspace
  • Interactive, headless, and ACP modes
  • Parallel Git worktree sessions
  • Persistent sessions with rewind
  • Fine-grained permission policies
  • Multiple sandbox profiles
  • Multiple model providers in Grok Build 2.0

Cons

  • Remote inference receives selected context
  • Sandbox defaults to off
  • Worktrees persist after sessions
  • Extensions expand the trust surface
  • Free plan has limited agent requests
  • Third-party models require a higher paid plan

Alternatives and Related Resources

FAQs

Is Grok Build open source?

Yes, for the original Grok Build 1.x. Its terminal client and agent runtime are hosted on GitHub, with first-party code licensed under Apache 2.0.

Does deleting a Grok Build session remove its worktree?

In Grok Build 1.x, deleting a session leaves its worktree and Git checkout in place. Use grok worktree rm to remove the worktree and grok worktree gc to clear stale tracking entries.

Can Grok Build reuse an existing Claude Code setup?

Yes. Run /import-claude in Grok Build 2.0 to import settings, or /resume-claude to reopen an earlier session. Use grok inspect to check the configuration loaded for your working directory.

Can Grok Build run with a local model?

Yes, with Grok Build 1.x. Configure a model profile in ~/.grok/config.toml with your local server’s URL, model ID, and API protocol, as shown in the Custom Model Endpoints section above. The model must handle tool calls for coding-agent tasks. If you used the example profile, run grok -m local-coder. Hosted open-weight models in the 2.0 model picker run remotely.

Does the strict sandbox block network access on macOS?

The restrictive profiles block child-process networking through Linux kernel controls. The current macOS sandbox restricts filesystem access but does not enforce the same child-network block.

Last updated: Nov 30, 2026

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!