codex-cli-runner
Skill20 starsChanged 22 days agoMITView on GitHub
Run the local `codex` CLI (OpenAI Codex) in non-interactive mode (`codex exec`) for arbitrary prompts; supports file-based system+user prompts, retries with exponential backoff, and writing output to a target file.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- citation-triangulationSkill
- claim-groundingSkill
- claude-cli-runnerSkill
- deep-literature-reviewSkill
- derivation-verifySkill
- dsh-cli-runnerSkill
- figure-hygieneSkill
- gemini-cli-runnerSkill
- hep-calcSkill
- hep-mcp-usageSkill
- idea-allocationSkill
- idea-generationSkill
- idea-pairwise-matchSkill
- idea-posteriorSkill
- julia-packageSkill
- julia-perfSkill
- kimi-cli-runnerSkill
- literature-graph-builderSkill
- literature-to-packageSkill
- markdown-hygieneSkill
- numerical-reliability-gateSkill
- opencode-cli-runnerSkill
- paper-reviserSkill
- pdg-lookupSkill
- physics-diagramsSkill
- referee-reviewSkill
- research-harnessSkill
- research-integritySkill
- research-teamSkill
- research-writerSkill
- review-swarmSkill
- zotero-importSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when you need to call the OpenAI Codex agent from the command line (any task), independent of the downstream workflow …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Codex CLI Runner
Use this skill when you need to call the OpenAI Codex agent from the command line (any task), independent of the downstream workflow (review, drafting, computation, etc.).
If you are already running as Codex, don't use this runner to re-invoke yourself. Keep the call in-host: a native sub-agent if your host exposes one, else inline in your own loop. The
codexCLI hop adds latency, a separate session, and context loss for zero gain. This runner is for reaching Codex from a DIFFERENT host (Claude / OpenCode / …) for cross-model work. Choosemodel_reasoning_effortby task difficulty (quality first, not token thrift) — hard tasks warranthigh/xhigh.
Preconditions
codexis installed:command -v codex- You are authenticated (run
codex loginif needed). - The default model and provider are configured in
~/.codex/config.toml.
Recommended: runner script (retries + file inputs)
SKILL_DIR="${SKILL_DIR:-$(for r in "${CLAUDE_CONFIG_DIR:-$HOME/.claude}" "${CODEX_HOME:-$HOME/.codex}" "$HOME/.config/opencode" "$HOME/.kimi-code"; do [ -d "$r/skills/codex-cli-runner" ] && echo "$r/skills/codex-cli-runner" && break; done || true)}"
bash "${SKILL_DIR}/scripts/run_codex.sh" \
--system-prompt-file /path/to/system.txt \
--prompt-file /path/to/prompt.txt \
--out /path/to/output.txtWith explicit model:
SKILL_DIR="${SKILL_DIR:-$(for r in "${CLAUDE_CONFIG_DIR:-$HOME/.claude}" "${CODEX_HOME:-$HOME/.codex}" "$HOME/.config/opencode" "$HOME/.kimi-code"; do [ -d "$r/skills/codex-cli-runner" ] && echo "$r/skills/codex-cli-runner" && break; done || true)}"
bash "${SKILL_DIR}/scripts/run_codex.sh" \
--model o3 \
--system-prompt-file /path/to/system.txt \
--prompt-file /path/to/prompt.txt \
--out /path/to/output.txtNotes
- Uses
codex exec(non-interactive mode) with--sandbox read-only(the safe default for review / text-generation tasks). Non-interactivity is pinned via-c approval_policy="never". - The runner intentionally does not pass codex's deprecated
--full-autoflag: in codex ≥0.140--full-autoimplies--sandbox workspace-writeand would silently override the read-only default, giving a reviewer write access. To allow writes, request the write sandbox explicitly with--sandbox workspace-write. - System prompt + user prompt are merged and fed via stdin to avoid ARG_MAX limits with large prompt files.
--output-last-message(-o) captures the agent's final response to the output file.- Danger:
--outOVERWRITES its target on every invocation, including retries. Never point--outat a file whose current content matters: a rerun or follow-up call that returns a short summary silently replaces whatever an earlier run wrote there (a real multi-hundred-line deliverable has been lost to a 13-line summary this way). Recommended pattern: have the prompt instruct the agent to write deliverables to their own separate files, and use--outonly to collect the final summary message. --skip-git-repo-checkis enabled by default so the runner works from any directory.- Retries on failure with exponential backoff (useful for transient API errors).
- Deterministic failures (usage/auth/region-ineligibility errors, exit codes 2/126/127, and similar, detected from the exit code and the tail of the attempt log) fail immediately with the diagnostic instead of burning the retry backoff.
- For offline/CI validation, use
--dry-runto print the planned invocation without calling Codex.
Session continuation (multi-turn / crash recovery)
codex exec records every run as a session (a rollout file under ~/.codex/sessions), and
codex exec resume continues one. The runner exposes this three ways (all live-validated):
--resume-session ID— send this prompt as the NEXT turn of a named session. The explicit, non-racy form for chaining multi-turn workflows across runner invocations (each run's banner printssession id: <uuid>; capture it from your log).--resume-last— resume the most recently STARTED session, resolved from the session-start timestamp embedded in the rollout FILENAME (deliberately NOT the file mtime — mtimes get refreshed by unrelated touches and were observed live to select the wrong session). Still RACY if other codex runs start sessions concurrently; prefer--resume-session IDin parallel workflows.--resume-on-retry— opt-in crash recovery: when an attempt fails, the runner extracts THIS run's session id from the codex banner, and every subsequent retry RESUMES that session with a short auto-continue prompt instead of restarting the whole task from scratch — a long run keeps its partial progress across transient failures. Falls back to the normal fresh restart when no id was captured.
Caveats: the resume subcommand does not accept --sandbox or --profile — the runner preserves
the sandbox via the equivalent -c sandbox_mode="..." config override and DROPS a --profile with
a warning. A resumed turn appends to the session permanently; do not resume clean-room review
sessions whose independence you need to preserve.
Options
| Flag | Default | Description |
--model MODEL | (from config.toml) | Model override (e.g. o3, gpt-4.1) |
--system-prompt-file FILE | (none) | Optional system instructions file |
--prompt-file FILE | required | User prompt file |
--out PATH | required | Output file for agent's last message (overwritten on every invocation — see Notes; keep deliverables in separate files) |
--sandbox MODE | read-only | Sandbox policy: read-only, workspace-write, danger-full-access |
--profile PROFILE | (none) | Config profile from config.toml |
--config KEY=VALUE | (none) | Repeatable -c overrides for config.toml values |
--skip-git-repo-check | enabled | Run outside git repos (disable with --no-skip-git-repo-check) |
--max-retries N | 6 | Maximum retry attempts |
--sleep-secs S | 10 | Base sleep for exponential backoff |
--resume-session ID | (none) | Send the prompt as the next turn of a named codex session |
--resume-last | off | Resume the most recently started session (filename-timestamp resolution; racy under concurrency) |
--resume-on-retry | off | On a failed attempt, resume this run's own session on retries instead of restarting |
--dry-run | off | Print planned command without executing |
Dry-run example
SKILL_DIR="${SKILL_DIR:-$(for r in "${CLAUDE_CONFIG_DIR:-$HOME/.claude}" "${CODEX_HOME:-$HOME/.codex}" "$HOME/.config/opencode" "$HOME/.kimi-code"; do [ -d "$r/skills/codex-cli-runner" ] && echo "$r/skills/codex-cli-runner" && break; done || true)}"
bash "${SKILL_DIR}/scripts/run_codex.sh" \
--model o3 \
--prompt-file /path/to/prompt.txt \
--out /path/to/output.txt \
--dry-runSandbox modes
read-only(default): Agent can read files but not modify them. Best for text generation, analysis, review. This default is enforced — the runner never sends--full-auto, so it is not silently upgraded toworkspace-write.workspace-write: Agent can modify files in the working directory. Use for code generation tasks.danger-full-access: No restrictions. Use only in externally sandboxed environments.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

