Skip to content

Codex

Zentri runs the Codex CLI with a profile named zentri. The profile adds the Zentri MCP server and hooks that claim each file before Codex patches it. Your Codex login and your own config.toml stay as they are.

  1. Install the Codex CLI. Zentri was checked against 0.172.0.

  2. Sign in with your own account through Codex’s own sign-in, or with your own API key. Zentri never reads or stores either. See Bring your own credentials.

    Terminal window
    codex login

    OpenAI documents API key sign-in for programmatic use:

    Terminal window
    printenv OPENAI_API_KEY | codex login --with-api-key
  3. Run zt doctor to check that codex is on your PATH.

  4. Start a task from your repository.

    Terminal window
    zt start --agent codex "add CSV export to the reports page"
  5. Attach with zt attach. The first time, Codex asks you to trust the new hooks. Trust the Zentri hooks once in /hooks. Zentri never passes --dangerously-bypass-hook-trust.

zt start writes the profile to $CODEX_HOME/zentri.config.toml. CODEX_HOME defaults to ~/.codex. Every session shares that one file, and zt start rewrites it only when its content changes. The launcher then runs:

Terminal window
codex --profile zentri \
-c 'sandbox_workspace_write.writable_roots=["<git dir>","<common dir>"]' "<prompt>"

The writable roots let Codex commit from the worktree. They change per session, so they go on the command line, not in the profile.

  • The stdio bridge as [mcp_servers.zentri], with env_vars for the session variables and default_tools_approval_mode = "approve".
  • approval_policy = "on-request", sandbox_mode = "workspace-write", and network_access = true, so the hooks can reach the coordinator.
  • The hooks below.

The profile holds no session token. zentri reads it from the file that ZENTRI_SESSION_TOKEN_FILE names.

Hook Matcher What it does
PreToolUse ^(apply_patch|Bash)$ Runs zentri hook codex pre-edit. It claims every file an apply_patch call names. A Bash call is checked only when it carries a patch. Any other command is left to the post-shell hook.
PostToolUse ^Bash$ Claims the files a command changed and tells Codex to revert any that another session holds.
SessionStart Passes on notices from other sessions.
UserPromptSubmit Passes on new notices.

Codex also gets the 13 MCP tools. The server’s instructions are under 512 characters, because Codex keeps only the first 512.

On your machine, zt start installs no skills for Codex. Codex 0.172.0 has no skills folder that belongs to a profile, and every folder it reads reaches all your Codex sessions, not only Zentri’s. To use the PRD and ADR skills anyway, copy them once into your user skills folder from a Zentri checkout:

Terminal window
mkdir -p ~/.agents/skills
cp -R adapters/skills/zentri-prd adapters/skills/zentri-adr ~/.agents/skills/

Without a checkout, zentri kit render --target sandbox --agent codex --out <dir> writes the same two folders under <dir>/etc/codex/skills/. Codex then lists the skills in every session, also in ones Zentri did not start, where the Zentri tools do not exist.

adapters/codex/AGENTS.md is an opt-in snippet for your repository’s own AGENTS.md. The launcher never writes it.

Terminal window
make sandbox-image AGENT=codex
zt start --launcher openshell --agent codex "add CSV export to the reports page"

The kit is managed config under read-only /etc. /etc/codex/requirements.toml holds the hooks with allow_managed_hooks_only = true. /etc/codex/config.toml holds the MCP server and turns off the update check, analytics, and feedback. The skills go to /etc/codex/skills/.

The policy lets /usr/local/bin/codex reach api.openai.com, chatgpt.com (only /backend-api/**), and auth.openai.com on port 443. A policy endpoint refuses a WebSocket upgrade, so Codex has to use its HTTP transport. See OpenShell policies.

  • A missing or crashing zentri binary lets the edit through, as described above.
  • With local-dev, Codex runs as you. A shell command that is not a patch can write a held file. The post-shell hook catches it afterwards.
  • The git pre-commit hook only warns, and git commit --no-verify skips it.

Codex has not run with its kit. Tests never use anyone’s credentials, and no Codex binary ran in this project’s tests. These points are inferred from Codex’s docs and source, not seen in a run:

  • that Codex loads hooks from a profile file;
  • that Codex asks you to trust the Zentri hooks once per machine;
  • that writable_roots lets commits through from the worktree.

Codex has not run inside an OpenShell sandbox either. The image builds and prints the pinned version.