Getting it into your agent
This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.
/plugin marketplace add okisdev/claude-code-fusion/plugin install grokWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/okisdev/claude-code-fusion/grok-cli-runtime)<a href="https://agentmods.dev/skills/okisdev/claude-code-fusion/grok-cli-runtime"><img src="https://agentmods.dev/badge/skills/okisdev/claude-code-fusion/grok-cli-runtime/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/okisdev/claude-code-fusion/grok-cli-runtime"><img src="https://agentmods.dev/badge/skills/okisdev/claude-code-fusion/grok-cli-runtime.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00019 | $0.05154 |
| Opus 5.5 | $0.00008 | $0.02062 |
| Sonnet 5.5 | $0.00004 | $0.01031 |
| Haiku 4.5 | $0.00002 | $0.00515 |
Grade A, and why
grok-cli-runtime scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 58 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Grok runtime
Primary helper:
node "${CLAUDE_PLUGIN_ROOT}/scripts/grok-companion.mjs" <subcommand> [flags]
Subcommand surface:
task [--prompt-file <path>] [--write] [--web] [--memory] [--background] [--resume <uuid>] [--resume-last] [--fresh] [--model <id>] [--effort <level>] [--max-turns <n>] [--cwd <dir>] [--json-schema <schema>] [--json] [--] [prompt]- The upstream Grok CLI has no default turn limit. An unset limit is unlimited, and one turn is one main-agent model call plus its tool cycle, excluding subagent calls. The companion defaults consult and write to
--max-turns 60; consult previously defaulted to 25. When the limit is reached, Grok prints the complete final JSON envelope to stdout, including partial text, usage,num_turns, andmodelUsage, then exits 1 with stderrError: max turns reached. The companion salvages that envelope and recordsfailureKind: "turn_limit". - Grok headless JSON has no top-level
modelfield. Model names are available only as keys inmodelUsagewhen usage attaches, so model capture depends on that map and on error-path salvage. MissingmodelUsageleaves the resolved model unavailable. review [--base <ref>] [--focus <text>] [--cwd <dir>] [--background] [--json]status [job-id] [--cwd <dir>] [--json]history [--all] [--limit <n>] [--cwd <dir>] [--json]result <job-id> [--cwd <dir>] [--wait] [--wait-timeout-ms <ms>] [--json]cancel <job-id> [--cwd <dir>] [--json]stats [--all] [--cwd <dir>] [--json]setup [--continuity <manual|claude-session>] [--enable-stop-gate] [--disable-stop-gate] [--clear-quota-cooldown] [--json]stop-gate
Execution rules:
- Slash commands stage their complete raw arguments through
transport-create, one Read of the allocated empty file, Write to that same file, and a fixed--raw-args-tokeninvocation. The token transport applies to task, review, status, history, result, cancel, stats, and setup. Raw request bytes never enter Bash, shell arguments, environment variables, redirections, substitutions, encoded literals, or heredocs. A transport is private, bounded, validated, and consumed once. Never delete, rename, recreate, or change the permissions of the transport file; usetransport-discardwhen Read or Write fails or when the allocated file is not empty. - The companion always invokes Grok with
--prompt-file /dev/stdinand pipes the complete prompt to the child. Never pass a private staging path to Grok. Headless installs the sandbox before it reads--prompt-file, so a brief under Claude plugin data can be unreadable even when the companion already consumed it successfully. - Task and review options must precede the first positional text. Once prompt or focus text starts, every remaining token is data, including option shaped words such as
--background,--write,--cwd, and--json. - Background has three distinct layers. The Grok rescue Agent remains foreground, and its helper call runs in a background shell of that one Bash call. Parallel orchestration starts multiple foreground Agent calls in one message. The Grok CLI runs in its own supervised process group, which is not itself a detached user job.
- A forwarder agent runs the companion in one background shell: a Bash call with
run_in_background: true, which returns at once with a background id and the path of the output file. It then runsnode "${CLAUDE_PLUGIN_ROOT}/scripts/grok-companion.mjs" await-output --file "PATH"in a foreground Bash call withtimeout: 120000and repeats that call while it prints exactlyawait-output: pending; any other output is the complete stdout of the launched operation. The harness delivers one report per agent, so a forwarder never ends its turn or writes a waiting line while the await operation prints pending. The rescue wrapper adds the fixed option--transport-background-shellto its task launch for a 900000ms default execution budget. Direct foreground tasks keep their 570000ms default, andGROK_COMPANION_TIMEOUT_MSoverrides either budget. Background mode belongs to that Bash call alone and is neither the Agent's own background mode nor the companion's--background. The dedicated review runner applies the same launch and await sequence to itsreviewcommand and to eachresult <job-id> --waitcall. A companion run directly by the main session through a slash command, with no forwarder agent, is a foregroundBashcall withtimeout: 600000. - Ordinary delegations use one helper call. Only an explicit incoming user
--backgrounddetaches a task and creates a manual receipt that crosses the Agent boundary. The dedicated review runner is the sole managed worker exception because it owns and collects the review before returning. Native Grok background tool waiting is a fourth, internal lifecycle. Ordinary calls pass--no-wait-for-background. That setting does not authorize companion detachment. - Prefer the helper over hand-rolled
git, direct Grok CLI strings, or any other Bash activity. - Consult mode is the default. Consult, write, and review pin
--sandbox strict; never downgrade to workspace. Consult overrides inherited always approve mode with--permission-mode defaultand hard filters built in tools to file read, list, and search.--webadditionally exposes Grok's web search and fetch tools. Strict's upstreamsystem_readroots include/varand/tmpon Linux, and/privateplus the entire~/Libraryon macOS, so shared temporary content and substantial user application configuration and caches may be readable. Its write roots are the workspace and$GROK_HOME/sessions(since 1.0.14 the rest of the Grok home is readable but not writable), always include/tmpand/var/tmp, and on macOS also include/private/tmp,/private/var/tmp, and all of/private/var/folders; the unique private runTMPDIRis the adapter's preferred and verified path, not the only temporary write surface. Its configuration requests child process network restriction, which Linux enforces through seccomp while macOS currently treats network blocking as a no-op; a write shell can reach the network on macOS, and--webcontrols only built in web tools. Hostedx_searchstays outside managed runs because the fixed--toolsallowlist governs the toolset (live verified on 1.0.0), and the companion adds no speculative disallow entries because Grok 1.0.0 warns when adisallowedToolsentry matches nothing and tracing fails closed on that warning. The hard tool filter and deny set provide the consult no-write model contract. Shell commands, tests, git, builds, file edits, MCP tools, and subagents are unavailable.--writekeeps strict, enables auto approval, and usesread_file,grep,list_dir,search_replace, andrun_terminal_cmd;search_replacecreates files, while upstream 1.0.0's OpenCode-compatiblewritetool id remains outside the fixed allowlist. Denies for common direct grok, claude, and codex commands do not cover absolute paths, aliases or functions, or indirect scripts. They are not hard confinement whilerun_terminal_cmdremains enabled; that requires removing the terminal tool or an OS-level executable or network policy. User toolchains outside strict's readable roots may be unavailable, which is a reroute or environment problem rather than permission to weaken the profile. - Every consult and write call explicitly denies
search_tool,use_tool,ask_user_question, and all MCP tools. Every ordinary call also passes bare--disallowed-tools AgentandGROK_SUBAGENTS=0.--no-subagentsdisables headless subagent spawning (verified on 1.0.77 and 1.0.88); the hard Agent tool deny andGROK_SUBAGENTS=0remain independent controls. Cross-session memory is force-disabled withGROK_MEMORY=0unless an ordinary task explicitly supplies--memory, in which case the child receivesGROK_MEMORY=1. Review and stop gate always keep memory off. Published headless Grok parses--experimental-memoryand--no-memorywithout forwarding them through the single-turn path, so the companion uses the environment variable as the effective control and never trusts an inherited value. When memory is enabled, upstream first-turn injection may read relevant global or workspace memory and place it in the model context sent to xAI. That internal injection is not a modelread_filecall and is not blocked by the companion's Read denies for$GROK_HOME/memory/**. Upstream automatic saving normally requires at least three real user prompts in the same resumed session and enough content, so a single Fusion task usually only reads existing memory and does not guarantee that new memory is saved.--no-subagentsis honored in headless mode on both 1.0.77 and 1.0.88; the hard Agent tool deny andGROK_SUBAGENTS=0provide independent controls. The child sets all eighteenGROK_CLAUDE_*_ENABLED,GROK_CURSOR_*_ENABLED, andGROK_CODEX_*_ENABLEDbridge variables to false; upstream currently consumes the six Claude and six Cursor cells plus the Codex sessions cell and reserves the other five Codex cells, and the child also pinsGROK_MANAGED_MCPS_ENABLED=falsebecause that variable has highest precedence over[managed_mcps]in~/.grok/config.tomland remote settings. It removes inheritedCLAUDE_CODE_*andCLAUDE_PLUGIN_*variables plus_GROK_CLAUDE_MARKER_OVERRIDE, and broadly scrubs secret-bearing variables except required xAI authentication. Strict keeps the private Grok home readable and grants writes under its sessions directory. Write shells can receive the retained xAI authentication variables. The companion adds best-effort Read denies forauth.json,mcp_credentials.json,config.toml,sessions,memory,logs, anddebugthrough absolute paths and standard**/.grokpatterns. Raw path variants, symbolic links, and shell or indirect scripts can bypass those rules, so environment scrubbing and path-pattern denies do not isolate the credentials. Narrower exposure requires a dedicated sandbox profile, an authentication broker, or upstream path-level authorization. Managed Grok runs use a separateGROK_HOMEfor each resolved user home and credential source. Each private home has an emptyhooks/directory. Itsconfig.tomlomits the user'spluginsandhookssettings and preserves the rest verbatim. Unsandboxed probes and model listing pass the resolved credential source inGROK_AUTH_PATHso Grok can refresh it directly. Before each strict launch, the companion prepares an emptymanaged_config.lockand atomically copies the source to a regular mode 0600auth.jsonin the profile’s private home. The child passes--no-auto-update; Grok enforces hard version requirements at startup (introduced in 0.2.112, verified through 1.0.41 on 2026-09-27; organization message, exit 1 before any envelope), the companion classifies that death assetup, and the soft update floors it also introduced only steer auto-update. The companion's own tested interval is[1.0.14, 1.0.89): below it managed runs fail closed assetup, at or past it/grok:setupreports the build as newer than the tested interval and a verification pass is advised; job records carrygrokVersionso a breaker advisory can name the build that failed. - A strict run whose stored OIDC token has expired cannot refresh it, because grok 1.0.14 and later can write only
$GROK_HOME/sessionsinside the Grok home. The companion watches for upstream'sauth 401 retry: no credential was sentwarning, stops the run on its first occurrence, and fails it asauth. The companion has already tried one refresh outside the sandbox and one rerun, so relay the remedy it prints: run grok once outside the sandbox (for examplegrok -p ok), orgrok loginwhen the refresh token itself has expired. Never retry the unchanged task or downgrade the sandbox. - The companion probes the installed binary before using source-derived flags. Every run requires
--prompt-file,--output-format,--sandbox,--tools,--disallowed-tools,--deny,--max-turns,--no-auto-update, and--no-wait-for-background. Consult also requires--permission-modeand--allow; no-web runs require--disable-web-search; write requires--always-approve; review requires--json-schema. A missing applicable capability fails before launch with failure kindsetup. Every managed run forces builder tracing. Upstream initializes tracing only after it consumes the complete stdin prompt, so it is not a pre-prompt or pre-side-effect attestation. Fallback, unmappable, or unmatched-policy warnings trigger early verified termination, and a successful close is rejected without positivetools allowlist appliedevidence. Before sending stdin, the companion creates a unique privateTMPDIRand requires a newProfileAppliedrecord in the incremental$GROK_HOME/sessions/sandbox-events.jsonldelta (the home-root location that 1.0.13 and earlier wrote is unsupported) that contains that path and matches the canonical workspace, strict profile, enforced state, and requestedrestrict_network: trueconfiguration. Upstream supplies no run id or pid, so unrelatedProfileAppliedandApplyFailedrecords are not attributed; failure events are auxiliary diagnostics. The matching event proves profile and configuration application, not platform-level network isolation. A matching owned-stderr warning, handshake timeout, missing or malformed matching evidence, shared-log disappearance or rotation, or matching field mismatch fails closed. - A manual background receipt relays one absolute
node "<plugin root>/scripts/grok-companion.mjs" watch --job <id>command to the main session for one Claude CodeMonitortool watch. Its single completion line is the cue to collect through/grok:result <id>. Watches poll every 15 seconds, stay silent while running, exit 0 on terminal state, and fail nonzero for unknown ids. Fusion orchestrated detached jobs retainfusion:job-collector. Request the receipt's watch duration, the engine background budget plus 60 seconds capped at 30 minutes. If a Monitor deadline notice arrives before the completion line, re-arm the same watch command with the same duration. Re-arm it on astill runningline too; each watch exits with that line after at most 29 minutes. Each poll runs the engine's status and result liveness reconciliation. A dead owner is announced asorphaned; unverified cleanup or a job still running past its deadline plus 15 seconds is announced ascleanup required, with result and cancel commands. --backgrounddetachestaskorreviewinto a companion worker; the helper prints the job id plus/grok:statusand/grok:resulthints. A task accepts it only from an explicit incoming user flag and creates manual delivery. The dedicated review runner setsGROK_COMPANION_BACKGROUND_DELIVERY=managed, owns that review job, and collects it with repeatedresult <job-id> --waitcalls before returning. The runner accepts only a 32 character lowercase hexadecimal job id and omits the raw launch--cwdbecause companion job ids resolve globally across workspaces; an original--jsonstays on both launch and result. Text collection continues only after a zero exit whose output ends instate: running; JSON collection continues only after a zero exit with top levelstatus: "running"andcleanupRequirednot true. A textphase: cleanup-requiredor JSONcleanupRequired: trueresult is returned as a nonterminal failure receipt instead of looping. Terminal result collection records successful companion output, not later Agent message delivery.result --waitblocks while a job is running, refreshes liveness on each poll, and prints the same terminal output asresultwhen the job finishes. If its bounded wait budget elapses first, it prints a compact running render ending instate: runningand exits zero so the forwarder can issue another wait call. If verified cleanup cannot complete, it exits nonzero and returns the explicit cleanup-required receipt even though the durable record remains running for a later cleanup retry.- A user asking to resume maps to the companion's
--resume <uuid>or--resume-last. Never invent a session uuid; only UUIDs recorded by finished ordinary companion tasks in the private home are resumable. Every mode records strict, so legacy workspace or unknown profiles fail closed and require a fresh task. Resume also requires the same credential profile, mode and memory boundary as the source task. A memory-enabled session must be resumed with--memory, a memory-disabled session must be resumed without it, and inconsistent recorded memory modes fail closed.--resume-lastselects the newest compatible terminal task and requires the current Claude session when one is available. Resolved metadata for a short cwd uses only its exact URL-encoded directory. A long cwd may scan bounded session-id candidates but accepts only an exact decoded or.cwdmatch; it never falls back to a sole candidate from another cwd. - Continuity policy defaults to
manual, which never resumes without--resumeor--resume-last./grok:setup --continuity claude-sessionpersists automatic affinity for an ordinary task that has a prompt, does not request explicit resume, and does not pass--fresh. Affinity selects only the newestdoneordinary task from the same Claude session, exact resolved cwd, mode, credential profile, strict sandbox profile, and memory boundary. Fusion routed briefs identified by their routing header do not receive automatic affinity and stay fresh unless explicitly resumed.--freshstarts a new session for one task and cannot be combined with either resume option.GROK_COMPANION_CONTINUITY_POLICYmay override the persisted policy withmanualorclaude-session. historyexposes a safe canonical projection of companion job metadata and resumable session identifiers. It defaults to the current workspace and 50 newest records,--allincludes every recorded workspace,--limitaccepts 1 to 500, and--cwdselects an exact workspace when--allis absent. It does not read native Grok conversation contents, briefs, stored results, or logs.- Fusion-routed dispatches carry
--modeland--effortfrom Fusion's lane defaults; a direct user call may leave them unset to use the Grok CLI default. --cwdscopes the workspace for task, review, status, history, result, cancel, and stats. Status, result, and cancel search all recorded workspaces by strict job id when--cwdis omitted, while history remains workspace-scoped unless--allis explicit. A bad working directory, or an implicit task or review working directory below its Git repository root, fails before a job record is created. Worktree isolation means creating a real Git worktree before launch and supplying that canonical path as the actual cwd. Do not pass headless--worktreeor--worktree-refin a managed brief: since 1.0.19 they create a real worktree, but the companion keys its handshake, state directory, and collection to the launched cwd, so an engine-created worktree is invisible to Fusion.--jsonreturns structured output for task, review, status, history, result, cancel, stats, and setup. Preflight failures with--jsonreturn a structured error object on stderr. Headless stdout is captured through a 0600 file that is unlinked immediately after a successful open, parsed in full through the still open descriptor under a total size limit, and reduced to a bounded tail for diagnostics.- Review requires and passes one
--json-schemacontract and consumesstructuredOutputfrom the same Grok call. A reported structured output error or explicit null result fails the review. Compatibility parsing oftextis limited to a response that completely omits the structured output field and never triggers a second call. - The stop gate is primarily toggled by the plugin's
Stop gate reviewsetting in Claude Code's plugin configuration;setup --enable-stop-gateandsetup --disable-stop-gatepersist the same toggle locally as a scripting fallback and only take effect when that setting is left unset. The Stop hook reads the first nonempty reply line:ALLOWpermits stopping andBLOCK: <reason>blocks it; a preamble beforeBLOCKand infrastructure failures fail open. Stop gate runs are always fresh and memory-disabled. After collection, the hook adds a non-blocking advisory when collected workers remain acceptance unverified. SessionEnd attempts verified process cleanup for jobs owned by that Claude session and removes verified unused raw transports; it does not delete the terminal companion ledger. cancelaccepts active foreground or background job ids. It waits for process cleanup before rendering the cancelled record.- Job outcomes carry a
state:line (done,error, orcancelled). JSON records keepstatusandtransportStatusequal, keep semantic acceptance atsemanticStatus: "unverified", distinguish delivery mode from delivery status, and record the observed resolved model and effort when Grok exposes them. They also preserve reported request id, session id, turn count, structured output, aggregate and per-model usage, total cost, cost ticks, partial cost, and incomplete billing indicators without inventing missing values. Upstreammodel_usagerows contain onlyinput,output,cacheRead, andmodelCalls, plus optionalcostUSD; never synthesize aggregate reasoning or total token channels from them. The upstream map is namedmodelUsagein the headless envelope, and its keys are the only source for model names when usage attaches. Error and cancelled outcomes carry afailure: <kind>line; cancelled jobs usefailure: cancelled. - Stats aggregate reported turn counts separately from coverage.
usage_is_incompletemeans the upstream usage ledger may have missed open subagents, usage application, or a drain timeout. Reported token fields then remain observed lower bounds, but job-total token and cost coverage both fail closed to incomplete and those values stay out of exact totals. Exact cost otherwise requires a finite positive top-level USD and tick pair with neither partial marker set; ticks are authoritative at 10000000000 per USD. - Managed Grok sessions persist across runs under
<plugin data>/homes/<profileKey>/sessionswith upstream’s default 30 day retention. Removing the plugin data directory also removes managed sessions, memory, and the job ledger. - Upstream ships ACP today, but the companion has not adopted it and continues per-call invocation. Any future companion implementation pools processes by canonical cwd plus sandbox profile and launches each directly as
grok --cwd <canonical> --sandbox <profile> agent --no-leader stdio, because the sandbox is installed once at process start and a reused leader can retain the wrong cwd or sandbox. - Return the helper output exactly as-is, whether the Bash tool reports it from stdout or stderr.
- If the Bash call fails or Grok cannot be invoked, surface the failure instead of hiding it; the grok-rescue agent returns exactly one
grok unavailable: <reason>line for the orchestrator's circuit breaker.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago Changed 061f6e484ae8
- 10d ago Changed · +1 lines 59a5399c2fc8
- 12d ago Changed 67bf192e5f81
- 18d ago Changed · +1 lines 5e406a6cdc2b
- 22d ago Changed 399218b8401c
- 1mo ago Changed bb19c429209d
- 2mo ago Changed 6a3350962b14
- 2mo ago Changed · +1 lines a660daa7d8d0
- 2mo ago Changed 534041d164ec
- 3mo ago First seen · 55 lines · 19 tokens per session scan A 7a39314e2564
grok-cli-runtime is a skill published in the GitHub repository okisdev/claude-code-fusion (3 stars, last pushed 3d ago), licensed MIT. It adds 19 tokens to every session and 5,154 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
grok-cli-runtime compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| grok-cli-runtimeokisdev/claude-code-fusion | Skill | 3 | 3d ago | MIT | A | 19 | Claude Code |
| review-teams977043/river-review | Skill | 8 | today | MIT | A | 147 | Claude Code |
| conductor-orchestratorIbrahim-3d/orchestrator-supaconductor | Skill | 384 | 2mo ago | AGPL-3.0 | A | 101 | Claude Code |
| message-busIbrahim-3d/orchestrator-supaconductor | Skill | 384 | 2mo ago | AGPL-3.0 | A | 44 | Claude Code |
| writing-skillsIbrahim-3d/orchestrator-supaconductor | Skill | 384 | 2mo ago | AGPL-3.0 | A | 20 | Claude Code |
| parallel-dispatchIbrahim-3d/orchestrator-supaconductor | Skill | 384 | 2mo ago | AGPL-3.0 | A | 40 | Claude Code |
| agent-factoryIbrahim-3d/orchestrator-supaconductor | Skill | 384 | 2mo ago | AGPL-3.0 | A | 36 | Claude Code |