Codex Castor
Manages Git worktrees and task branches to isolate parallel Codex workers and inspect/merge diffs.
English · 简体中文
Codex Castor
Gemini talks human. Codex shuts up and ships. Zero tokens spent waiting.
Why Codex Castor · Benchmark · Quickstart · Monitoring · Permissions · Developer Docs · Homepage
https://github.com/user-attachments/assets/5ef7cb4c-914b-4e5f-a55f-bbb533259cee
Why Codex Castor?
Local Codex CLI writes solid, low-hallucination code — yet working with it directly often feels exhausting: dense jargon, defensive disclaimers leaking into your UI and READMEs, dated frontend taste, and subagent polling loops that burn tokens while waiting. Meanwhile, Gemini in Antigravity speaks plainly, nails visual taste, and clarifies requirements quickly.
Codex Castor puts Gemini in the architect seat and keeps Codex quietly executing in the background. You stay in one conversation with Gemini — no window-switching, no manual spec copy-pasting, and no token-burning status loops.
Pain point when running Codex solo | How Codex Castor fixes it |
Robotic jargon & defensive disclaimers leaking into UI/docs | Gemini owns requirements, UX copy, and final review. Codex executes headless specs and returns structured reports. |
Polling loops / | True zero-token idle wait. Antigravity runs |
Parallel tasks colliding in one working directory | Managed Git worktrees. Concurrent workers run on isolated |
Expensive full repo re-reads on rework | In-session |
Blindly cranking reasoning effort to | Empirical routing loop. Logs duration, tokens, rework rate, inline 1–5 ratings, and verbatim first replies ( |
Switching windows to check quota, Fast mode, or approvals | Antigravity Composer Widget + Codex Monitor. Toggle Codex Fast mode, switch permission policies ( |
Studying MCP or multi-agent design? Even if you aren't on Antigravity yet, Codex Castor is a clean, self-contained reference implementation of a zero-dependency Python 3.9+ stdio MCP server (
mcp/server.py), a standaloneui://MCP App (mcp/monitor.html), and a zero-polling async delegation protocol.
Related MCP server: AgentBraid
Same-prompt benchmark
What happens when you give the exact same prompt — build a local single-page Pour-Over Coffee Tasting Atlas & Brew Studio with editorial magazine aesthetics, 6 single-origin beans, live preference matching, interactive brew curve, and unit tests — to Solo Codex (xhigh) vs. Codex Castor (Gemini + Codex medium)?

Metric | Solo Codex ( | Codex Castor ( | Delta |
First-draft wall time |
|
| 2.4× faster |
Reasoning tokens |
|
| −53% |
Passing unit tests |
|
| +183% |
UI & repository cleanliness | 3-screen landing page; | Single-viewport editorial UI, clean copy, zero disclaimers | Night-and-day |
Note: Real side-by-side run (UI labels translated to English for readability). Exact numbers vary by task, but separating architecture & visual review from headless implementation consistently beats throwing maximum reasoning effort at a single agent.
Quickstart
Prerequisites: Python 3.9+, Git, a configured local Codex CLI, and Antigravity. Zero third-party Python packages required.
macOS & Linux
git clone https://github.com/JAY201368/codex-castor.git && cd codex-castor && ./scripts/install.sh --install-statuslineReload Antigravity to pick up the MCP server, composer widget, hook, and orchestrator skill, then verify the installation:
python3 scripts/doctor.pyWindows 11 x64 (native PowerShell — no WSL or Git Bash required)
Install Python for Windows (with the py launcher), Git for Windows, the native Codex CLI, and Antigravity, then run:
git clone https://github.com/JAY201368/codex-castor.git
Set-Location codex-castor
py -3 scripts/install.py --install-statuslineRestart Antigravity and verify with py -3 scripts/doctor.py. If codex.exe is outside PATH, pass --codex-bin 'C:\path\to\codex.exe'.
Upgrading: Pull the latest changes (or download a release archive) and re-run
./scripts/install.sh(orpy -3 scripts/install.pyon Windows). Include--install-statuslinewhen upgrading the optional CLI status line, and add--force-statuslineonly when replacing an existing custom status line.Common flags:
--symlink(link installed files to your checkout; requires Developer Mode / symlink permission on Windows),--gemini-dir PATH,--python PATH,--codex-bin PATH,--skip-gemini-md,--dry-run. Pass the same--gemini-dirtodoctor.py; add--jsonfor machine-readable diagnostics.Hook backup: The installer registers the
PreInvocationhook in~/.gemini/config/hooks.jsonand backs up any existing file tohooks.json.bakbefore modifying it.Uninstalling: Run
python3 scripts/install.py --uninstall(orpy -3 scripts/install.py --uninstallon Windows). Add--purge-stateonly if you also want to delete saved Castor telemetry and task logs.
Manual setup on macOS or Linux: Merge the codex-castor entry from config/mcp_config.example.json into ~/.gemini/config/mcp_config.json. Point command to Python 3.9+ and pass the absolute path to mcp/server.py. Keep telemetry.py, castor_platform.py, windows_process.py, composer_bridge.py, composer_widget.js, report.schema.json, and monitor.html alongside server.py (plus analytics.py and executable hook.py for an installed copy). Set CODEX_BIN to your Codex executable, install skills/codex-orchestrator/SKILL.md to ~/.gemini/config/skills/codex-orchestrator/SKILL.md, and merge config/GEMINI.md into ~/.gemini/GEMINI.md.
Merge this entry into ~/.gemini/config/hooks.json with your absolute Python and hook paths:
{
"codex-castor": {
"PreInvocation": [
{
"type": "command",
"command": "[ ! -f '/path/to/hook.py' ] || '/path/to/python3' '/path/to/hook.py'",
"timeout": 5
}
]
}
}Live monitoring & analytics
Codex Castor gives you full visibility at zero LLM tokens:
Antigravity Composer Widget (
mcp/composer_widget.js,mcp/composer_bridge.py): Adds a native status entry beside the Antigravity model selector to check live 5h / 7d Codex quota, toggle Fast mode, and switch the default permission policy (full_access,approve_for_me,workspace_write,read_only) in one click.Codex Monitor MCP App (
ui://codex-castor/monitor.html): Open in the Antigravity side panel or full-page view viacodex_monitor. Refreshes every 1 second while active and every 8 seconds when idle viatools/call.Tasks groups live runs and collapsible By Project history with filter counts (
All,Active,Rated,Unrated), model/effort/Fast badges, concise failure summaries, two-step Cancel confirmation, full-screen Prompt & categorized Activity Stream viewers (per round for multi-round rework), and inline 1–5 star ratings & notes.Analytics displays overall KPIs and a Model × Reasoning Effort matrix (excluding failed runs from aggregates) so Gemini and you can pick the fastest, cleanest tier for each kind of task.
Zero-token Wakeup Hook (
scripts/hook.py): An AntigravityPreInvocationhook that renders each finished round's model, effort, duration, and token count inline viametadata.user_markdownand silently captures your first reply verbatim.Terminal & Antigravity CLI: Run
python3 scripts/watch.py(or--follow [TASK_ID]) for a standalone live terminal dashboard, or enable--install-statuslineto stack active tasks beneath Antigravity CLI's default status bar (stack_with_default: true; silent when idle).Standard MCP notifications: Pass
_meta.progressTokenfornotifications/progress, or setlogging/setLeveltoinfo/debugfornotifications/message.
Run from the repository (use py -3 instead of python3 on Windows). Every subcommand accepts --state-dir PATH:
python3 scripts/analytics.py summary [--model MODEL] [--effort EFFORT] [--project PROJECT] [--since YYYY-MM-DD] [--limit N] [--json]
python3 scripts/analytics.py backfill [--json]
python3 scripts/analytics.py feedback TASK_ID [--rating 1-5] [--verdict VERDICT] [--tags TAG1,TAG2] [--notes TEXT] [--user-prompt TEXT] [--round N]
python3 scripts/analytics.py export [--md PATH] [--csv PATH]summaryprints overall KPIs, the Model × Effort matrix, and recent tasks (15 by default;--sincefilters inclusively by creation date).backfillreconstructs the ledger and exports from saved task artifacts while preserving existing feedback.feedbackupdates the same records ascodex_feedback(defaults to the current round).exportregeneratesreport.mdandtelemetry.csvin the state directory, or writes to a specific path.
Effective model and reasoning effort are resolved in priority order from the current rollout's turn_context, explicit codex_dispatch/codex_resume overrides, the previous round, project .codex/config.toml, and user ~/.codex/config.toml (or $CODEX_HOME/config.toml).
Security & permissions
Codex Castor supports four configurable permission policies (default: full_access), configurable globally in ~/.gemini/codex-castor/settings.json or via the Antigravity composer widget, and overridable per round via permission_mode:
full_access(default): passes--dangerously-bypass-approvals-and-sandboxand--dangerously-bypass-hook-trustfor unattended execution.approve_for_me: uses Codex's auto-review approval flow (--approve-for-meon dispatch;workspace-writesandbox withon-request/auto_reviewon resume).workspace_write: restricts writes to the workspace (workspace-writesandbox withapproval_policy="never").read_only: restricts Codex to read-only inspection (read-onlysandbox withapproval_policy="never").
When using full_access, run Codex Castor only in trusted local developer workspaces. Managed Git worktrees isolate files and branches, while Codex retains the local user's OS permissions — always inspect git diff and run verification checks before merging.
Architecture & lifecycle
flowchart LR
U["User"] --> G["Gemini / Antigravity"]
G -->|"spec or review feedback"| B["MCP stdio · mcp/server.py"]
B -->|"codex exec / codex exec resume"| C["Local Codex CLI"]
C --> W["Optional managed Git worktrees · codex/task-a, codex/task-b"]
C -->|"JSON events and final report"| B
B -->|"Tool result → Antigravity wakes Gemini"| G
G -->|"Independent diff and tests"| WWrite a self-contained spec. Gemini inspects the codebase and covers objective, key files, requirements, constraints/non-goals, verification commands, and acceptance criteria.
Route, dispatch, and yield. Gemini checks
~/.codex/models_cache.json(falling back to~/.codex/config.toml) and past telemetry, picksmodelandreasoning_effort, prefixestoolSummarywith[<model>·<effort>], enablesuse_worktree: truefor concurrent workers, and ends its turn cleanly — zero status loops, zerosleep, zero polling timers.Review independently. On automatic wakeup, Gemini receives a compact result containing the six-field structured report schema (
status,summary,files_changed,commands_run,tests_summary,open_issues),git.diff_stat,git.status_short, and telemetry. Gemini inspects the actual diff, runs tests, and either sends file-specific rework viacodex_resumeor merges and cleans up the worktree.Close the feedback loop. The
PreInvocationhook displays round telemetry inline and records your first reply verbatim; ratings and notes from Codex Monitor feed straight back into future routing.
See the Orchestrator Skill for the complete protocol, or read the Illustrated Engineering Manuscript.
MCP tools reference
All seven tools use eager: true in Antigravity (timeoutSeconds: -1). The stdio server speaks newline-delimited JSON-RPC 2.0 and runs each tool call in a worker thread.
Tool | Background | Key inputs | When to use |
|
| Absolute | Start a new implementation from a self-contained Markdown spec. |
|
|
| Send concrete review feedback back to an existing Codex session. |
|
|
| Record or update ratings/verdicts or store the user's first reply verbatim. |
|
|
| One-off inspection on explicit request or post-mortem debugging. |
|
|
| Stop Codex and all child processes (Job Object on Windows; |
|
|
| Remove a managed Git worktree after merge or discard. |
|
| Optional | Open the Codex Monitor MCP App or fetch structured snapshots, quota, analytics, and per-round prompt/activity detail. |
What's included
Path | Purpose |
Zero-dependency stdio MCP server managing subprocesses, worktrees, rollout model/effort tracking, quota refresh, failure summaries, and Monitor snapshots. | |
Self-contained MCP App ( | |
Antigravity chat composer widget and local bridge for live 5h/7d Codex quota, Fast mode toggle, and permission policy selector. | |
Locked telemetry/feedback ledger, synced JSONL/CSV/Markdown exports, historical backfill, and analytics aggregation. | |
Six-field JSON Schema enforced on Codex's final handoff report. | |
Cross-platform path/process helpers and native Windows Job Object termination. | |
Gemini's end-to-end procedure for specs, model routing, independent review, and telemetry reporting. | |
Antigravity MCP wiring ( | |
Cross-platform installer, hook merger, uninstaller, and stdio handshake health check. | |
Zero-token | |
Antigravity CLI native status line and standalone live terminal watcher. | |
Automated Python |
~/.gemini/codex-castor/
├── settings.json # default fast_mode & permission_mode
├── telemetry.jsonl
├── telemetry.csv
├── report.md
├── hook_state/
│ └── <conversation_id>.json # transcript cursor and pending rounds
├── tasks/
│ └── <task_id>/
│ ├── spec.md
│ ├── meta.json
│ ├── events-r1.jsonl
│ ├── stderr-r1.log
│ ├── report-r1.json
│ ├── feedback-r2.md
│ ├── events-r2.jsonl
│ ├── stderr-r2.log
│ └── report-r2.json
└── worktrees/
└── <task_id>/ # managed checkout on codex/<task_id>Override the state root with CODEX_CASTOR_STATE_DIR and the Codex binary with CODEX_BIN. Outer process status and the worker's report.status are tracked separately — inspect both before accepting or resuming.
Testing & development
python3 -m unittest discover -s tests -v
python3 scripts/doctor.py --repo-onlyOn Windows, run py -3 -X utf8 -m unittest discover -s tests -v and py -3 scripts/doctor.py --repo-only. See the Windows 11 x64 verification guide for CI matrix and live Antigravity App/CLI verification details.
If Codex Castor saves your quota, sanity, or gives you a useful reference for async MCP Apps, a ⭐️ helps others find it.
Illustrated Manuscript Homepage · Glama Registry · Releases · MIT License
Available Tools
7 toolscodex_cancelB
Terminate a currently running Codex task immediately.
Inputs: task_id (required).
codex_cleanup_worktreeA
Remove a managed Git worktree created with use_worktree=true after Gemini has verified and merged (or discarded) its branch.
Inputs: task_id (required), force, delete_branch.
codex_dispatchA
Dispatch a detailed implementation specification to local Codex CLI running non-interactively with the configured Codex Castor permission policy (full access by default). Configured as an async background tool: after calling it, do NOT poll codex_status; either work on something else or stop your turn and wait for automatic wakeup.
Inputs: workdir (required), spec, model, title, +8 more.
codex_feedbackB
Record or update user/reviewer effectiveness feedback (rating 1–5, verdict, tags, notes) and/or the user's first prompt after a Codex round finishes. Automatically updates meta.json, telemetry.jsonl, telemetry.csv, and report.md.
Inputs: task_id (required), tags, notes, round, +3 more.
codex_monitorCodex MonitorC
Open the live Codex Castor monitor panel (side pane or full page in Antigravity App) or return a structured live snapshot of running and recent Codex tasks including effective model, reasoning effort, and current activity.
Inputs: limit, task_id, refresh_quota, include_detail.
codex_resumeA
Resume an existing Codex task/session with concrete review feedback or rework instructions while preserving Codex's prior session memory. Model and reasoning effort inherit independently from the previous round when known, unless explicitly overridden. Applies the configured Codex Castor permission policy (full access by default). Runs asynchronously as a background tool; do NOT poll after calling.
Inputs: model, task_id, workdir, feedback, +5 more.
codex_statusA
Non-blocking inspection of one Codex task (or list of recent tasks). Use ONLY when the user explicitly asks for progress or for post-mortem debugging—never poll in a loop.
Inputs: limit, task_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Most tools have clearly distinct lifecycle roles: dispatch, resume, cancel, cleanup, feedback, monitor, and status. The main ambiguity is between codex_monitor and codex_status, since both can report on running/recent tasks, though the descriptions distinguish a live UI/snapshot from explicit non-blocking inspection.
All tools consistently use the codex_ prefix with snake_case, making the set predictable. Most names are action-oriented, though a few are noun-like (feedback, status, monitor), causing minor deviation from a strict verb_noun pattern.
Seven tools is well-scoped for a Codex task orchestration server. Each tool maps to a distinct lifecycle operation, and there are no obvious redundant or filler tools.
The surface covers the core task lifecycle: dispatch, monitor, status, resume with feedback, cancel, worktree cleanup, and effectiveness feedback. Minor gaps may exist around retrieving full task output or configuring policy dynamically, but core workflows are supported.
Maintenance
Related MCP Connectors
Hosted MCP server for live public-data APIs and Skills for AI agents.
Hosted MCP server and Agent Skills for specs, engineering threads, and project memory.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Real-time planetary signal engine and Model Context Protocol (MCP) server for autonomous AI agents.
Related MCP Servers
- AlicenseAqualityAmaintenanceAn MCP server that bridges Claude Code with Antigravity CLI using a Swarm Agent architecture to optimize local development workflows and minimize LLM token costs. Includes a web UI for monitoring agent workflows.33731 PyPI35MIT
- AlicenseNot gradedqualityCmaintenanceA local-first MCP orchestration server that uses Codex as lead planner and Antigravity as host to delegate and review bounded tasks with Git integration and persistent SQLite state.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceMCP server that bridges Claude Code to Google Antigravity's CLI, enabling Claude to orchestrate Gemini workers in parallel for reading, writing, verifying, and autonomous tasks. It provides tools for single dispatch, parallel fan-out, background jobs, and handles permission, cwd, and shell pitfalls.2MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that lets OpenAI Codex and Google Antigravity delegate tasks to each other, review each other's code, continue multi-round discussions, leave notes, and synchronize MCP servers, skills, and rules across both apps.MIT