Skip to content
Agentic Control Plane

Grok Build Hooks Reference: PreToolUse in Every Mode, Fail-Open by Default

David Crowe David Crowe · · Updated · 9 min read
grok-build hooks permissions reference
Share X HN LinkedIn

Just want the answer?

Grok Build's PreToolUse hook fires in every permission mode, --always-approve included. The ACP hook registers itself in ~/.grok/hooks/acp.json. Install it with:

curl -sf https://agenticcontrolplane.com/install.sh | bash

Full walkthrough: Grok Build install guide. Native control model: Grok Build permissions, explained.

Grok Build is xAI’s terminal coding agent. Of the harnesses in this reference series, its hooks are the closest to Claude Code’s. It reads your Claude Code settings files and accepts Claude’s tool names and JSON output shape. But its own hook runner fails open, and the field it reads for a decision isn’t the one most Claude-style hooks write. This page covers what fires, what it returns, and what a hook has to do on its own to hold in every mode.

Where hooks live

Grok Build reads hook registrations from three places:

  • ~/.grok/hooks/*.json: always trusted, no prompt.
  • <project>/.grok/hooks/*.json: only after you trust the folder once.
  • Inline [[hooks]] blocks in config.toml.

By default it also finds hooks in your existing ~/.claude/settings.json, ~/.claude/settings.local.json and ~/.cursor/hooks.json. If you already run Claude Code or Cursor hooks, Grok Build may already be running them.

Five permission modes

Mode What it means
default Prompts for anything not pre-approved
plan Read-only; no edits or shell commands run
acceptEdits File edits auto-approved; shell commands still prompt
always-approve (--yolo) Every native prompt answered yes automatically
dontAsk (headless) No prompts at all; unmatched calls are silently denied

Don’t mix up the last two. always-approve answers yes to a prompt a human would have seen. dontAsk denies anything a rule doesn’t cover. For hooks they behave the same way: deny rules and PreToolUse hooks fire in every mode, always-approve included. The flag removes the confirmation dialog. It doesn’t remove the hook.

Only one event blocks

Grok Build fires SessionStart, SessionEnd, UserPromptSubmit (observe-only; unlike Claude Code it can’t deny here), PreToolUse, PostToolUse, PostToolUseFailure, PermissionDenied, Stop, SubagentStop, and a compaction event. Only PreToolUse can stop a call before it runs.

The output contract: a top-level field

A Grok Build hook writes JSON to stdout. The field the runner reads is a top-level decision:

{ "decision": "deny", "reason": "Blocked by policy" }

"allow" or no field lets the call proceed. Exit code 2 is an alternate deny, read from stderr.

Here’s the trap. Claude Code hooks put their verdict under hookSpecificOutput.permissionDecision. Grok Build’s docs say they accept that shape too, “for forward-compatibility.” We read Grok Build’s open-source hook runner (August 2026). It parses only the top-level decision. A hook that only sets hookSpecificOutput.permissionDecision: "deny" leaves it unset, which reads as no decision, which means allow. The hook can compute a deny correctly and still let the call through because it wrote the answer in the wrong place. A hook for Grok Build has to write the flat decision field to block anything.

Fail-open, and what the ACP hook does about it

Grok Build’s default hook timeout is 5 seconds. A timeout, a crash or malformed output all mean allow. Only an explicit "decision": "deny" stops a call. That’s reasonable for the harness: a broken hook shouldn’t brick your session. But anything built on this contract inherits “proceed” as its failure mode unless it adds its own.

The ACP hook adds its own, and it isn’t the same everywhere. In interactive and auto sessions it fails open loudly: a [ACP] ⚠ UNGOVERNED warning on stderr and a line in ~/.acp/lapse.log. In unattended sessions (headless, CI, dontAsk, bypass) it fails closed, because nobody is reading the scrollback. The gateway call is retried once before either happens.

No “ask” in Grok Build

Grok Build’s hook contract has no ask, only allow or deny. The ACP hook handles an ACP ask by mode:

  • In default and plan, Grok Build’s own confirmation prompt still stands after the hook returns, so the ask lands there.
  • In auto, always-approve and headless modes there is no prompt to fall back on. The ask becomes a deny with a link to approve it on the console. You approve, then ask the agent to retry.

A local allow rule outranks an ask in attended modes. A deny always holds, in any mode. The coverage matrix has the same story for every harness.

Installing it

curl -sf https://agenticcontrolplane.com/install.sh | bash

By hand:

mkdir -p ~/.acp/hooks/grok-build ~/.grok/hooks
curl -fsSL https://agenticcontrolplane.com/hooks/grok-build/hook.mjs \
  -o ~/.acp/hooks/grok-build/hook.mjs
curl -fsSL https://agenticcontrolplane.com/hooks/grok-build/acp.json \
  -o ~/.grok/hooks/acp.json

The registration file points Grok Build at the local script. The script calls the gateway, so rotating your ACP key means overwriting the credentials file, not reinstalling.

--local skips Grok Build

In the installer’s source, Grok Build is skipped under --local. It prints that the hook needs a workspace and that local decisions aren’t wired there yet. Claude Code’s and Cursor’s hooks can use an on-device rules file (~/.acp/policy.json) in local mode. Grok Build’s hook always calls the hosted /govern/tool-use endpoint, so with no workspace key it has nothing to check against. The installer skips the setup instead of registering a hook that would never do anything.

Known limits

  • The hook sees tool calls, not tokens. We don’t have a model-spend path for Grok Build, so the log records each call and its allow or deny, with Grok’s native tool name kept.
  • A hook can only judge what it is shown when it’s called. That’s true of every hook-based control, Grok Build’s included.
  • Grok Build’s own session log (~/.grok/sessions) has no documented way to query it. The ACP activity log is the searchable record of what the hook decided.

Compared with Claude Code hooks

The two are close but not the same. Claude Code reads hookSpecificOutput.permissionDecision and has a real ask. Grok Build reads a flat decision and only has allow or deny. Both run hooks in their “approve everything” modes, Claude Code’s bypassPermissions and Grok Build’s --always-approve. The Claude Code hooks reference covers the other side.

Frequently asked questions

Does a Grok Build PreToolUse hook fire under --always-approve?

Yes. Grok Build applies deny rules and PreToolUse hooks in every permission mode, always-approve (--yolo) included. The flag answers yes to Grok’s own prompts. It doesn’t stop the hook from running or from returning a deny that blocks the call.

What does a Grok Build hook return to block a call?

A top-level decision field: “deny” (with a reason string) blocks the call, “allow” or an absent field lets it proceed. Exit code 2 is an alternate deny channel. There is no ask value. Grok Build’s hook contract only has two outcomes.

What happens if a Grok Build hook times out or crashes?

The call runs. Grok Build’s hook runner is fail-open by design. A timeout (5 seconds by default), a crash, or malformed JSON output is logged to the scrollback, and the tool call proceeds. Only an explicit deny blocks it.

Can I run Grok Build's ACP hook in --local mode with no account?

Not today. The installer’s --local mode skips Grok Build: the hook needs a workspace to check calls against, and the on-device rules file Claude Code’s and Cursor’s hooks use locally isn’t wired into Grok Build’s hook yet.

Where to read more

Running Grok Build? One command adds a hook. Each tool call it sees is recorded, and a force-push, destructive SQL or curl | sh is blocked until you approve it on the console or from the email.

macOS · Linux · WSL
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
Windows · PowerShell
irm https://agenticcontrolplane.com/install.ps1 | iex

What the installer writes  ·  Grok Build guide  ·  free up to 5 agents

Share X HN LinkedIn
Get the next data drop
What agents actually cost, new tool-surface captures, and the occasional incident post-mortem — sent when we publish something worth your inbox, not on a schedule. Unsubscribe anytime.
Share: Twitter LinkedIn
Related posts

← back to blog