Skip to content

feat(codex): Codex CLI bridge for cross-model exec, review, and verification#58

Merged
arzafran merged 2 commits into
mainfrom
feat/codex-bridge
Jun 19, 2026
Merged

feat(codex): Codex CLI bridge for cross-model exec, review, and verification#58
arzafran merged 2 commits into
mainfrom
feat/codex-bridge

Conversation

@arzafran

Copy link
Copy Markdown
Member

What this does

Adds a bridge to the OpenAI Codex CLI so a Claude Code session can use Codex as a second model — delegate bulk work to it, get an independent cross-model review of the current diff, or ask it a quick read-only question. It's opt-in and gated: if Codex isn't installed or logged in, everything no-ops and the session continues Claude-only, so teammates without Codex are unaffected.

The point is cross-model verification. Opus reviewing its own output shares its own blind spots; a different model family catches what self-review misses. The statusline shows whether the bridge is live at a glance.

Summary

  • src/lib/codex.ts — all bridge logic. Detection ladder: PATH check → bounded codex login status (no model call) → a real codex exec (the only way to observe entitlement/quota). Sticky verdict cache with TTLs (entitlement re-checked daily, quota per ~5h window), error classification, and a preflight gate that fails open.
  • src/scripts/codex-run.ts — the /codex CLI: exec (workspace-write), review and ask (read-only). exec never uses danger-full-access without an explicit flag.
  • src/hooks/codex-verify.ts — SessionStart hook (async, 3s timeout) refreshing the availability verdict.
  • skills/codex/SKILL.md + agents/codex-verifier.md — the skill and a Sonnet fan-out agent for parallel cross-model verification.
  • src/hooks/statusline.ts — availability badge (codex ✓ / auth? / ⏳; hidden when not-installed/unknown).
  • CLAUDE-FULL.md — quota-aware routing guidance (Opus = thinking, Sonnet = loop bodies, Codex = bulk/verify). MANUAL.md — skill registration. docs/codex-bridge.md — full design + a cross-reference to Codex's native config-import flow.

Security

  • -- terminates Codex arg parsing so a prompt starting with - can't be reparsed as a flag.
  • Sandbox runtime allowlist; danger-full-access is never a default.
  • stderr is ANSI-stripped, token-redacted, and length-capped before it's cached or shown.

Dogfood

Built the bridge, then ran /codex review against its own diff. Codex flagged two real issues — an unbounded codex login status in preflight, and a docs/statusline badge-string mismatch — both fixed in this branch. The cross-model loop closed on its first real use.

Test Plan

  • bun run typecheck clean
  • bun test — 576 pass / 0 fail (codex suite 37/37)
  • bun run lint — codex files clean
  • bun run lint:skills — 35 skills, 0 errors (under the 40 cap)
  • Live smoke test: ask round-trips, review reads the diff, verdict cache written
  • Reviewer: after merge+install, re-run setup.sh to refresh the hooks fingerprint (new SessionStart hook) — see docs/codex-bridge.md "Setup Caveat"

arzafran added 2 commits June 19, 2026 13:08
…, tests

Runtime interop with the OpenAI Codex CLI as a second model. src/lib/codex.ts
holds all logic: an L0/L1/L2 detection ladder (PATH → bounded `codex login
status` → real `codex exec`), a sticky verdict cache with TTLs (entitlement
re-checked daily, quota per ~5h window), error classification, and a preflight
gate that fails open to Claude-only.

Thin consumers: codex-verify.ts (SessionStart availability) and codex-run.ts
(the /codex CLI: exec / review / ask). exec defaults to workspace-write and
never danger-full-access without an explicit flag; review/ask are read-only.
codex-verifier agent fans out cross-model review on a risky diff.

37 tests cover detection, reconciliation, error classification, sandbox
allowlisting, and stderr redaction/capping.
Statusline badge reads the cached verdict (codex ✓ / auth? / ⏳; hidden when
not installed or unknown — no clutter for teammates without Codex). SessionStart
hook refreshes the verdict async with a 3s timeout. CLAUDE-FULL.md documents
quota-aware routing (Opus for thinking, Sonnet for loop bodies, Codex for
bulk/verify); MANUAL.md registers the skill. docs/codex-bridge.md is the full
design, including a cross-reference to Codex's native config-import flow as the
complementary config-interop direction.
@arzafran arzafran merged commit 70e2f58 into main Jun 19, 2026
15 checks passed
@arzafran arzafran deleted the feat/codex-bridge branch June 19, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant