{"success":true,"name":"codex","description":"Delegate coding to OpenAI Codex CLI (features, PRs).","category":"autonomous-ai-agents","path":"autonomous-ai-agents/codex/SKILL.md","file":"SKILL.md","content":"---\nname: codex\ndescription: \"Delegate coding to OpenAI Codex CLI (features, PRs).\"\nversion: 1.0.1\nauthor: Hermes Agent\nlicense: MIT\nplatforms: [linux, macos, windows]\nmetadata:\n  hermes:\n    tags: [Coding-Agent, Codex, OpenAI, Code-Review, Refactoring]\n    related_skills: [claude-code, hermes-agent]\n---\n\n# Codex CLI\n\nDelegate coding tasks to [Codex](https://github.com/openai/codex) via the Hermes terminal. Codex is OpenAI's autonomous coding agent CLI.\n\n## When to use\n\n- Building features\n- Refactoring\n- PR reviews\n- Batch issue fixing\n\nRequires the codex CLI and a git repository.\n\n## Prerequisites\n\n- Codex installed: `npm install -g @openai/codex`\n- OpenAI auth configured: either `OPENAI_API_KEY` or Codex OAuth credentials\n  from the Codex CLI login flow\n- **Must run inside a git repository** — Codex refuses to run outside one\n- Use `pty=true` in terminal calls — Codex is an interactive terminal app\n\nFor Hermes itself, `model.provider: openai-codex` uses Hermes-managed Codex\nOAuth from `~/.hermes/auth.json` after `hermes auth add openai-codex`. For the\nstandalone Codex CLI, a valid CLI OAuth session may live under\n`~/.codex/auth.json`; do not treat a missing `OPENAI_API_KEY` alone as proof\nthat Codex auth is missing.\n\n## One-Shot Tasks\n\n```\nterminal(command=\"codex exec 'Add dark mode toggle to settings'\", workdir=\"~/project\", pty=true)\n```\n\nFor scratch work (Codex needs a git repo):\n```\nterminal(command=\"cd $(mktemp -d) && git init && codex exec 'Build a snake game in Python'\", pty=true)\n```\n\n## Background Mode (Long Tasks)\n\n```\n# Start in background with PTY\nterminal(command=\"codex exec --sandbox workspace-write 'Refactor the auth module'\", workdir=\"~/project\", background=true, pty=true)\n# Returns session_id\n\n# Monitor progress\nprocess(action=\"poll\", session_id=\"<id>\")\nprocess(action=\"log\", session_id=\"<id>\")\n\n# Send input if Codex asks a question\nprocess(action=\"submit\", session_id=\"<id>\", data=\"yes\")\n\n# Kill if needed\nprocess(action=\"kill\", session_id=\"<id>\")\n```\n\n## Key Flags\n\n| Flag | Effect |\n|------|--------|\n| `exec \"prompt\"` | One-shot execution, exits when done |\n| `--sandbox workspace-write` (`-s`) | Sandboxed but auto-approves file changes in the workspace (the recommended auto-build mode) |\n| `--dangerously-bypass-approvals-and-sandbox` | No sandbox, no approvals (fastest, most dangerous; `--yolo` still works as a hidden alias) |\n| `--sandbox danger-full-access` | No Codex sandbox; useful when the host service context breaks bubblewrap |\n\n> **Deprecated:** `--full-auto` still works but the live CLI warns to use `--sandbox workspace-write` instead.\n\n## Hermes Gateway Caveat\n\nWhen invoking the Codex CLI from a Hermes gateway/service context (for example,\nTelegram-driven agent sessions), Codex `workspace-write` sandboxing may fail even\nwhen the same command works in the user's interactive shell. A typical symptom is\nbubblewrap/user-namespace errors such as `setting up uid map: Permission denied`\nor `loopback: Failed RTM_NEWADDR: Operation not permitted`.\n\nIn that context, prefer:\n\n```\ncodex exec --sandbox danger-full-access \"<task>\"\n```\n\nUse process boundaries as the safety layer instead: explicit `workdir`, clean git\nstatus before launch, narrow task prompts, `git diff` review, targeted tests, and\nhuman/agent confirmation before committing broad changes.\n\n## PR Reviews\n\nClone to a temp directory for safe review:\n\n```\nterminal(command=\"REVIEW=$(mktemp -d) && git clone https://github.com/user/repo.git $REVIEW && cd $REVIEW && gh pr checkout 42 && codex review --base origin/main\", pty=true)\n```\n\n## Parallel Issue Fixing with Worktrees\n\n```\n# Create worktrees\nterminal(command=\"git worktree add -b fix/issue-78 ~/.hermes/cache/scratch/issue-78 main\", workdir=\"~/project\")\nterminal(command=\"git worktree add -b fix/issue-99 ~/.hermes/cache/scratch/issue-99 main\", workdir=\"~/project\")\n\n# Launch Codex in each\nterminal(command=\"codex --sandbox workspace-write exec 'Fix issue #78: <description>. Commit when done.'\", workdir=\"~/.hermes/cache/scratch/issue-78\", background=true, pty=true)\nterminal(command=\"codex --sandbox workspace-write exec 'Fix issue #99: <description>. Commit when done.'\", workdir=\"~/.hermes/cache/scratch/issue-99\", background=true, pty=true)\n\n# Monitor\nprocess(action=\"list\")\n\n# After completion, push and create PRs\nterminal(command=\"cd ~/.hermes/cache/scratch/issue-78 && git push -u origin fix/issue-78\")\nterminal(command=\"gh pr create --repo user/repo --head fix/issue-78 --title 'fix: ...' --body '...'\")\n\n# Cleanup\nterminal(command=\"git worktree remove ~/.hermes/cache/scratch/issue-78\", workdir=\"~/project\")\n```\n\n## Batch PR Reviews\n\n```\n# Fetch all PR refs\nterminal(command=\"git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'\", workdir=\"~/project\")\n\n# Review multiple PRs in parallel\nterminal(command=\"codex exec 'Review PR #86. git diff origin/main...origin/pr/86'\", workdir=\"~/project\", background=true, pty=true)\nterminal(command=\"codex exec 'Review PR #87. git diff origin/main...origin/pr/87'\", workdir=\"~/project\", background=true, pty=true)\n\n# Post results\nterminal(command=\"gh pr comment 86 --body '<review>'\", workdir=\"~/project\")\n```\n\n## Rules\n\n1. **Always use `pty=true`** — Codex is an interactive terminal app and hangs without a PTY\n2. **Git repo required** — Codex won't run outside a git directory. Use `mktemp -d && git init` for scratch\n3. **Use `exec` for one-shots** — `codex exec \"prompt\"` runs and exits cleanly\n4. **`--sandbox workspace-write` for building** — auto-approves changes within the sandbox (`--full-auto` is deprecated for this)\n5. **Background for long tasks** — use `background=true` and monitor with `process` tool\n6. **Don't interfere** — monitor with `poll`/`log`, be patient with long-running tasks\n7. **Parallel is fine** — run multiple Codex processes at once for batch work\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}