Skip to content

Commit 91b7f49

Browse files
committed
Initial Claude Code Codex subagents plugin
Add a daemonless Claude Code MCP plugin for launching OpenAI Codex agents from Claude Code. Includes read-only defaults, Codex desktop binary resolution, project_dir support, parallel agent runs, Spark model presets, nested Codex subagent configuration, GitHub CI, comprehensive fake/runtime validation, and opt-in live Claude plus real Codex tests.
0 parents  commit 91b7f49

29 files changed

Lines changed: 28236 additions & 0 deletions

.claude-plugin/mcp.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"mcpServers": {
3+
"codex-subagents": {
4+
"command": "${CLAUDE_PLUGIN_ROOT}/dist/index.js",
5+
"env": {
6+
"CLAUDE_PROJECT_DIR": "${CLAUDE_PROJECT_DIR}"
7+
}
8+
}
9+
}
10+
}

.claude-plugin/plugin.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "codex-subagents",
3+
"version": "0.1.0",
4+
"description": "Launch OpenAI Codex agents from Claude Code through a daemonless MCP server.",
5+
"author": {
6+
"name": "xuio"
7+
},
8+
"license": "MIT",
9+
"keywords": ["codex", "subagents", "mcp", "parallel"],
10+
"mcpServers": "./.claude-plugin/mcp.json",
11+
"skills": "./skills"
12+
}

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Node ${{ matrix.node }}
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
node: [20, 22]
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v5
25+
26+
- name: Setup Node
27+
uses: actions/setup-node@v5
28+
with:
29+
node-version: ${{ matrix.node }}
30+
cache: npm
31+
32+
- name: Install
33+
run: npm ci
34+
35+
- name: Test
36+
run: npm run test:ci

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
.DS_Store
3+
.env
4+
*.log
5+
coverage/
6+
.vitest/
7+
tmp/

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial Claude Code plugin for launching Codex agents through a daemonless stdio MCP server.
6+
- Added read-only defaults, non-interactive approvals, Codex desktop binary resolution, and per-call `project_dir`.
7+
- Added single-agent, parallel-agent, Spark preset, and nested Codex subagent support.
8+
- Added unit, MCP smoke, reliability, runtime, desktop Claude Code, and opt-in live Claude/Codex validation scripts.

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Contributing
2+
3+
Thanks for improving `claude-code-codex-subagents`.
4+
5+
## Development
6+
7+
```sh
8+
npm install
9+
npm run build
10+
npm test
11+
npm run test:ci
12+
```
13+
14+
`test:ci` is the portable suite used by GitHub Actions. It uses the fake Codex binary and does not require Claude Code, the Codex desktop app, or live credentials.
15+
16+
Desktop-only and live-token checks are available when you need end-to-end validation:
17+
18+
```sh
19+
npm run test:comprehensive
20+
npm run test:claude-orchestration
21+
npm run test:claude-real-codex
22+
```
23+
24+
## Pull Requests
25+
26+
- Keep the default sandbox behavior read-only unless a change explicitly requires otherwise.
27+
- Prefer small, focused changes with tests that cover the MCP contract.
28+
- Do not commit credentials, local logs, generated temp files, or machine-specific paths.
29+
- Run `npm run build` before committing changes to `src/`, because the plugin manifest loads `dist/index.js`.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 xuio
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Claude Code Codex Subagents
2+
3+
[![CI](https://github.com/xuio/claude-code-codex-subagents/actions/workflows/ci.yml/badge.svg)](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

SECURITY.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Security Policy
2+
3+
This plugin launches Codex from Claude Code through a local stdio MCP server. The default execution mode is intentionally conservative:
4+
5+
- Codex runs with `--sandbox read-only`.
6+
- Codex uses non-interactive `approval_policy="never"`.
7+
- Prompts are sent over stdin instead of command-line arguments.
8+
- Custom nested subagents are written to a temporary Codex home and cleaned up after the run.
9+
10+
## Reporting A Vulnerability
11+
12+
Please report security issues through GitHub Security Advisories for this repository. If advisories are not available, open an issue with a minimal description and avoid posting secrets, tokens, private logs, or sensitive project contents.
13+
14+
## Handling Secrets
15+
16+
Do not include API keys, OAuth tokens, local auth files, Claude/Codex account output, `.env` files, or machine-specific private paths in issues or pull requests. The test suite uses a fake Codex binary for portable CI coverage.

0 commit comments

Comments
 (0)