|
| 1 | +# Claude Code Codex Subagents |
| 2 | + |
| 3 | +[](https://github.com/xuio/claude-code-codex-subagents/actions/workflows/ci.yml) |
| 4 | + |
| 5 | +Claude Code plugin that exposes OpenAI Codex agents through a daemonless stdio MCP server. |
| 6 | + |
| 7 | +The plugin lets Claude Code launch one Codex agent or several Codex agents in parallel. It is designed for read-only delegation by default: codebase exploration, review, planning, risk checks, documentation mapping, and other sidecar work where Claude should collect independent Codex results without giving those agents write access. |
| 8 | + |
| 9 | +## Defaults |
| 10 | + |
| 11 | +- Codex binary: prefers `/Applications/Codex.app/Contents/Resources/codex` when the Codex desktop app is installed, then falls back to configured overrides and `codex` on `PATH`. |
| 12 | +- Sandbox: `read-only`. |
| 13 | +- Approvals: non-interactive `approval_policy="never"`. |
| 14 | +- Transport: stdio MCP, launched by Claude Code for the active session. No daemon is required. |
| 15 | +- Prompt delivery: stdin, not command-line arguments. |
| 16 | + |
| 17 | +Optional environment overrides: |
| 18 | + |
| 19 | +- `CODEX_SUBAGENTS_CODEX_BIN`: explicit Codex CLI path. |
| 20 | +- `CODEX_SUBAGENTS_DEFAULT_MODEL`: model to use when a tool call omits `model`. |
| 21 | +- `CODEX_SUBAGENTS_DEFAULT_REASONING_EFFORT`: `minimal`, `low`, `medium`, `high`, or `xhigh`. |
| 22 | + |
| 23 | +## Spark And Nested Subagents |
| 24 | + |
| 25 | +Use `model_preset: "spark"` to launch a top-level Codex agent with `gpt-5.3-codex-spark`. Exact `model` still wins when both are provided. |
| 26 | + |
| 27 | +To let a Codex agent spawn its own Codex subagents, pass: |
| 28 | + |
| 29 | +- `codex_subagents`: custom Codex agent definitions with `name`, `description`, `developer_instructions`, optional `model` or `model_preset`, reasoning effort, sandbox, MCP servers, skills config, and extra config. |
| 30 | +- `subagent_tasks`: the specific built-in or custom subagents the parent Codex run should spawn and wait for. |
| 31 | +- `subagent_runtime`: runtime limits such as `max_threads`, `max_depth`, and `job_max_runtime_seconds`. |
| 32 | + |
| 33 | +Custom subagents are passed to Codex as `agents.<name>...` config overrides and also materialized in a temporary Codex home for the duration of one run. The target project is not modified, and the default sandbox remains `read-only`. |
| 34 | + |
| 35 | +## Installation |
| 36 | + |
| 37 | +```sh |
| 38 | +git clone <repo-url> |
| 39 | +cd claude-code-codex-subagents |
| 40 | +npm install |
| 41 | +npm run build |
| 42 | +claude --plugin-dir . |
| 43 | +``` |
| 44 | + |
| 45 | +The plugin manifest points Claude Code at `dist/index.js`, so run `npm run build` after changing TypeScript source. The built file is committed so the plugin can be loaded directly from a clone. |
| 46 | + |
| 47 | +## Development |
| 48 | + |
| 49 | +```sh |
| 50 | +npm install |
| 51 | +npm run build |
| 52 | +npm test |
| 53 | +npm run test:comprehensive |
| 54 | +npm run validate:plugin |
| 55 | +npm run test:claude-desktop |
| 56 | +``` |
| 57 | + |
| 58 | +`test:ci` is the GitHub-safe suite. It uses the fake Codex binary and does not require Claude Code, the Codex desktop app, or live model credentials. |
| 59 | + |
| 60 | +`test:comprehensive` runs the TypeScript build, unit tests, stdio MCP smoke test, reliability matrix, Codex desktop runtime probe, Claude plugin validation, and desktop-shipped Claude Code CLI plugin/auth checks. The runtime probe validates local Codex capabilities without invoking a model. |
| 61 | + |
| 62 | +`test:claude-orchestration` is an opt-in live Claude Code test. It loads the plugin inside Claude Code, lets Claude call the plugin MCP tools, and uses the fake Codex binary so no Codex model tokens are spent. It is kept out of `test:comprehensive` because it does spend Claude tokens. |
| 63 | + |
| 64 | +`test:claude-real-codex` is the full opt-in live path: Claude Code loads the plugin and calls real Codex through the desktop app binary, including one single agent, one parallel run, and one nested Spark subagent run. It spends both Claude and Codex tokens, so it is intentionally not part of the default suite. |
| 65 | + |
| 66 | +Run Claude Code with the local plugin: |
| 67 | + |
| 68 | +```sh |
| 69 | +claude --plugin-dir . |
| 70 | +``` |
| 71 | + |
| 72 | +After startup, ask Claude to use Codex subagents, or invoke the plugin skill: |
| 73 | + |
| 74 | +```text |
| 75 | +/codex-subagents:codex-subagents run three read-only Codex agents: one for API flow, one for tests, one for security risks |
| 76 | +``` |
| 77 | + |
| 78 | +## MCP Tools |
| 79 | + |
| 80 | +`run_agent` launches one Codex `exec` process. |
| 81 | + |
| 82 | +`run_agents` launches multiple Codex `exec` processes concurrently with a bounded `max_parallel` setting. |
| 83 | + |
| 84 | +`codex_status` reports the resolved Codex binary, server working directory, Claude project directory, default model, default reasoning effort, and version probe. |
| 85 | + |
| 86 | +Each agent accepts model, reasoning effort, sandbox, project directory, timeout, and output-size controls. Pass `project_dir` when Claude Code wants Codex to inspect the same repository or subdirectory Claude is currently working in. If `project_dir` is omitted, the server uses `CLAUDE_PROJECT_DIR` when Claude Code provides it. Omit model to use Codex's configured default or the plugin's optional configured default model. |
| 87 | + |
| 88 | +## License |
| 89 | + |
| 90 | +MIT |
0 commit comments