Claude Code on Opus plans, routes and reviews; Codex (GPT-6.1 Sol, through the
openai/codex-plugin-cc plugin) writes
the code; a Claude Opus complex-implementer subagent takes only high-risk units.
agentkit is one bash file that sets this up on a machine and in any repo.
You -> Opus session (plan, route) --default--> codex:codex-rescue (Codex, Sol)
\--high-risk--> complex-implementer (Opus)
both --> reviewer (Opus): PASS -> commit on agent/<unit> | FIX (max 2) | ESCALATE
git clone <your-private-remote>/agent-kit.git ~/.agent-kit # or keep it anywhere
~/.agent-kit/agentkit installinstall installs Claude Code and the Codex CLI if missing, writes
~/.codex/config.toml only if you have none, installs the codex@openai-codex
plugin at user scope, and links agentkit into ~/.local/bin. Then sign in once:
claude setup-token # headless; export CLAUDE_CODE_OAUTH_TOKEN=<token>
codex login --device-auth # or copy ~/.codex/auth.json from a laptopcd ~/work/<repo> && agentkit init
# review AGENTS.md (Commands section), then commit the result| File | Read by | Written by init |
|---|---|---|
AGENTS.md |
Codex and Claude | Created once with detected install/test/lint commands; never overwritten. An existing CLAUDE.md is moved here (backup kept). |
CLAUDE.md |
Claude | @AGENTS.md on line 1, plus the orchestration rules between agentkit:begin/end markers (refreshed on every run). |
.claude/agents/reviewer.md, complex-implementer.md |
Claude | Refreshed while they carry the "managed by agentkit" marker. |
.claude/settings.json |
Claude | Merged: model (only if unset), plugin enabled, marketplace declared. |
.codex/config.toml |
Codex | Model, effort, approval_policy = "never", workspace-write, network off. |
~/.codex/config.toml |
Codex | Appends a [projects."<repo>"] trust_level = "trusted" entry so the project config applies. |
.gitignore |
git | Adds .worktrees/. |
Override models at setup time: CODEX_MODEL=<id> CODEX_EFFORT=xhigh CLAUDE_MODEL=claude-opus-5-5 agentkit init.
Set CODEX_NETWORK=true for a project where Codex itself must install packages.
| Command | What it does |
|---|---|
agentkit install |
Machine setup (above). |
agentkit init [dir] |
Project setup (above). Works from inside a linked worktree too; it always targets the main checkout. |
agentkit wt <name> [base] [--no-install] |
Creates .worktrees/<name> on branch agent/<name> from base exactly as given (default: the branch checked out in the main checkout; pass origin/main to start from the remote), installs dependencies there (npm/pnpm/yarn, uv, poetry, go; bare pip is skipped with a warning), and prints only the path on stdout. |
agentkit codex <name> [--resume] [--model m] [--effort e] [prompt...] |
Runs a Codex task through the plugin's runtime with the unit's worktree as Codex's workspace (write access there only). Prompt from args, --prompt-file <f>, or stdin. --resume continues that worktree's last Codex thread. |
agentkit codex <name> status|result|cancel |
Job status, output or cancel for that worktree. |
agentkit rm <name> |
Removes a clean unit worktree; keeps the branch. |
agentkit doctor [dir] |
One line per machine and project check; exits non-zero if anything is missing. |
tmux new -As work
cd ~/work/<repo> && claude
> APP-1234: <ticket text>. Plan, route, and bring every unit to review PASS.Approve the plan and route table, watch a unit with
agentkit codex <unit> status (or result), read the final report, then push
the agent/ branch and raise the PR yourself. To take over a Codex run, use the
codex resume <session-id> line printed at the end of its output.
- Builders never commit. Codex's
workspace-writesandbox keeps.gitread-only, so it cannotgit add/commit. Builders leave changes uncommitted; the reviewer readsgit diff HEADand untracked files; Opus commits after PASS. - Units go to Codex through
agentkit codex <unit>, notcodex:codex-rescue. The rescue subagent always runs Codex at the git top level of the Claude session, so Codex could write to the main checkout and every other unit's worktree, rannpm testagainst unchanged code, and--resumepicked the newest thread in the whole repo (or refused while any other unit was running).agentkit codexcalls the same plugin runtime with--cwd <worktree>: Codex's sandbox, commands and resume thread are all scoped to that unit./codex:rescueis still there for ad-hoc questions. - Dependent units chain branches. Unit B is created from
agent/<A>after A passes review, andwtuses an explicit base exactly as given (no silent swap toorigin/<base>), so the reviewer diffs against the right ref. - Symlinked instruction files. A
CLAUDE.md -> AGENTS.mdsymlink is replaced by a realCLAUDE.md; a symlinkedAGENTS.mdstopsinit. Otherwise the Claude-only rules would leak into the file Codex reads. - Trust is read, not assumed. A project you once marked
untrustedin Codex is reported byinitanddoctorinstead of being treated as trusted. wtinstalls dependencies. Codex runs with network off, so a fresh worktree would have nonode_modules.- Worktree-safe roots.
init,wtandrmresolve the main checkout even when run inside.worktrees/<x>, so worktrees never nest. - Logs on stderr, so
path=$(agentkit wt x)works;doctorchecks are argument-safe (noeval) and check the configured model, not the default one. - Input validation for
CODEX_EFFORT,CODEX_NETWORKand model ids; a.gitignoreorconfig.tomlwithout a trailing newline is no longer corrupted.
- Never enable the plugin's review gate (
/codex:setup --enable-review-gate): it runs Codex after every Claude reply and can drain both plans. - Fix rounds are capped at 2, then the unit escalates to Opus.
- Agents push only
agent/branches; protectmainon the remote. - On a shared VPS, run everything as a dedicated non-root
agentuser with a deploy key that can push feature branches only.
bash tests/run.sh
uvx --from shellcheck-py shellcheck -x agentkit tests/*.sh