Support for the new Grok CLI
Thanks!
wshm ยท Automated triage by AI
๐ Automated Triage
| โจ Category | feature |
| ๐ข Priority | low |
| ๐ฏ Confidence | 72% |
Summary
Feature request to add RTK wrapper/support for the Grok CLI; body is nearly empty so details on commands or behavior needed are unknown.
Triaged automatically by wshm ยท This is an automated analysis, not a human review.
This is needed, thanks
Adding the contract details this issue is missing (needs-info), gathered from grok CLI v1.0.0 on macOS (its own bundled docs plus direct probing of rtk's hook processor).
Good news: grok's hook system is already Claude-Code-compatible on the output side. Its bundled docs (~/.grok/docs/user-guide/10-hooks.md) specify, for PreToolUse:
- Config location:
~/.grok/hooks/*.json(global) or project-scoped, same shape as Claude Code:{ "hooks": { "PreToolUse": [ { "matcher": "...", "hooks": [ { "type": "command", "command": "...", "timeout": 10 } ] } ] } } - Output for rewriting:
{"hookSpecificOutput": {"hookEventName": "PreToolUse", "updatedInput": {"command": "..."}}}โ byte-identical to whatrtk hook claudealready emits. - The docs also state grok accepts Cursor-style event names (
preToolUse,beforeShellExecution) as aliases forPreToolUse. - Failures are fail-open; only an explicit
denyblocks a call.
The only incompatibility is the input side โ casing:
Claude Code (what rtk hook claude parses) |
grok | |
|---|---|---|
| tool name | tool_name |
toolName |
| tool input | tool_input |
toolInput |
| shell tool value | Bash |
run_terminal_command (docs: "Bash โ run_terminal_command", and a matcher on Bash matches both) |
Verified locally:
$ echo '{"toolName":"run_terminal_command","toolInput":{"command":"git status"}}' | rtk hook claude
# (empty output โ not recognized)
$ echo '{"tool_name":"Bash","tool_input":{"command":"git status"}}' | rtk hook claude
{"hookSpecificOutput":{...,"updatedInput":{"command":"rtk git status"}}}
Suggested fix โ likely a handful of lines, no new handler needed: in the rtk hook claude input parser, accept toolName/toolInput as fallbacks for tool_name/tool_input, and treat run_terminal_command as an alias of Bash. Then rtk init --agent grok only needs to drop a JSON file into ~/.grok/hooks/.
I'm bridging it locally with a small shim that normalizes the casing, shells out to rtk hook claude, and passes the output through unchanged. Scope of what I verified: the shim's own transform (both casings in, correct updatedInput out, fail-open on bad/empty/non-shell input, no double-prefix when the command is already rtk-prefixed). End-to-end is also confirmed: grok inspect lists the handler as command matcher=Bash|run_terminal_command user (native grok layer, not the Claude-compat layer), and a headless run (grok -p "Run exactly one shell command: git status --short") landed in rtk's own history DB as git status --short -> rtk git status --short, with the row count going 110 -> 111. So the rewrite genuinely applies inside a live grok session. Happy to open a PR if a maintainer confirms the approach.
Two notes for whoever picks this up:
- Guard the rewrite when the command is already
rtk-prefixed.rtk hook claudealready returns empty in that case, so passing its output through verbatim is safe, but a hand-rolled handler could double-prefix. - grok applies
updatedInputonly after all handlers finish, last rewrite wins โ so ordering matters if another hook also rewrites.