codex-exec
Codex-exec runs autonomous task execution through the codex CLI in non-interactive mode, streaming progress to stderr with final results on stdout. Use this skill when users explicitly request codex execution, task delegation to codex, or autonomous problem-solving. The tool accepts task descriptions as arguments and can process large context via stdin piping.
git clone --depth 1 https://github.com/tobihagemann/turbo /tmp/codex-exec && cp -r /tmp/codex-exec/claude/skills/codex-exec ~/.claude/skills/codex-execSKILL.md
# Codex Exec Autonomous task execution via the codex CLI. Runs non-interactively. Progress streams to stderr; final result on stdout. ```bash codex exec "task description" < /dev/null ``` For large context, pipe it via stdin. The prompt stays as the argument, context is passed as `<stdin>` automatically: ```bash cat context.txt | codex exec "question about the context" ``` Route text you did not author through this channel whatever its size — a diff, file contents, a code comment, a plan or spec, third-party feedback, command output. Keep backticks and `$` out of the quoted argument even in text you wrote, since both stay live inside it. Write the context file with the Write tool so nothing is interpreted on the way in. ## Sandbox **All `codex` Bash calls require `dangerouslyDisableSandbox: true`** (network access to OpenAI API). Without it, codex crashes with an `Operation not permitted` panic from the `system-configuration` crate before the model runs. ## Stdin Gotcha Codex reads from stdin whenever stdin is non-TTY (per `codex exec --help`: "If stdin is piped and a prompt is also provided, stdin is appended as a `<stdin>` block"). In subagent and subprocess contexts the harness leaves stdin connected to a pipe that never EOFs, so a bare `codex exec "..."` hangs forever, printing only `Reading additional input from stdin...`. Always redirect stdin on non-piped invocations: ```bash codex exec "task description" < /dev/null ``` The piped form (`cat context.txt | codex exec "..."`) is safe — `cat` closes the pipe after the file, sending EOF. ## Synchronous Execution Run codex via the Bash tool as a foreground call (do not set `run_in_background`). Set `timeout: 600000`, the Bash maximum. A larger value is not honored: the harness backgrounds the call immediately and hard-kills codex at 600s, truncating its output. Within a valid timeout, codex runs foreground and returns its result synchronously when it finishes in time. Capture the `session id:` from the run's stderr chrome as it starts; it never appears in the `-o` file, and recovery depends on it. Do not pass `--ephemeral` when the run may need recovery, since it persists no session files. Give every run its own `-o` path, named with a random tag so that runs spawned concurrently and successive runs in an iteration loop cannot collide on a path each derived independently. A reused path holds the prior run's complete output until the current run exits, so an early read returns well-formed output from the wrong run; a fresh path turns that same read into a detectable empty one. Treat content in the `-o` file as final only once the run has exited. A run that outlives the timeout is normally **force-backgrounded**: the result carries a task ID and an output file path, and the run continues to completion. Recover it by reading the output file: `Read` the path, then `Read` it again once the `<task-notification>` reports completion. Rarely the run is **hard-killed** instead, giving an error exit (code 143) reading `Command timed out after <duration>` with no task ID and no `-o` file. Do not re-run the prompt from scratch; that discards the work already done and hits the same ceiling. Resume the session with a fresh output path, asking for the findings as the final message rather than as a file write: ```bash codex exec -o <fresh-output-path> resume <session-id> \ "Reply now with your complete findings as your final message." < /dev/null ``` `resume` inherits the original session's sandbox, so pass `--sandbox` only to change it. When the kill left no session id in hand, recover it from the newest `~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-<timestamp>-<session-id>.jsonl` (the id is the UUID in the filename), listing a single day directory so the ordering is right. `codex exec resume --last` also works when no other codex run is in flight. Do not consult `~/.codex/session_index.jsonl`; it lags behind the rollout files. Never wait with `Monitor` (it returns immediately, and events that arrive after your final text are dropped), and never return the task ID, an interim file snapshot, or `"Waiting for codex to finish"` as the result — each is a false-empty return. ## Transient Crash Retry Re-run the command once when the Bash call returned an error exit with no stdout and no task ID. A timeout is not a crash: when the error text reads `Command timed out after <duration>`, resume the session per Synchronous Execution rather than re-running. Recover a force-backgrounded run per Synchronous Execution rather than retrying it. Keep the same prompt. Treat a second failure as final. Treat models-manager and cache-TTL errors as non-fatal warnings. Read the error text for usage-limit and authentication signatures and report those without retrying. ## Permission Levels | Level | Flag | When to Use | |-------|------|-------------| | Read-only | `--sandbox read-only` | Analysis, code reading, generating reports | | Workspace write | `--sandbox workspace-write` | Editing files within the project | | Full access | `--sandbox danger-full-access` | Installing packages, running tests, system operations | | Full auto | `--full-auto` | Combined with a sandbox level for unattended execution | Omitting `--sandbox` falls back to the codex config and project trust level (trusted projects run workspace-write), so always pass the flag explicitly. For fix or implementation tasks, default to `--sandbox workspace-write --full-auto` so Codex can edit files without confirmation prompts. Use `--sandbox read-only` for analysis or research tasks. ## Options | Option | Description | |--------|-------------| | `--full-auto` | Allow file edits without confirmation prompts | | `--sandbox <level>` | Permission level: `read-only`, `workspace-write`, `danger-full-access` | | `--json` | JSON Lines output (progress + final message) | | `-o <path>` | Write final message to a file | | `--output-schema <path>` | Enforce JSON Schema on the output | | `--epheme
For each reviewer question on a PR, recall implementation reasoning and compose a raw answer. Use when the user asks to \"answer reviewer questions\", \"draft answers to PR questions\", or \"explain reviewer questions\".
Apply findings by making the suggested code changes. Applies accepted verdicts, escalates ambiguous findings to the user, and offers to note genuine improvements for later. Use when the user asks to \"apply findings\", \"apply fixes\", \"apply suggestions\", \"apply accepted findings\", \"fix the findings\", or \"apply the review results\".
Project-wide health audit pipeline that fans out to all analysis skills in parallel, evaluates findings, and produces a unified report at .turbo/audit.md. Use when the user asks to \"audit the project\", \"run a full audit\", \"project health check\", \"audit my code\", \"codebase audit\", or \"comprehensive review\".
Shared changelog conventions and formatting rules referenced by $create-changelog and $update-changelog. Not typically invoked directly.
Enforce existence, reuse, mirror, and symmetry principles to keep new code minimal and consistent with surrounding code. Use when writing new code in an existing codebase, adding new features, refactoring, or making any code changes.
Run AI-powered code review using the codex CLI. Use when the user asks to \"codex review\", \"run codex review\", or \"review a commit with codex\".
Shared commit message rules and technical constraints referenced by /stage-commit and /commit-staged. Not typically invoked directly.
Commit already-staged changes and push in one step. Use when the user asks to \"commit and push staged changes\", \"commit and push what's staged\", or \"commit staged and push\".