Skip to content

Agent Architecture

Grok Build

Grok Build is xAI's official open-source coding agent: a Rust harness plus terminal UI installed as `grok`. It keeps every writable surface under $GROK_HOME (default ~/.grok) with TOML config, a Claude-compatible hook directory, flat markdown commands, Anthropic-format skills, markdown subagents, and AGENTS.md project rules.

Source reviewed #37Checked 2026-09-07
Run type
CLI
Adapter
json-stdio
Source
OSS · xai-org/grok-build
Stars
★ 27k

Archive Context

This page is one host entry inside the full architecture archive and keeps multi-surface products visible instead of collapsing them into a single run type.

42 host archive
Host page
grok-build
Run cohort
CLI: 30
Archive route
/agents

Host Surface Perspectives

The host is the primary architecture boundary. Each runnable surface below separates what the host owns from what agent-connector can safely install for Grok Build.

1 surface entry

CLI

cli
Host entry
A terminal command owns the process, current working directory, stdin/stdout, shell environment, and project file discovery.
Host owns
The CLI host owns agent loop timing, approval prompts, tool execution, session files, and how hook or MCP subprocesses are launched.
Connector role
agent-connector can only write the host's documented CLI config, prompt, memory, hook, MCP, or package files and point them at the home binary. Current wired connector surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
Implementation consequence
A CLI surface is byte-addressable and smoke-testable from a temporary HOME, but terminal UI behavior still belongs to the host process. Visible host-native gaps for this surface: Statusline handler.

Verified Architecture

Source-checked on 2026-09-07. These notes are intentionally separate from the generated surface matrix below.

Sequence #37

Source pass

Current source review findings are kept as the first architecture section so readers can separate external evidence from the generated local coverage model.

  • Grok Build is xAI's official agent (Apache-2.0, binary artifact xai-grok-pager, installed as `grok`), distinct from the community superagent-ai/grok-cli behind the grok-cli adapter id.
  • Both products default to ~/.grok but never share a file: Grok Build keys on config.toml, Grok CLI on user-settings.json, so each adapter claims the directory only when the sibling's marker is absent.
  • Hooks fire PascalCase events that map 1:1 to twelve canonical agent-connector events; StopFailure, StopCancelled, and PermissionDenied ride the nativeHooks escape hatch, and PermissionRequest stays unset because PermissionDenied is a post-decision observation.

Runtime boundary

The adapter target is the Grok Build CLI process. The host owns the model loop, permission system, folder trust, and the TUI; agent-connector writes only the files the user guide documents under $GROK_HOME and <project>/.grok.

  • Project-scope config.toml contributes exactly [mcp_servers], [plugins], [permission], and [mcp] max_output_bytes; every other table is read from the user file only.
  • Project hooks require folder trust; user hooks are always trusted.
  • This is not the community Grok CLI: same default directory, different vendor, product, and config file.

MCP registration

MCP servers live in TOML under [mcp_servers.<name>] with stdio keys (command, args, env, enabled, startup_timeout_sec, tool_timeout_sec) or remote keys (url, headers). TOML has no interpolation, so environment references resolve to literals at install time.

  • User scope: $GROK_HOME/config.toml. Project scope: <project>/.grok/config.toml.
  • Detection keys on config.toml so the shared ~/.grok directory is never misreported as a Grok CLI install.

Hook bridge

Hooks are JSON files in $GROK_HOME/hooks/*.json or <project>/.grok/hooks/*.json using the Claude-compatible { hooks: { <Event>: [ { matcher, hooks: [ { type: "command", command, timeout } ] } ] } } shape. agent-connector writes its own file instead of merging into the user's config.toml [[hooks.<Event>]] block.

  • Twelve PascalCase events map 1:1 to canonical names, from SessionStart to PostCompact.
  • StopFailure, StopCancelled, and PermissionDenied have no canonical analog and ride the nativeHooks escape hatch.
  • PermissionRequest stays unset: PermissionDenied fires after the denial and is documented as non-blocking.

Content surfaces

Commands are flat markdown files whose filename stem is the slash-command name, skills are <name>/SKILL.md with Anthropic-format frontmatter, and subagents are agents/<name>.md with name, description, tools, and model frontmatter.

  • Memory is AGENTS.md loaded from the repo root down to the cwd, deeper files winning; user scope adds $GROK_HOME/rules/*.md.
  • Commands are prompt templates with no shell-exec affordance, so the actions surface is a host N/A rather than an adapter gap.

Marketplace and host-only affordances

Grok Build has a native [ui.status_line] type="command" surface that receives JSON on stdin. The host supports it, the adapter does not write it yet, so it is the one genuine coverage gap on this row.

  • A [plugins] table exists in project config, but no marketplace driver is wired for it.
  • Official xAI ownership is the affordance to highlight against the community Grok CLI row.

Host-specific shape

Grok Build is xAI's official Rust CLI agent: MCP in $GROK_HOME/config.toml, Claude-compatible hook JSON under .grok/hooks, commands, skills, agents, and AGENTS.md memory are wired; its native [ui.status_line] command is an adapter gap.

  • Form factor: CLI.
  • Native surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory, Statusline handler.
  • Wired surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
  • Visible gaps: Statusline handler.

Hooks

Hooks enter through a host-launched command that exchanges event JSON over stdio.

MCP

The adapter writes this host's native MCP registration dialect, including its root key, scope, transport fields, and environment syntax.

Memory

Managed memory text is written into the rules or memory file this host actually reads, with ownership markers for reversible uninstall.

Marketplace and affordances

Current install is a direct native-file write path; any package artifact is manual unless a driver is added.

  • Runtime handlers: none.
  • User-visible affordances: Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary..

Known Limits

  • Statusline is host-native but unwired; the page must show it as an adapter gap, not as unsupported.
  • Facts come from the in-repo user guide and hook event schema; product docs outside the repository were not reviewed.
  • Do not merge this row with grok-cli even though both default to ~/.grok.

Architecture Diagram

Host-specific flow for the CLI surface.

json-stdio
Host-owned architecture flowHost surfaceCLIRuntimejson-stdioNative artifactsMCP + hooks + content + memoryConnector boundarystdio eventsUser surfacecmds + skills + agents + memoryagent-connector writes only documented host artifacts; the host owns the agent loop.
  1. 1
    Entry point: CLI

    Terminal agent process reads user/project config and invokes the connector home binary for runtime callbacks.

  2. 2
    Connector package

    defineConnector package declares server, hooks, content, memory, and actions.

  3. 3
    Adapter module: grok-build

    json-stdio renderer at src/adapters/grok-build/index.ts.

  4. 4
    Native host artifacts

    Adapter writes MCP config + hook config + content files + memory/rules through this host's native file, package, or marketplace surface.

  5. 5
    Runtime boundary

    host launches JSON-stdio hook command

  6. 6
    User-visible surface

    Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary.

  7. 7
    Coverage ceiling

    6/7 native surfaces wired. Statusline handler are host-native but not wired yet.

Component Diagram

Static parts of the Grok Build integration and which side owns each one.

Components and ownershipGrok Build hosthostagent-connector packageconnectorgrok-build adapterjson-stdioNative artifactsartifactsRuntime bridgeruntimeUser-visible surfaceuser
  • Grok Build host

    CLI surface owns the model loop, UI shell, config discovery, and native lifecycle for this integration.

  • agent-connector package

    Normalizes connector declarations into MCP, hook, memory, content, and action payloads before delegating to a host adapter.

  • grok-build adapter

    Implements the json-stdio translation layer in src/adapters/grok-build/index.ts.

  • Native artifacts

    Adapter writes MCP config + hook config + content files + memory/rules through this host's native file, package, or marketplace surface.

  • Runtime bridge

    host launches JSON-stdio hook command

  • User-visible surface

    Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary.

Runtime Sequence Flow

Message order from install to runtime for the CLI surface.

User / projectagent-connectorgrok-build adapterGrok BuildAgent runtimeCoverage matrix1. Choose host adapter2. Resolve connector declaration3. Render host-native shape4. Host loads artifacts5. Run through host boundary6. Expose remaining ceiling
  1. 1 · User / project
    Choose host adapter

    Install or update starts against Grok Build; the selected surface is CLI.

  2. 2 · agent-connector
    Resolve connector declaration

    The package reads connector metadata and routes it to the grok-build adapter instead of exposing a generic host contract.

  3. 3 · grok-build adapter
    Render host-native shape

    Adapter writes MCP config + hook config + content files + memory/rules through this host's native file, package, or marketplace surface.

  4. 4 · Grok Build
    Host loads artifacts

    host launches JSON-stdio hook command

  5. 5 · Agent runtime
    Run through host boundary

    Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary.

  6. 6 · Coverage matrix
    Expose remaining ceiling

    6/7 native surfaces wired. Statusline handler are host-native but not wired yet.

Architecture Archive

The same five study axes are rendered for every host: runtime shape, hooks, MCP, memory, and host-only affordances.

Host-specific shape

Grok Build is xAI's official Rust CLI agent: MCP in $GROK_HOME/config.toml, Claude-compatible hook JSON under .grok/hooks, commands, skills, agents, and AGENTS.md memory are wired; its native [ui.status_line] command is an adapter gap.

  • Form factor: CLI.
  • Native surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory, Statusline handler.
  • Wired surfaces: MCP server, Hooks, Commands, Skills, Subagents, Memory.
  • Visible gaps: Statusline handler.

Hooks

Hooks enter through a host-launched command that exchanges event JSON over stdio.

MCP

The adapter writes this host's native MCP registration dialect, including its root key, scope, transport fields, and environment syntax.

Memory

Managed memory text is written into the rules or memory file this host actually reads, with ownership markers for reversible uninstall.

Marketplace and affordances

Current install is a direct native-file write path; any package artifact is manual unless a driver is added.

  • Runtime handlers: none.
  • User-visible affordances: Users see managed commands + skills + subagents + memory surfaces after install; runtime-only surfaces stay behind the host boundary..

Special Feature Inventory

Host-specific capabilities separated from the generic surface matrix: lifecycle hooks, MCP registration, memory/rules, marketplace delivery, and UI or content affordances owned by the host.

Lifecycle hooks

Wired

Hooks enter through a host-launched command that exchanges event JSON over stdio.

MCP registration

Wired

The adapter writes this host's native MCP registration dialect, including its root key, scope, transport fields, and environment syntax.

Memory and rules

Wired

Managed memory text is written into the rules or memory file this host actually reads, with ownership markers for reversible uninstall.

Marketplace delivery

Direct files

Current install is a direct native-file write path; any package artifact is manual unless a driver is added.

Host-only affordances

3/4 wired

Wired host affordances: Commands, Skills, Subagents. Host-native gaps: Statusline handler. Not confirmed: Action affordances.

Source Review Notes

Latest source pass for host-specific architecture details. This is separate from generated adapter coverage and local drift guards.

Checked 2026-09-07Open review source
xai-org/grok-build repository (user guide + xai-grok-hooks event schema)
  • Grok Build is xAI's official agent (Apache-2.0, binary artifact xai-grok-pager, installed as `grok`), distinct from the community superagent-ai/grok-cli behind the grok-cli adapter id.
  • Both products default to ~/.grok but never share a file: Grok Build keys on config.toml, Grok CLI on user-settings.json, so each adapter claims the directory only when the sibling's marker is absent.
  • Hooks fire PascalCase events that map 1:1 to twelve canonical agent-connector events; StopFailure, StopCancelled, and PermissionDenied ride the nativeHooks escape hatch, and PermissionRequest stays unset because PermissionDenied is a post-decision observation.

Evidence Map

Each host page ties public source evidence to the local adapter and drift guards that keep the rendered archive aligned with code.

Public source: xai-org/grok-build

Primary public repository or product source used for current host status and source links.

external
Open source

Local adapter implementation

Defines the install/uninstall behavior, native config rendering, capability flags, and any runtime parse/format bridge for this host.

local
src/adapters/grok-build/index.ts

Platform metadata and host-native matrix

Records the form factor, public source target, ranking source, native host surfaces, and current agent-connector coverage cells.

local
site/src/platform-data.ts

Architecture drift guard

Asserts that every registered host has a page, diagram, host-specific brief, source link, form-factor band, and adapter-aligned surface data.

local
tests/docs/platform-drift.test.ts

Runtime Shape

Hooks are dispatched through a host-launched command. The adapter parses host JSON, calls the connector handler, and formats the reply back to the host contract.

MCP registration
Wired through this adapter
Hook bridge
Wired

Connector Surfaces

Static content

MCP server, Hooks, Commands, Skills, Subagents, Memory

Runtime handlers

No runtime handler surfaces wired

Surface Matrix

Wired means agent-connector installs it now. Host native marks support we know about but have not wired yet.

SurfaceStatus
MCP server
Static content
agent-connector installs this surface today.
Wired
Hooks
Static content
agent-connector installs this surface today.
Wired
Commands
Static content
agent-connector installs this surface today.
Wired
Skills
Static content
agent-connector installs this surface today.
Wired
Subagents
Static content
agent-connector installs this surface today.
Wired
Memory
Static content
agent-connector installs this surface today.
Wired
Statusline handler
Runtime handler
The host appears to offer this, but this adapter has not wired it yet.
Host native
Action affordances
Runtime handler
No confirmed host-native surface.
N/A