invoking-codex-exec
Invoking codex exec
Delegate a self-contained task to codex exec while you keep working in the main conversation. The codex subprocess edits files, runs builds, reviews diffs, or addresses corrections — depending on the role you dispatch it as. You stay in command of the rest of the session.
Codex roles
Codex can be dispatched in three distinct roles. The role determines the prompt shape, the boundary, and how the orchestrator reads back the result.
| Role | Job | Allowed to edit files? | Output |
|---|---|---|---|
| Implementer | Build the change. Default. | Yes — within the worktree. May commit. | Committed diff + log. |
| Reviewer | Read the artifact and produce structured findings. | No. Read-only. Must not edit, must not commit. | JSON file at <worktree>/.codex-review-output.json. |
| Corrector | Apply specific fixes from a prior review. Same as implementer but with the review findings as input. | Yes — within the worktree. | Committed diff + log. |
The orchestrator (claude) is purely a manager: it plans, dispatches each role, reads structured outputs, and decides the next dispatch. Claude does not edit source files, does not make in-place fixes, and does not review code itself. Every read-or-write touch on the codebase goes through codex.
This means even one-line fixes go through a corrector dispatch. The cost is real but the discipline buys auditability — every change has an associated codex run with a prompt, a diff, and a review pass.