Skip to content

About

Multi-model orchestration for Claude Code: Claude worker tiers plus the Codex and Grok CLIs as peer engineers

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

claude-code-fusion

Multi-model orchestration for Claude Code. Your Claude session stays the planner and final judge, and it delegates work to Codex, Grok, Cursor, Devin, Antigravity, and OpenCode Go through their companion plugins, so that work bills to their subscriptions instead of your Claude plan. Every delegated result comes back to the main session, which verifies it before relying on it.

Install only the engines you use: Fusion routes around a missing one, and the session start check names any installed engine whose CLI is not on PATH. The Codex plugin calls the official CLI directly and does not depend on codex-plugin-cc. The plugin audits the session model but never sets it.

Layer Who Job
Orchestrator the user's chosen main session model; best[1m] is recommended but never set by the plugin sole control plane: resolve ambiguity, decompose, integrate, verify, record semantic acceptance, make the final judgment, and communicate with the user; it does not execute work packages; it authors judgment dense cores (naming, API shape, UX copy, policy text) itself under the authorship rule and dispatches their mechanical spread
Claude workers fusion:deep-reasoner (Fable), fusion:claude-worker (Sonnet), fusion:trivial-worker (Haiku) native specialists rather than external diversity: read only high stakes advice, resolved work whose load bearing capability is the Claude Code tool surface or privacy boundary, structurally stranded packages carrying claude-fallback: <reason>, and exact tiny fallback packages when no eligible peer lane fits
Peer engines Companion plugins implementing the shared contract. Current instances are the hosted Codex, Grok, Cursor, Devin, Antigravity, and OpenCode plugins in this marketplace Codex is the primary implementation lane and default deep external reviewer. Grok is a complementary specialist and burst lane with four protected roles: burst, independence, live-web, and large-context. It remains implementation capable inside those roles, but idle capacity alone does not make it the ordinary default. Antigravity (agy) is the Google family lane on the user's Google AI subscription, with read only independence and large-context consults and edit only burst implementation in orchestrator owned worktrees. Its verification runs in the main session. Cursor or Devin holds the multi family breadth seat, selected with `/fusion:config set-breadth <cursor
Panel mechanism /fusion:panel sends one blind brief to available peer engines in parallel and gives their attributed evidence to the main Claude session for final adjudication; it is not an independent role or authority

Codex first admission follows this order: use Codex in the current workspace, then the breadth engine's prepaid burst pool for a worktree eligible package whose brief fits under 3 KB, then an isolated Codex worktree for an independent eligible package (while Codex is over pace on its weekly window, quick and volume packages go to the breadth engine's prepaid burst pool first, and once Codex is near exhaustion at 90% used, flagship packages that do not need Codex split to fit that pool or Antigravity burst), then Grok, Antigravity, or the breadth engine under burst for an independent package inside its safety and turn boundaries, then route generic overflow to the Codex volume tiers and reserve fusion:claude-worker for packages carrying claude-fallback: <reason>, where the reason is one of network, toolchain, long-build, claude-surface, privacy, or no-healthy-lane; the dispatch hook denies any other reason and accepts no-healthy-lane only while every implementation peer lane is unhealthy for writes. Overlapping files, shared generated state, and ordering dependencies are consolidated or sequenced instead of parallelized by changing engines.

Routing is capability first: a package routes by its load bearing capability, not its surface task type. Capability monopolies hard route: X and live platform reads go to Grok live-web even for digest shaped work, Google family work goes to Antigravity, Claude tool surface and privacy needs go to Claude workers, and judgment dense authorship stays in the main session. Lane defaults are cached capability observations; a fresh observation that disagrees wins for the package at hand.

Direct /codex:*, /grok:*, /cursor:*, /devin:*, /agy:*, and /opencode:* commands are user selected engine escape hatches. They return the selected engine's transport result directly and do not first pass through Fusion's automatic routing or main session adjudication.

For each manual background receipt from Codex, Grok, Cursor, Devin, Antigravity, or OpenCode, the main session starts exactly one Claude Code Monitor tool watch with the absolute command node "<plugin root>/scripts/<engine>-companion.mjs" watch --job <id>. Only the plugin path and validated 32 character lowercase hexadecimal job id enter that command; raw request text never does. The watch uses the existing job reader and liveness check every 15 seconds, prints nothing while running, prints one terminal line with the engine, job id, state, failure kind when present, and result command, then exits 0 even for an error or cancellation. An unknown id exits nonzero with a clear message. The completion line is the cue to collect through the existing result command before relying on the outcome. Text and JSON manual receipts carry the watch instruction. Fusion orchestrated detached jobs retain fusion:job-collector; settlement records peer token observations and retries engine acceptance delivery, and SubagentStop and Stop retry indexed pending or failed acceptance delivery for their own session, with at most 500ms per attempt, 2000ms per hook, and exponential backoff within the existing five failure limit. FUSION_ACCEPTANCE_RETRY_TIMEOUT_MS can shorten the attempt timeout, and FUSION_ACCEPTANCE_RETRY_BACKOFF_MS sets the initial 1000ms backoff, doubled by attempt count up to one hour. Tool pre and post hooks never run this retry. 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 a still running line 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 as orphaned; unverified cleanup or a job still running past its deadline plus 15 seconds is announced as cleanup required, with result and cancel commands. <ENGINE>_COMPANION_WATCH_POLL_MS overrides the 15000ms poll interval, and <ENGINE>_COMPANION_WATCH_MAX_MS can shorten the 1740000ms watch lifetime.

Quick start

Prerequisites: Claude Code 2.1.300 or later (the plugin manifests enforce this floor) and Node.js 22 or later (the Node floor is not enforced; CI runs Claude Code 2.1.327 with Node 22 and 24), git, macOS or Linux, and the peer CLIs you want installed and authenticated on PATH (contract verified against codex-cli 0.172.0, grok 1.0.89, Cursor Agent CLI 2026.11.17-f532c45, Devin CLI 3000.14.30821, and Antigravity CLI 1.5.12; the Codex companion enforces a tested minimum version at preflight and fails with the setup kind below it, while the Grok companion refuses builds below 1.0.14 at preflight and /grok:setup reports builds outside its tested interval [1.0.14, 1.0.90)). Verify them with codex --version, grok --version, cursor-agent --version, devin --version, and agy --version. OpenCode uses the same Codex CLI and requires OPENCODE_GO_API_KEY for its OpenCode Go subscription. Claude Code may launch worker and wrapper Agents asynchronously; the main session collects or explicitly cancels every one it launched. If codex@openai-codex is installed, migrate first (see below).

claude plugin marketplace add okisdev/claude-code-fusion
claude plugin install fusion@claude-code-fusion
# then the companions for the CLIs you have
claude plugin install codex@claude-code-fusion
claude plugin install grok@claude-code-fusion
claude plugin install cursor@claude-code-fusion
claude plugin install devin@claude-code-fusion
claude plugin install agy@claude-code-fusion
claude plugin install opencode@claude-code-fusion

Then open a new session. The fusion SessionStart hook installs the static routing template into ~/.claude/rules/orchestration.md with identical bytes on every machine and keeps it current across plugin upgrades, as long as the live copy still matches a version the plugin has shipped; a hand edited copy is left alone and flagged by the hook and /fusion:doctor. Each machine's capability table, breadth seat, and lane defaults come from its model-routing.json as session context at session start and after compaction. /fusion:config shows and edits that data, with changes taking effect in new sessions or after /compact. Run the setup command of each companion you installed (/codex:setup, /grok:setup, /cursor:setup, /devin:setup, /agy:setup, /opencode:setup) once to verify its CLI and authentication. /fusion:setup is optional: it reinstalls the rules after a hand edit and offers a permission allow. /fusion:config set-breadth <cursor|devin> chooses the breadth engine (Cursor by default). From there plain language is enough: ask for "a second opinion from Grok" or "hand this to Codex" and the routing rules make the orchestrator delegate on its own.

Migrating from codex@openai-codex

If codex@openai-codex is installed, migrate before installing this marketplace's Codex plugin. In a session where the old plugin is still enabled, run /codex:status --all, use the old /codex:result <job-id> --wait or /codex:cancel <job-id> for every authoritative running job, confirm that no result you need remains uncollected, then exit that session. Disable and uninstall the old plugin while preserving its data:

claude plugin disable codex@openai-codex
claude plugin uninstall codex@openai-codex --keep-data

Never enable codex@openai-codex and codex@claude-code-fusion together because both register the same codex namespace. Open a new session after the replacement is installed.

Commands

Command What it does
/codex:task <text>, /codex:rescue <text> Delegate to Codex. Runs stay foreground regardless of complexity, expected duration, or model unless the incoming request explicitly passes --background; --write allows edits, --resume <thread-id> or --resume-last continues a thread, --fresh forces a new one, --web enables live search, --write --network enables workspace network access, and --model or --effort forwards an explicit override. A direct background invocation returns a receipt without automatically collecting it
`/codex:review [--scope <auto working-tree
/codex:status [job-id], /codex:result <job-id> --wait, /codex:cancel <job-id> Lifecycle for explicitly detached Codex jobs. Status inspects progress, result collects the deliverable, and a per-job Monitor watch notifies completion. Fusion gives jobs detached by its own orchestration one same turn collection attempt of at most 540000ms; a timeout remains explicitly uncollected
/codex:history [--json] List canonical local Codex companion jobs across workspaces, including resumable thread ids, delivery state, semantic status, and observed model and effort. Codex exec threads remain persisted locally, but Codex Desktop does not guarantee that exec sourced threads appear in its sidebar
/codex:setup Codex CLI, authentication, adapter path, and compatibility health check
/grok:task <text> Delegate directly to the user selected Grok lane. Consult and --write both use the strict sandbox; --write allows edits through its fixed tool policy, --web enables web search and fetch, and explicit --background returns a manual receipt for /grok:status and /grok:result. Without that flag, the Agent and companion stay foreground regardless of expected duration; a typed timeout is split or rerouted instead of being silently detached. Cross-session memory is off by default and can be enabled for an ordinary task with --memory; --resume <uuid> or --resume-last continues only a compatible companion-recorded strict task with the same mode and memory boundary; --fresh bypasses continuity and starts a new session. --model, --effort, and --max-turns forward explicit overrides.
/grok:review [--base <ref>] [--focus <text>] [--cwd <dir>] [--json] Read only adversarial review of the working tree or a branch range (untracked files reach the review as names only); the review run never edits, and acting on confirmed findings is a separate orchestrator decision after it returns
/grok:status [job-id], /grok:result <job-id> [--wait], /grok:cancel <job-id> Background job lifecycle. Each accepts --cwd <dir> and --json; a successful JSON background launch preserves its task or review envelope through result collection, while cancellation, process death, and other failures return a stable typed failure envelope
/grok:history [--all] [--limit <n>] [--cwd <dir>] [--json] List canonical local Grok companion jobs and resumable session identifiers. The default scope is the current workspace and 50 newest records; --all spans recorded workspaces and --limit accepts 1 to 500. The command exposes safe metadata, not native Grok conversation contents, briefs, results, or logs
/grok:stats [--all] Grok delegation history by status, mode, model, failure kind, and exact reported token totals with complete, incomplete, and unreported coverage
/fusion:stats [--all] [--identities] [--by-day] Delegation history across Claude workers and peer engines, including stable task identity, Agent identity, delivery state, transport status, semantic acceptance, actual model and effort when observable, and exact reported token coverage. --audit [--days <n>] summarizes the retained inline guard ledger. The report also counts accepted implementation packages with a credited verification before the verdict. The default report stays compact; --identities adds the task identity map and --by-day the per-day fleet lines
/grok:setup Health check; --continuity manual keeps explicit resume as the default, while --continuity claude-session enables automatic affinity for compatible ordinary direct tasks in the same Claude session and exact resolved working directory. Fusion routed briefs do not receive automatic affinity and stay fresh unless explicitly resumed. --enable-stop-gate / --disable-stop-gate toggles the stop-time review gate, and --clear-quota-cooldown clears the one hour fast-fail window that a Grok quota failure opens (GROK_QUOTA_COOLDOWN_MS, 0 disables it)
/cursor:task <text>, /cursor:rescue <text> Delegate to Cursor. Consult is the default and runs read only in Cursor's ask mode; --write allows edits inside the working directory through Cursor's sandbox; --model and --effort select a catalog variant, --resume <session-id> or --resume-last continues a chat, --fresh starts a new one, and explicit --background returns a manual receipt. Auto is refused because no event reports the model it chooses
`/cursor:review [--scope <auto working-tree
/cursor:status [job-id], /cursor:result <job-id> [--wait], /cursor:cancel <job-id>, /cursor:history Cursor job lifecycle and resumable session history
/cursor:setup Cursor CLI path, build against the tested interval, authentication, model catalog, sandbox helper, and project hook advisory
/devin:task <text>, /devin:rescue <text> Delegate to Devin. Consult is read only by default; --write permits bounded edits in the workspace sandbox. --model accepts a family such as kimi-k3, glm-5.2, muse-wonder, or swe-2; --effort selects a supported thought level. --resume <session-id> or --resume-last continues a compatible session, --fresh starts another, and explicit --background returns a manual receipt. Devin Adaptive is refused because it does not pin the serving model. A fusion-<planner>-sidekick-swe-2-<tier> pairing is accepted only with --write and a non Claude planner
`/devin:review [--scope <auto working-tree
/devin:status [job-id], /devin:result <job-id> [--wait], /devin:cancel <job-id>, /devin:history Devin job lifecycle and resumable session history
/devin:setup Devin CLI version, authentication, account plan, model catalog, and project configuration advisory
/agy:task <text>, /agy:rescue <text> Delegate to Antigravity on the Google AI subscription. Consults are read only; --write allows file edits in an owned worktree while commands remain read only, so verification runs in the main session. --model and --effort pin the Google model and thought level; explicit --background returns a manual receipt
/agy:review, /agy:status [job-id], /agy:result <job-id> --wait, /agy:cancel <job-id>, /agy:history, /agy:setup Read only review, job lifecycle, resumable history, and CLI, model, authentication, and overage checks
/opencode:task <text>, /opencode:rescue <text> Bulk generation on OpenCode Go through the Codex CLI sandbox, or a read only blind check; requires an opencode auth login for OpenCode Go or OPENCODE_GO_API_KEY, and an `opencode-role: bulk
/opencode:status [job-id], /opencode:result <job-id> --wait, /opencode:cancel <job-id>, /opencode:history, /opencode:setup Job lifecycle, history, and Codex CLI, key, catalog, and model health checks
/fusion:panel <question> Blind multi-model panel with attributed adjudication, for decisions where a wrong answer is expensive. Also fires from plain language ("help me decide", "compare these")
/fusion:ultra <task> Fans a large task out as a fleet while preserving lane ownership: Codex keeps the primary deep implementation seat, Grok supplies its protected specialist roles, and the selected breadth engine supplies cross family consults and burst implementation. It synthesizes and verifies the combined result, fires from "go deep", "audit everything", or "be exhaustive", and returns small tasks to ordinary routing.
/fusion:setup Install or update the routing rules into ~/.claude/rules/; offers the optional permission allow
/fusion:smoke Run the post-update live smoke wave across version parity and the Codex, Grok, OpenCode, selected breadth engine, and Claude worker dispatch lanes before real delegated work
/fusion:config, `/fusion:config set-breadth <cursor devin>`
/fusion:doctor Audit model pins, environment overrides, peer model defaults (Codex, Grok, Cursor, Devin, Antigravity, and OpenCode), rules drift, and stale agent copies

Companion text outcomes use the shared footer grammar for state, failure, job, delivery, semantic, and <engine>-session lines defined in docs/companion-contract.md, with delivery and semantic lines present when that adapter exposes those dimensions in text. The Codex runtime contract is docs/codex-contract.md, the Grok runtime contract is docs/grok-contract.md, the Cursor runtime contract is docs/cursor-contract.md, the Devin runtime contract is docs/devin-contract.md, the Antigravity runtime contract is docs/agy-contract.md, and the OpenCode runtime contract is docs/opencode-contract.md. Each plugin names its own session line, for example Codex emits codex-session: <thread-id>, Grok emits grok-session: <uuid>, Cursor emits cursor-session: <chat-id>, and Devin emits devin-session: <session-id>.

Every peer state: done and Claude worker transportStatus: done is a transport result, not proof that the work is acceptable; the main session verifies the result before relying on it. Terminal work without a verified verdict remains unverified. A collector timeout, dead job, or status error reports the Fusion task id, peer job id, literal state uncollected, and the exact result command for Codex, Grok, Cursor, Devin, Antigravity, or OpenCode. /fusion:stats --record <id>=<verdict> settles collected results; a rejected verdict requires --reason through the raw args transport, and a judgment shaped rejection may add --failure-kind with one of intent_override, scope_rewrite, wrong_approach, or style_mismatch.

Safety model

Two layers with different strength, stated plainly.

Enforced by companion runtimes (code, covered by the test suite): the Codex companion invokes codex exec --json, uses the read-only or workspace-write sandbox with approval_policy="never", disables both Codex multi-agent feature generations plus the sleep tool and memories features, fails closed if a collaboration tool call or a persistent mode run is still observed, forces web search and workspace-write network access off by default, supervises the owned process group, and permits detachment only through an explicit --background already present in the incoming request. A tool that deliberately creates a new session or daemonizes leaves that portable containment boundary. --web opts into live search, while network access requires the separate --write --network combination. Ordinary stats observation stays read only; companion watches use the same locked liveness repair as status and result, and the explicit stats prune command remains user-authorized cleanup. The Codex adapter does not impose a companion-owned shell command allow list and does not rewrite configured MCP servers or other Codex tools; those remain part of the user's Codex configuration trust boundary. Its exact runtime and durability rules are in docs/codex-contract.md.

Grok consult, write, and review all pin --sandbox strict. Consult overrides inherited approval bypass with --permission-mode default and hard filters built in tools to file read, list, and search, optionally adding web search and fetch. Every mode denies native questions, delegated search and tool execution, and MCP. --no-subagents disables headless subagent spawning (verified on 1.0.77 and 1.0.88); the hard Agent tool deny and GROK_SUBAGENTS=0 remain independent controls. Write auto approves a fixed list containing read, grep, list, search_replace, and terminal tools; upstream 1.0.0's OpenCode-compatible write tool id remains outside that fixed allowlist, and search_replace creates files. Strict does not confine reads to the workspace or Grok home; its broader system_read roots are described below, and user toolchains outside those readable roots may still be unavailable. Its configuration requests child process network restriction. Linux enforces that request through seccomp, while macOS network blocking is currently a no-op and a write shell can still reach the network; --web controls only Grok's built in web tools. The hosted x_search tool never reaches managed runs because the fixed --tools allowlist governs the toolset, as verified by a live 1.0.0 probe whose no-web consult reported exactly read_file, list_dir, and grep. The companion adds no speculative disallow entries because Grok 1.0.0 warns when a disallowedTools entry matches nothing and the companion's tracing fails closed on that warning. The companion never silently downgrades to workspace.

Before prompt delivery, the companion requires a new ProfileApplied event in the incremental delta of the shared ~/.grok/sessions/sandbox-events.jsonl log (the home-root location that 1.0.13 and earlier wrote is unsupported) that contains this run's private temporary path and matches the canonical workspace, strict profile, enforced state, and requested restrict_network: true configuration. Upstream appends there with no rotation or size cap. Upstream records have no run id or pid, so the unique private path correlates positive evidence; unrelated ProfileApplied and ApplyFailed records are not attributed, and failure records are only auxiliary diagnostics. The matching event proves profile and configuration application, not actual platform network isolation. A matching warning on the owned stderr stream, handshake timeout, missing or malformed matching evidence, shared-log disappearance or rotation, or any matching field mismatch terminates the process and fails closed; stderr cannot prove successful enforcement. Forced builder tracing starts only after Grok consumes stdin, so it is not a pre-prompt or pre-side-effect attestation. Fallback or unmatched warnings trigger early termination, and a nominally successful close is rejected without positive allowlist applied evidence.

The child sets all eighteen GROK_CLAUDE_*_ENABLED, GROK_CURSOR_*_ENABLED, and GROK_CODEX_*_ENABLED bridge 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 pins GROK_MANAGED_MCPS_ENABLED=false because that variable has highest precedence over [managed_mcps] in ~/.grok/config.toml and remote settings. The bridge variables do not cover native Grok configuration. Grok loads hooks from plugins enabled in ~/.grok/config.toml and from ~/.grok/hooks/*.json inside managed runs, verified at 1.0.77. The GROK_CONFIG overlay does not disable them (the plugin stays loaded in GROK_HOOKS_LOG), and allow_managed_hooks_only is read only from policy layers that also bind interactive use, so /grok:setup names them and the repair is the user's [plugins] list. The child disables subagents and the per turn summary model call, removes inherited Claude session and plugin variables plus _GROK_CLAUDE_MARKER_OVERRIDE, scrubs unrelated secret-bearing variables while preserving required xAI authentication, and disables automatic updates with --no-auto-update. Cross-session memory is force-disabled for every run except an ordinary task with explicit --memory; review and stop gate always keep it off. When enabled, upstream may inject relevant Grok memory into the model context sent to xAI. Upstream automatic saving usually requires at least three real user prompts in the same resumed session, so one Fusion task usually only reads existing memory and does not guarantee that new memory is saved. The write tool and deny rules reduce exposure but are not complete confinement. Command-pattern denies for common direct grok, claude, and codex calls can be bypassed with absolute paths, aliases or functions, and indirect scripts; a hard boundary requires removing run_terminal_cmd or applying an OS-level executable or network policy. Run write delegations on a clean branch or an orchestrator-created disposable worktree and launch Grok with that worktree as its actual cwd. Prompts reach headless Grok through /dev/stdin, and stdout is parsed from a 0600 file that is unlinked immediately after open. The capability preflight checks the universal safety flags and the exact consult, write, review, no-web, and ordinary-wait surfaces before each applicable run; /grok:setup reports the complete surface. Grok splits soft update floors from hard startup requirements (introduced in 0.2.112, verified through 1.0.41); the hard layer exits 1 before the headless turn regardless of --no-auto-update and the companion classifies that death as setup. The companion's own tested interval is [1.0.14, 1.0.90): below it managed runs fail closed as setup, at or past it /grok:setup reports the build as newer than the tested interval and a verification pass is advised; job records carry grokVersion so a breaker advisory can name the build that failed. --web deliberately uses Grok's built in network tools and may transmit inspected content to xAI. Continuity defaults to manual; optional claude-session affinity applies only to compatible ordinary direct tasks. Fusion routed briefs do not receive automatic affinity and stay fresh unless explicitly resumed. The optional stop gate runs from the Stop hook, not SessionEnd, and parses its first nonempty reply line: ALLOW allows the stop, while BLOCK: <reason> blocks it. A BLOCK after a preamble and every infrastructure failure fail open. SessionEnd attempts verified process cleanup and removes unused raw transports, but it does not delete the terminal companion ledger. Grok permission matcher notes are in docs/grok-contract.md, and the shared outcome rules are in docs/companion-contract.md.

Upstream strict has broader read and write surfaces than the workspace and adapter-private run directory. Linux system_read includes /var and /tmp; macOS includes /private and the entire ~/Library, so shared temporary content and substantial user application configuration and caches may be readable. Its write roots are the workspace and ~/.grok/sessions (since 1.0.14 the rest of the Grok home is readable but not writable), always include /tmp and /var/tmp, and on macOS also include /private/tmp, /private/var/tmp, and all of /private/var/folders. The run's unique private TMPDIR is the adapter's preferred and handshake-verified temporary path, not the only writable temporary surface. The sandbox permits consult read_file to reach ~/.grok/auth.json, config, and sessions because strict keeps the Grok home readable, and write terminal commands can receive preserved xAI authentication variables. The companion adds best-effort Read denies for auth.json, mcp_credentials.json, config.toml, sessions, memory, logs, and debug under the Grok home through absolute paths and standard **/.grok patterns, but raw path variants, symbolic links, and shell or indirect scripts can bypass those tool-level rules. Those Read denies govern model tool calls only. They do not block upstream's internal first-turn memory search and injection when the user explicitly supplies --memory. Environment scrubbing and path-pattern denies do not isolate credentials or memory content. Model-facing MCP and meta-tool denies do not prove that native MCP servers, plugins, or hooks configured under ~/.grok did not start during agent construction or had no side effects; those bridge variables do not disable native Grok configuration. Narrower exposure requires a dedicated sandbox profile, an isolated Grok home, an authentication broker, or upstream path-level authorization.

Grok 1.0.77 refuses runtime-socket symlinks under strict; 1.0.88 accepts them when their resolved targets are covered by its deny list, which now includes ~/.orbstack/run/docker.sock. The companion applies that version dependent preflight so consult and review can run on hosts with covered symlinks; prereleases such as 1.0.88-rc.1 remain below the exemption. A macOS strict write shell can still reach runtime sockets on 1.0.88 even when ProfileApplied.deny_paths lists them, so the companion refuses writes while any of ~/.docker/desktop/docker.sock, ~/.docker/run/docker.sock, or ~/.orbstack/run/docker.sock exists. Stop the container engine or route writes to another lane; removing the /var/run symlink does not resolve write reachability, and strict is never downgraded.

Fusion's worker lifecycle hook enforces the compact fusion-brief: v1 envelope, rejects unauthorized explicit background dispatch, owns stable task and Agent identities, observes bounded usage and progress, and blocks Stop until worker collection and settlement are recorded, releasing after three repeated blocks so a session cannot be held open. While a wrapper runs its companion in a background shell and waits through await-output --file <path>, the Stop hook shows a user visible systemMessage for the in flight task; a recorded verdict ends that task's collection gate, and a report delivered through SubagentHandback is collected at SubagentStop. At dispatch it runs Explore on Sonnet when the call names no model, and denies a launch that would fail before doing any work: an engine whose host check reports a blocker for the requested mode (for example Grok's strict sandbox against a symlinked Docker socket), a second Codex wrapper in a workspace whose single Codex slot is already held, an engine whose latest job in the session ended on an infrastructure failure within 30 minutes, and a Claude worker type whose last run hit a usage limit until its stated reset. Each denial is bypassed when the latest user message names that engine or agent. A Codex write brief over 5 KB gets an advisory to split it, because measured timeout rates climb with brief size. The hook cannot prevent Claude Code itself from choosing an asynchronous internal launch when run_in_background is omitted, so it treats that launch as owned unfinished work rather than as a completed delivery. Semantic acceptance still requires main session verification.

The optional Jev brief check adds a classifier's opinion at dispatch time. It is off unless TYPESAFE_API_KEY is set in the session environment, for example in the env block of ~/.claude/settings.json. When it is on, a PreToolUse hook sends each codex:codex-rescue, grok:grok-rescue, cursor:cursor-rescue, and devin:devin-rescue brief of at least 200 characters to TypeSafe AI's Jev model (pinned to jev-1.13.0) with four fixed yes or no questions: whether the brief mixes diagnosis with a fix, carries style intent only as prose, names no checkable completion condition, or asks for a sweep without named paths. An answer at or above 0.7 adds one advisory to the orchestrator's context with the probability and the remedy. The check never emits a permission decision, so it cannot deny a dispatch, and a missing key, a timeout after 1.2 seconds, or any API error produces no output at all. Jev returns typed probabilities and no text, so it holds no routing lane and runs no work packages. The data boundary is described in SECURITY.md.

Requested by prompts (the orchestrator follows the installed instructions; not runtime enforced): the routing policy, the panel's blindness, read only review runs never applying fixes, separate orchestrator decisions about confirmed findings after review returns, and quality driven lane selection. The SessionStart breaker check reads only job files modified inside its lookback window, adds a wrapper delivery advisory, and runs <companion> host-check --json for engines that declare it, including Grok. Immediate infrastructure failures stop routing to the affected lane, while timeout, stall, and process failures require repetition before opening the breaker. Ordinary read only permission mismatch does not globally break an engine. Each engine can define its own unavailable prefix; the one present today is grok unavailable:. /fusion:panel substitutes fusion:deep-reasoner for a missing track rather than aborting.

The Cursor companion runs every job with HOME set to a private home that it builds per job, because Cursor reads Claude Code hooks and plugins, CLAUDE.md, Codex and Grok skills, and its own user rules, skills, plugins, MCP servers, and sandbox policy from fixed home directory locations that no flag disables. The private home links only the macOS keychain (where the CLI keeps its credentials), carries a generated cli-config.json and sandbox.json per mode, and holds read only empty plugins and skills-cursor directories so Cursor's marketplace plugins and built in skills never load. Consult and review run in Cursor's ask mode with a read only sandbox and read, search, and lint tools only; write mode adds edit, delete, and shell tools inside a workspace read write sandbox with reads confined to the workspace, the language runtime installation root, and a linked worktree's Git directories, and with network denied. The companion passes --allowed-tools, --disable-project-configs, --disable-auto-update, and --single-turn, never --force or --approve-mcps, and terminates a run whose stream shows a tool outside the mode's allowlist. Residual boundaries: project instructions (AGENTS.md, CLAUDE.md, .cursor/rules) and project hooks in .cursor/hooks.json and .claude/settings*.json still load, and project hooks run outside the sandbox, which the companion reports as a warning: line; account level Cursor user rules reach every session; prompts and tool results pass through Cursor's backend to the serving vendor. The exact recipe and the probes behind it are in docs/cursor-contract.md.

The Devin companion runs every job with a shared private home whose only credential source is a link to the CLI credentials file. Its per job config disables imports from other tools and the cloud, except project AGENTS.md instructions, and leaves MCP servers empty. The ACP client refuses every permission request and terminates a run that announces a tool outside its mode's allowlist. Consult and review use read and search tools; write mode uses the CLI sandbox to confine writes to the workspace and refuses network permission requests. Project .devin configuration can still add permissions, hooks, or MCP servers, and the companion warns when it finds it. Prompts, workspace content, and results pass through Devin's backend to the model vendor. The exact recipe is in docs/devin-contract.md.

The Antigravity companion speaks ACP to agy using a private Gemini directory while retaining the real HOME for keychain authentication. Consults and reviews are read only; burst permits workspace file edits, while command permissions remain limited to read only checks and verification runs in the main session. Forbidden tools and sandbox bypasses fail as policy; the CLI sandbox does not confine writes. Project .gemini, .agents, AGENTS.md, and GEMINI.md may still load. Prompts, workspace content, and results pass through Google's backend on the Google AI subscription. Set overage to never to avoid buying AI credits past the plan limit; see docs/agy-contract.md.

Model roles

Roles bind to alias tiers, not to specific models, so a same tier release (Sonnet 5 under sonnet, a new Opus generation) needs zero configuration, and best[1m] floats the orchestrator to future Fable releases. opus resolves to Opus 5.5 since Claude Code 2.1.280, and Opus 5.5 holds the orchestrator seat at parity with Fable 5.1 on published evidence; Opus 5 and older remain a temporary fallback to reverse with /model, not a lateral move. The one deliberate exception is fusion:trivial-worker, pinned to the full ID claude-haiku-5-5 for machines where ANTHROPIC_DEFAULT_HAIKU_MODEL remaps the haiku alias; bump it by hand when a newer cheap tier ships. It is a fallback for trivial work when no eligible peer lane remains, or when Claude-only tools or privacy are required, not the default for single file tasks. Fusion-routed peer dispatches carry the routing table's lane defaults (/fusion:config set-default), so a CLI's interactive default model or effort never leaks into delegated runs; direct peer commands still use each CLI's own config (~/.grok/config.toml, ~/.codex/config.toml). Alias semantics are Claude Code behavior as observed on 2.1.x, and nothing here sets your main model for you: pick it yourself, for example /model best. /fusion:doctor audits all of this.

Benchmark

The plugin makes no effectiveness claim until the benchmark below publishes results. The claims and the full protocol live in bench/METHODOLOGY.md: C1 quota displacement (routing bills fewer tokens to the Claude subscription than a vanilla session at equal task success, split into a Claude tiers only arm, a peer offload arm, and an advisor profile arm where the main session runs on Sonnet and consults stronger tiers on demand), C2 wall clock compression on plan shaped tasks versus a protocol enforced sequential baseline, and C3 typed failure surfacing, scoped to the shared companion outcome contract the test suite already covers. The harness ships in bench/: a runner that isolates each condition in its own Claude configuration directory and keeps verifiers outside the model visible worktree, a strict JSONL record schema, a summary script that refuses to compare snapshots from different task manifests, a redaction step for published transcripts, and a manifest tool that content hashes every task before any results exist.

No claim results are published yet. The task suite currently holds nine tasks (T01 to T09) of the planned 8 to 12. The first dated reference snapshot ships once the pool is complete, with raw per run data committed alongside the summary table. Until then the status is plain: the procedure is public and runnable, the numbers do not exist. Readers can run the harness themselves with node bench/run.mjs --task <id> --condition <A|B1|B2|B3> --repetition <n> --results <dir> --claude-config <dir> after building condition profiles per bench/conditions/README.md. A separate lane instrument, node bench/lanes/run.mjs, runs one task brief through one engine companion on an explicit model and effort, so routing scores rest on matched evidence; its first snapshot is bench/results/lanes-2026-10-13, and it makes no claim under test.

Data and uninstall

The Codex plugin keeps job records, prompts, logs, event ledgers, and stored results under ~/.claude/plugins/data/codex-claude-code-fusion/; prompts and logs can contain task text, diffs, command output, and diagnostics. Heavy artifacts of terminal jobs (event logs, stdout and stderr logs, partial results) are capped at 256 jobs and 512 MiB (CODEX_COMPANION_HISTORY_MAX_RECORDS, CODEX_COMPANION_HISTORY_MAX_BYTES), while each job record and its brief stay for up to 5000 jobs or 90 days (CODEX_COMPANION_RECORD_MAX_RECORDS, CODEX_COMPANION_RECORD_RETENTION_DAYS), so acceptance verdicts outlive the artifacts. Running jobs, resume safety records, and uncollected background results are protected even when they temporarily exceed those caps. Unknown, corrupt, future-schema, and crash-orphaned content is left untouched rather than counted as safely managed history. Private raw-command staging is removed at SessionEnd for the matching session or after one hour during a later transport allocation.

The Grok plugin keeps its companion ledger, private job records, briefs, and logs under ~/.claude/plugins/data/grok-claude-code-fusion/; briefs can contain prompts and diffs, logs can contain Grok stderr, and new records retain the CLI reported usage and model_usage objects. /grok:history reads a safe metadata projection from this ledger. The companion prunes a terminal job record with its brief and log 90 days after it finished (GROK_COMPANION_RECORD_RETENTION_DAYS, 0 disables) and never prunes a running job, an uncollected result, or a record that a live resume lease refers to. Native Grok conversations are separate under ~/.grok/sessions; upstream retains them for 30 days by default. ~/.grok/config.toml accepts a positive integer at [storage] cleanup_ttl_days; 0 falls back to the default 30 days. Cross-session memory is separate again under ~/.grok/memory and can be read or written by upstream only when memory is enabled. Deleting the companion ledger does not delete native sessions or memory, and deleting native sessions does not clear companion history. A model_usage row contains input, output, cache-read, cache-creation, and model-call counts plus optional cost, so reporting never invents reasoning or total token channels. usage_is_incomplete means the usage ledger may have missed open subagents, usage application, or a drain timeout; present tokens are observed lower bounds and both job-total token and cost coverage are incomplete. Exact positive cost pairs use integer ticks at 10000000000 ticks per USD as authoritative. Grok raw-command staging uses one-time private directories under validated system temporary storage and is consumed before parsing or pruned after one hour. Its headless stdout uses a separate 0600 file that is unlinked as soon as it is opened.

The Cursor plugin keeps its job records, briefs, logs, model catalog cache, compile cache, and each job's private home (including the Cursor chat store used for resume) under ~/.claude/plugins/data/cursor-claude-code-fusion/; private homes contain chats that can hold task text and results. When a job ends, its private home is pruned to the chat that resume needs, homes older than 30 days are removed, run directories without a job record are swept after an hour, and terminal job records are pruned after 90 days (CURSOR_COMPANION_RECORD_RETENTION_DAYS, 0 disables). Cursor's own account side history follows the account's privacy mode.

The Devin plugin keeps job records, briefs, logs, a model catalog cache, per job configuration, and a shared private home with a credentials link and CLI session data under ~/.claude/plugins/data/devin-claude-code-fusion/. Job records retain devinVersion, the selected and observed model, and the per job configDir; run directories without records are swept after an hour, terminal job records are pruned after 90 days (DEVIN_COMPANION_RECORD_RETENTION_DAYS, 0 disables), and the CLI owns retention of its session database. Clear this directory only when no running job, uncollected result, or resume evidence is needed.

The Antigravity plugin keeps job records, briefs, logs, model cache, and private Gemini conversations under ~/.claude/plugins/data/agy-claude-code-fusion/ (or AGY_COMPANION_DATA). The real HOME remains available for login keychain authentication; settings and MCP configuration are isolated through --gemini-dir and reset before every run.

The OpenCode plugin keeps job records, briefs, logs, model cache, and a private Codex home under ~/.claude/plugins/data/opencode-claude-code-fusion/; the API key remains in the companion environment and is not written to those files.

The Fusion plugin keeps model routing and reconciliation data under ~/.claude/plugins/data/fusion-claude-code-fusion/: model-routing.json (whose top level breadth key selects the engine named in the rendered routing table), reconcile-decisions.json, short lived inline-guard/ session state, the longer lived inline-guard-audit/ JSONL ledger, workers/ lifecycle records with stable task identity and bounded usage, and observations/ sidecars for Codex model, effort, exact per turn token usage, and semantic acceptance. Fusion stats raw arguments use the same one-time temporary staging pattern. New directories use mode 0700 and data files use mode 0600 where the platform exposes POSIX modes. Delete the relevant directories to clear their history. Full uninstall: remove all six plugins via /plugin, delete ~/.claude/rules/orchestration.md, drop the optional Bash(node:*) entry from permissions.allow, delete the six current data roots, and optionally delete the preserved ~/.claude/plugins/data/codex-openai-codex/ root if its old history is no longer needed. Native Grok sessions and memory remain under ~/.grok unless removed separately. Environment overrides for Codex, Grok, Cursor, Devin, and Antigravity are documented in docs/codex-contract.md, docs/grok-contract.md, docs/cursor-contract.md, docs/devin-contract.md, and docs/agy-contract.md. Fusion's audit ledger accepts FUSION_INLINE_GUARD_AUDIT_DIR, FUSION_INLINE_GUARD_AUDIT_RETENTION_DAYS, FUSION_INLINE_GUARD_AUDIT_MAX_BYTES, and FUSION_INLINE_GUARD_AUDIT_MAX_FILES. /fusion:stats aggregates delegation counts across Claude workers and every peer engine, reports exact token totals only for complete records, distinguishes incomplete from unreported usage, and never estimates missing history. Claude account totals still come from ccusage, and the vendor dashboards remain authoritative for billing.

Development

npm test runs the suite against fake Codex, Grok, Cursor, Devin, and Antigravity binaries plus a fake Codex binary for OpenCode with no real peer CLI or network. claude plugin validate plugins/codex, claude plugin validate plugins/grok, claude plugin validate plugins/cursor, claude plugin validate plugins/devin, claude plugin validate plugins/agy, claude plugin validate plugins/opencode, claude plugin validate plugins/fusion, and claude plugin validate . check every plugin and the marketplace. Iterate with claude --plugin-dir ./plugins/codex --plugin-dir ./plugins/grok --plugin-dir ./plugins/cursor --plugin-dir ./plugins/devin --plugin-dir ./plugins/agy --plugin-dir ./plugins/opencode --plugin-dir ./plugins/fusion plus /reload-plugins; after committing and pushing, claude plugin marketplace update claude-code-fusion refreshes the installed copy.

CI also runs node bench/manifest.mjs --check; contributors should run it after touching bench/tasks.

Layout

  • .claude-plugin/marketplace.json: the marketplace manifest; installs as marketplace claude-code-fusion.
  • plugins/codex/: the Codex integration (companion runtime, codex-rescue agent, /codex:* commands).
  • plugins/grok/: the Grok integration (companion runtime, grok-rescue agent, /grok:* commands).
  • plugins/cursor/: the Cursor integration (companion runtime, cursor-rescue agent, /cursor:* commands).
  • plugins/devin/: the Devin integration (companion runtime, devin-rescue agent, /devin:* commands).
  • plugins/agy/: the Antigravity integration (companion runtime, agy-rescue agent, /agy:* commands).
  • plugins/opencode/: the OpenCode Go integration through the Codex CLI sandbox (companion runtime, opencode-rescue agent, /opencode:* commands).
  • plugins/fusion/: the orchestration layer: tier agents (agents/), the routing policy payload (rules/), and the /fusion:panel, /fusion:setup, /fusion:smoke, /fusion:doctor, /fusion:stats, /fusion:ultra, and /fusion:config commands.
  • shared/companion/: companion runtime modules shared by the engine plugins. node shared/sync.mjs copies them into each plugin by byte (Claude Code installs every plugin on its own), and CI fails when a copy drifts; edit the shared source, never a copy.
  • docs/: the companion outcome contract and one runtime contract per engine.
  • bench/: the benchmark methodology, harness, task suite, and lane instrument; no claim results yet, see the publication gate in bench/METHODOLOGY.md, and lane snapshots under bench/results/lanes-<date>/.
  • tests/: the fake Codex, Grok, Cursor, Devin, Antigravity, and OpenCode runtime tests plus Claude driven tests.

Internals

The shared companion outcome contract (job lifecycle, liveness, failure kinds, footer grammar, background collection, session threading, stop gate verdicts) lives in docs/companion-contract.md. The Codex instance contract (JSONL lifecycle, foreground invariant, process supervision, durable state, review, usage, and compatibility) lives in docs/codex-contract.md. The Grok CLI instance contract (headless invocation, permission inheritance, process lifecycle constants, timeouts, review validation, version pins) lives in docs/grok-contract.md. The OpenCode Go instance contract lives in docs/opencode-contract.md. Bug reports and questions go to GitHub issues.

License

MIT

About

Multi-model orchestration for Claude Code: Claude worker tiers plus the Codex and Grok CLIs as peer engineers

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages