Codex
Route Codex's shell commands into the sandbox with a project hook.
boxer adds a hook to Codex that rewrites each intercepted command to boxer run. Codex sees the
normal output and exit code.
Set up
boxer install codex
git add .codex .agents
git commit -m "Run Codex's commands in boxer"Codex reads project hooks from the main checkout's files, not from the branch a worktree is on. Every worktree of this checkout uses them either way. Committing them shares them with your team.
Then do two things boxer install cannot:
-
Trust the project hooks. Codex loads project hooks only from a trusted project. Run
/hooksonce in Codex. Forcodex exec, pass--dangerously-bypass-hook-trust. -
Turn off Codex's own sandbox. A hypervisor cannot start inside Codex's seatbelt or landlock sandbox, so boxer cannot create one from there. boxer replaces it: intercepted commands run in the microVM. Run Codex with
--sandbox danger-full-access, or--dangerously-bypass-approvals-and-sandboxundercodex exec. To set it once, addsandbox_mode = "danger-full-access"to~/.codex/config.toml. That also covers Codex when an orchestrator starts it.With it, build and test commands run in boxer's microVM instead of Codex's sandbox.
git,gh,sshand any command not ininterceptrun on your machine without Codex's sandbox around them. Security lists what stays on the host.
These steps are tested with the Codex CLI. The Codex desktop app is not tested.
Codex reads project configuration from the main checkout, not from a linked worktree. Run from a
linked worktree, boxer install codex writes its hooks to both.
Secrets
Codex drops environment variables whose names contain KEY, SECRET or TOKEN from the commands
it runs, so a variable listed in secrets never reaches boxer run. Let them through in
~/.codex/config.toml:
[shell_environment_policy]
ignore_default_excludes = trueWhat it writes
| File | What it is |
|---|---|
.codex/hooks.json | the hooks: SessionStart creates the sandbox, PreToolUse rewrites commands, and SessionEnd, SubagentStart and SubagentStop handle cleanup and subagent sandboxes |
.agents/skills/boxer/ | the skill that tells Codex how commands run here |
To give Codex the boxer_run tool, add the MCP server to .codex/config.toml:
[mcp_servers.boxer]
command = "boxer"
args = ["mcp", "--harness", "codex"]Check it
boxer doctorThen ask Codex to run node -p process.platform. It prints linux.
Options
- No trust step:
boxer install codex --userwrites the hooks to~/.codex/config.toml, which Codex trusts. Use this under an orchestrator, where no one can approve project hooks. - Run Codex itself in the sandbox:
boxer shell codex. See Inside mode. - Block the shell instead: set
[harness.codex] mode = "tool".
Tested in the matrix with hook rewrite, tool mode, PATH shims and inside mode. PATH shims do not work if Codex starts a login shell.