codex
Delegate coding to OpenAI Codex CLI (features, PRs).
What this skill does
# Codex CLI Delegate coding tasks to [Codex](https://github.com/openai/codex) via the Hermes terminal. Codex is OpenAI's autonomous coding agent CLI. ## When to use - Building features - Refactoring - PR reviews - Batch issue fixing Requires the codex CLI and a git repository. ## Prerequisites - Codex installed: `npm install -g @openai/codex` - OpenAI auth configured: either `OPENAI_API_KEY` or Codex OAuth credentials from the Codex CLI login flow - **Must run inside a git repository** — Codex refuses to run outside one - Use `pty=true` in terminal calls — Codex is an interactive terminal app For Hermes itself, `model.provider: openai-codex` uses Hermes-managed Codex OAuth from `~/.hermes/auth.json` after `hermes auth add openai-codex`. For the standalone Codex CLI, a valid CLI OAuth session may live under `~/.codex/auth.json`; do not treat a missing `OPENAI_API_KEY` alone as proof that Codex auth is missing. ## One-Shot Tasks ``` terminal(command="codex exec 'Add dark mode toggle to settings'", workdir="~/project", pty=true) ``` For scratch work (Codex needs a git repo): ``` terminal(command="cd $(mktemp -d) && git init && codex exec 'Build a snake game in Python'", pty=true) ``` ## Background Mode (Long Tasks) ``` # Start in background with PTY terminal(command="codex exec --full-auto 'Refactor the auth module'", workdir="~/project", background=true, pty=true) # Returns session_id # Monitor progress process(action="poll", session_id="<id>") process(action="log", session_id="<id>") # Send input if Codex asks a question process(action="submit", session_id="<id>", data="yes") # Kill if needed process(action="kill", session_id="<id>") ``` ## Key Flags | Flag | Effect | |------|--------| | `exec "prompt"` | One-shot execution, exits when done | | `--full-auto` | Sandboxed but auto-approves file changes in workspace | | `--yolo` | No sandbox, no approvals (fastest, most dangerous) | | `--sandbox danger-full-access` | No Codex sandbox; useful when the host service context breaks bubblewrap | ## Hermes Gateway Caveat When invoking the Codex CLI from a Hermes gateway/service context (for example, Telegram-driven agent sessions), Codex `workspace-write` sandboxing may fail even when the same command works in the user's interactive shell. A typical symptom is bubblewrap/user-namespace errors such as `setting up uid map: Permission denied` or `loopback: Failed RTM_NEWADDR: Operation not permitted`. In that context, prefer: ``` codex exec --sandbox danger-full-access "<task>" ``` Use process boundaries as the safety layer instead: explicit `workdir`, clean git status before launch, narrow task prompts, `git diff` review, targeted tests, and human/agent confirmation before committing broad changes. ## PR Reviews Clone to a temp directory for safe review: ``` terminal(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) ``` ## Parallel Issue Fixing with Worktrees ``` # Create worktrees terminal(command="git worktree add -b fix/issue-78 /tmp/issue-78 main", workdir="~/project") terminal(command="git worktree add -b fix/issue-99 /tmp/issue-99 main", workdir="~/project") # Launch Codex in each terminal(command="codex --yolo exec 'Fix issue #78: <description>. Commit when done.'", workdir="/tmp/issue-78", background=true, pty=true) terminal(command="codex --yolo exec 'Fix issue #99: <description>. Commit when done.'", workdir="/tmp/issue-99", background=true, pty=true) # Monitor process(action="list") # After completion, push and create PRs terminal(command="cd /tmp/issue-78 && git push -u origin fix/issue-78") terminal(command="gh pr create --repo user/repo --head fix/issue-78 --title 'fix: ...' --body '...'") # Cleanup terminal(command="git worktree remove /tmp/issue-78", workdir="~/project") ``` ## Batch PR Reviews ``` # Fetch all PR refs terminal(command="git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'", workdir="~/project") # Review multiple PRs in parallel terminal(command="codex exec 'Review PR #86. git diff origin/main...origin/pr/86'", workdir="~/project", background=true, pty=true) terminal(command="codex exec 'Review PR #87. git diff origin/main...origin/pr/87'", workdir="~/project", background=true, pty=true) # Post results terminal(command="gh pr comment 86 --body '<review>'", workdir="~/project") ``` ## Rules 1. **Always use `pty=true`** — Codex is an interactive terminal app and hangs without a PTY 2. **Git repo required** — Codex won't run outside a git directory. Use `mktemp -d && git init` for scratch 3. **Use `exec` for one-shots** — `codex exec "prompt"` runs and exits cleanly 4. **`--full-auto` for building** — auto-approves changes within the sandbox 5. **Background for long tasks** — use `background=true` and monitor with `process` tool 6. **Don't interfere** — monitor with `poll`/`log`, be patient with long-running tasks 7. **Parallel is fine** — run multiple Codex processes at once for batch work
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.