In short.
The Grok Hooks guide teaches developers to automate coding-assistant events, with the main catch that failed hook checks allow tool calls to proceed. Hooks can log tool activity, run formatters, send notifications or explicitly deny a tool call before execution. The page explains configuration locations, event matching, project trust and the command input/output contract. Only PreToolUse can block execution; timeouts, crashes and malformed output do not block it. Pricing, supported versions and runtime reliability are unknown, and the documented behavior has not been tested.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete selected documentation page at [https://docs.x.ai/build/features/hooks.md], including configuration, trust, events and the script contract. Linked pages are excluded. No license notice appears in the supplied page. Commands, hooks, HTTP endpoints and compatibility behavior were not executed or tested.
The overview
identity
This is xAI's documentation for Grok hooks: shell commands or HTTP endpoints invoked when events occur during an assistant session. The guide is available at [https://docs.x.ai/build/features/hooks.md].
It is a feature guide containing configuration and interface details. It does not supply the safety-check script used in its example.
assessment
The guide provides enough detail to begin configuring event-driven automation: where files belong, how to match tools, which events exist and how command hooks receive data.
Its most consequential limitation is failure behavior. A blocking check must explicitly deny execution; a broken or timed-out check leaves the tool call able to proceed. Actual enforcement and integration reliability are untested.
users
The guide is relevant to developers who want tool-use logs, automatic formatting after edits, end-of-turn notifications or checks before commands run.
Following it requires understanding JSON and either shell commands or HTTP services. Beginners receive a small configuration example, but the page does not teach scripting, regular expressions or endpoint implementation.
capabilities
Hooks support command execution or HTTP POST delivery. A matcher selects tools through a regular expression; omitting it matches every tool. Claude tool names are mapped to Grok names automatically.
Documented events are SessionStart, SessionEnd, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, PermissionDenied, Stop, StopFailure, Notification, SubagentStart, SubagentStop, PreCompact and PostCompact. PreToolUse is the only blocking event.
Grok also reads Claude Code and Cursor hook configuration files, including Cursor's camelCase event names.
Using it
requirements
You need a Grok environment supporting these hooks, a JSON configuration file and either a command to execute or an HTTP endpoint accepting event POSTs. Supported Grok versions, operating systems and installation requirements are not specified.
Project hooks require trust before execution. The trust decision also covers the project's MCP and LSP servers, so its scope extends beyond hooks.
mechanism
A command hook receives an event as JSON on standard input. Fields include hookEventName, sessionId, cwd and workspaceRoot; tool events also include toolName and toolInput. Its environment includes GROK_HOOK_EVENT, GROK_HOOK_NAME, GROK_SESSION_ID and GROK_WORKSPACE_ROOT.
For PreToolUse, the page shows a JSON denial decision with a reason on standard output. It separately specifies exit code 0 for allowing execution and exit code 2 for denying it. Timeouts, crashes, malformed output and other failures are recorded in the session while the tool call proceeds.
For passive events, standard output is ignored and successful commands should exit with code 0. The default timeout is five seconds.
setup
Place personal JSON hook files in ~/.grok/hooks/*.json or project files in <project>/.grok/hooks/*.json. Grok also reads .claude/settings.json and .cursor/hooks.json.
Under the hooks object, configure an event, an optional matcher and a handler. A command handler uses type command and a command value; an HTTP handler uses type http and a url. Timeout values are in seconds.
Inspect loaded hooks through the /hooks tab of the extensions modal. Project trust can be granted with /hooks-trust or by launching with --trust; decisions are stored in ~/.grok/trusted_folders.toml.
example
The documented configuration attaches a command hook to PreToolUse, matches Bash, invokes bin/safety-check.sh and sets a ten-second timeout. This illustrates where a developer could place a check before a shell tool runs.
The page shows denial output as {"decision":"deny","reason":"Unsafe command detected"} and identifies exit code 2 as denying execution. The script's implementation and effectiveness are unknown; neither the configuration nor the script was executed.
Assessment & evidence
limitations
Only PreToolUse can block a tool call. Other events cannot serve as pre-execution gates, and failed checks permit execution to continue.
The page does not specify precedence when a command's JSON decision conflicts with its exit status. It also does not explain HTTP denial responses, authentication, retries or delivery guarantees.
Supported versions, execution ordering, performance and compatibility beyond the stated configuration support are unknown.
reasoning
The documented lifecycle events make hooks a plausible fit for formatting, logging and notifications because those tasks can be attached to specific session or tool events.
A practical inference from the failure contract is that configuring a safety hook does not guarantee enforcement: blocking depends on an explicit denial. The page does not establish hooks as a complete security boundary.
alternatives
Claude Code and Cursor are the adjacent systems named in the guide. Grok's ability to read their hook files may help developers reuse existing configuration.
The page does not compare their native hook behavior, reliability or costs. Reading their configuration files does not establish complete feature parity.
evidence
The evidence consists of the complete Hooks documentation page at [https://docs.x.ai/build/features/hooks.md]. It contains configuration examples, an event table, trust instructions and a command interface description.
The page supplies no benchmark results, demonstrated execution traces or implementation of bin/safety-check.sh. Blocking behavior, formatting, notifications and HTTP delivery remain untested.
Access & freshness
costs
The page provides no pricing for Grok access, hook execution or HTTP services. Hook-specific charges and total operating cost are unknown.
rights
The selected page states no license or redistribution terms for its documentation or examples. Permission to redistribute those materials is unknown.
freshness
The page was captured on 23 November 2026 at 04:20:01.703 UTC. Its captured source revision is sha256:4f013d7601893175f27233934a3de60b9df0c0efeb31b041613aae56f1103eeb.
The page gives no publication date, update date or supported Grok version. Changes after this snapshot are unknown.
actions
Choose an event matching the intended automation. Use PreToolUse when a decision must precede tool execution; use a completion event for work such as formatting after edits.
Review project hooks and the associated MCP and LSP configuration before granting project trust. Inspect the loaded configuration in /hooks.
Before depending on a blocking hook, verify allowed calls, explicit denials and failure behavior in the intended environment. Resolve conflicting-output semantics and HTTP response requirements if the implementation depends on them.
