/codex-worker:codex-workerfrom codex-worker
Delegates a code change from a Claude Code session to an outside Codex CLI worker. Covers sandbox scope, the `codex exec` run, monitoring, follow-ups, review, and a worker inside the pstack Orchestrate playbook. Use when Claude Code is the harness and a code delegate should be a Codex CLI run, or when asked to hand a task to Codex, run `codex exec`, or use Codex as a worker or reviewer. Do not use when the agent itself runs inside Codex.
Ships in codex-worker. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill only when Claude Code is the harness and Codex is an outside worker. Do not use this skill when the agent runs inside Codex. In that case, use spawn_agent.
A Codex worker is a delegate. It does the brief and edits the code. It is the same as a pstack:poteto-agent code delegate.
Before you write the brief, make a list of what the worker needs:
/tmp or $TMPDIR. Many test tools and build tools do this.Put the list into sandbox flags. In the commands below, <scope> is these flags:
-c 'sandbox_mode="workspace-write"' -c 'sandbox_workspace_write.writable_roots=["<other-folder>"]' -c 'sandbox_workspace_write.network_access=false' -c 'sandbox_workspace_write.exclude_slash_tmp=true' -c 'sandbox_workspace_write.exclude_tmpdir_env_var=true' -c 'approval_policy="on-request"' -c 'approvals_reviewer="auto_review"'
writable_roots. The sandbox does not limit reads.writable_roots. If the worker writes only to its worktree, use [].network_access to true./tmp or $TMPDIR, set the two exclude_* keys to false..git folder to writable_roots. Codex keeps all .git folders read-only.command_execution item that completed or failed.sandbox_mode="danger-full-access" only when the task cannot run in the sandbox. If you use it, tell the user that the run had full access.Do not add guard hooks or wrapper scripts to the run.
Give each worker its own worktree or branch (pstack:principle-separate-before-serializing-shared-state).
Make a <run-dir> outside the worktree. This keeps the run files out of the diff.
Write the brief to <run-dir>/brief.md. Start the brief with "Load the poteto-mode skill."
In the brief, give the goal, the done state, the checks, and the branch for the commit. The worker commits its own work.
Start the run with the Bash tool and run_in_background: true:
rm -f <run-dir>/exit-code; codex exec --json -C <worktree> <scope> -o <run-dir>/last-message.md - < <run-dir>/brief.md > <run-dir>/events.jsonl; echo $? > <run-dir>/exit-code
To use the Codex default model, do not use -m. Use -m only when the task is too difficult for the default model.
Monitor tool on the events file. Each line is one JSON event.thread.started. It has the thread_id.item.completed event. Its item.type can be command_execution, file_change, agent_message, or a different type. The end of a turn is turn.completed or turn.failed.last-message.md.The run failed if one or more of these conditions are true:
exit-code is not 0.turn.* event in the events file is not turn.completed.A refused commit can also end with turn.completed, so do all the checks. If the run failed, tell the user in your next reply. Say that Codex did not do the task, and say why.
The Fresh subagents by default rule in the Subagents section of the pstack:poteto-mode skill applies. A fresh run in the same worktree keeps the files and the changes that are not committed. Resume only if the follow-up needs the conversation of the thread, and a brief cannot hold it at low cost.
rm -f <run-dir>/exit-code; (cd <worktree> && codex exec resume --json <scope> -o <run-dir>/last-message.md <thread_id> - < <run-dir>/follow-up.md > <run-dir>/events-resume-<n>.jsonl; echo $? > <run-dir>/exit-code)
resume has no -C flag. It uses the current directory as its workdir. resume does not keep the sandbox of the first run, so give the same <scope> again.
The review is a separate step. Start it after the work run stops. Any harness can do the review. The reviewer must be a fresh agent that did not write the change. Use one of these reviewers:
A fresh Claude subagent. Follow the Subagents section of the pstack:poteto-mode skill.
A separate Codex review run that is read-only. Start it from the worktree with the Bash tool and run_in_background: true. This run reads the diff. It does not do the checks.
rm -f <run-dir>/review-exit-code; (cd <worktree> && codex exec review --json -c 'sandbox_mode="read-only"' --base <base-branch> -o <run-dir>/review.md > <run-dir>/review-events.jsonl; echo $? > <run-dir>/review-exit-code)
The findings are in review.md. The review run failed if review-exit-code is not 0. It also failed if the last turn.* event in review-events.jsonl is not turn.completed.
Outside Orchestrate, Codex can review the work of Codex. Inside Orchestrate, the reviewer must use a different model family from the worker. If no review completes, keep the gate closed. Follow the Subagents section of the pstack:poteto-mode skill.
Do not use the report of the worker as the review. The auto reviewer that approves a commit controls only sandbox access. It does not review the code.
The drain loop of the Orchestrate playbook in pstack:poteto-mode reads only Agent notifications. In that playbook, spawn a background pstack:poteto-agent as a wrapper. In the brief, tell the wrapper to invoke the codex-worker:codex-worker skill and start one Codex worker as it says. Also tell it to return the result of each failure check and the text of last-message.md.
The wrapper starts the run in the background.
The wrapper waits with a foreground Bash call and timeout: 600000:
until [ -s <run-dir>/exit-code ]; do sleep 10; done
If the call stops before exit-code exists, the wrapper does the call again.
The wrapper does not end its turn while the run continues.
Do not use the Monitor tool to wait. Monitor does not block. The review is the verifier of the unit. The verifier is a separate unit, and it uses a different model family from the worker. Do not read the diff inside a drain.
Outside Orchestrate, start the run directly with the Bash tool.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub uraxii/dotai --plugin codex-worker