AGENT SKILL
Codex 编码任务委派
codex
将编码任务(功能开发、PR)委派给 OpenAI Codex CLI。
- License 许可
- MIT
- 最近更新
- 2026-11-06
- Stars
- ★ 5
- Forks
- 4
01 前言 Front Matter
- name
- codex
- author
- Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "Coding-Agent", "Codex", "OpenAI", "Code-Review", "Refactoring" ], "related_skills": [ "claude-code", "hermes-agent", "hermes-opencode-linear-build", "opencode-http-coding-workflow" ] } }
- description
- Delegate coding to OpenAI Codex CLI (features, PRs).
03 SKILL.md 正文
Codex CLI
Delegate coding tasks to Codex via the Hermes terminal. Codex is OpenAI's autonomous coding agent CLI.
When to use
- Building features
- Refactoring
- PR reviews
- Batch issue fixing
- Prefer this maintained Codex path (or maintained Pi) for Aaron's repo work. Use compatibility-only
hermes-opencode-linear-buildonly when Aaron explicitly requests it and its OpenCode command plus both helpers pass preflight; while active, that command owns review orchestration. Codex CLI v0.128.0 no longer accepts the older-a/--ask-for-approvalflag; use-s read-onlyfor read-only reviews and rely on the default non-interactiveapproval: neverbehavior shown bycodex exec.
Requires the codex CLI and a git repository.
Prerequisites
- Codex installed:
npm install -g @openai/codex - OpenAI API key configured
- On Aaron's macOS/Hermes setup, if Codex returns
401 Unauthorized/ missing authentication from a plain invocation, retry through the user's interactive login shell:HOME=/Users/anichols zsh -lic 'cd <repo> && codex exec ...'. This can expose the configured auth environment that non-login Hermes shells miss. - Must run inside a git repository — Codex refuses to run outside one
- Use
pty=truein terminal calls for interactive sessions.codex execis non-interactive, but on Aaron's setup a PTY/login shell may still be useful when auth environment is not visible.
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. Use workspace-write for autonomous repo-local work; current Codex exec defaults to non-interactive approval: never.
terminal(command="codex exec -s workspace-write 'Refactor the auth module'", workdir="~/project", background=true, notify_on_complete=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 (verified with codex-cli 0.128.0)
| Flag | Effect |
|---|---|
exec "prompt" |
One-shot/non-interactive execution, exits when done |
-C, --cd <DIR> |
Set Codex's working root |
| `-s, --sandbox read-only | workspace-write |
--dangerously-bypass-approvals-and-sandbox |
No sandbox/no approvals; avoid unless the environment is externally sandboxed |
--output-last-message <FILE> / -o <FILE> |
Write the final agent message to a file; useful for review artifacts |
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 exec -s workspace-write 'Fix issue #78: <description>. Commit when done.'", workdir="/tmp/issue-78", background=true, notify_on_complete=true)
terminal(command="codex exec -s workspace-write 'Fix issue #99: <description>. Commit when done.'", workdir="/tmp/issue-99", background=true, notify_on_complete=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
- Use
execfor one-shots —codex exec "prompt"runs non-interactively and exits cleanly - Git repo required by default — Codex won't run outside a git directory unless
--skip-git-repo-checkis supplied. Usemktemp -d && git initfor scratch repo work - Prefer repo-local autonomy — for supervised implementation use
-s workspace-write; avoid danger-full-access unless explicitly needed - Background for long tasks — use
background=true,notify_on_complete=true, and monitor withprocess - PTY is mainly for the interactive TUI — use
pty=truefor interactivecodexsessions;codex execis non-interactive and usually does not need PTY - Don't interfere — monitor with
poll/log, be patient with long-running tasks - Parallel is fine — run multiple Codex processes at once for batch work
04 同仓库更多 Skills
网页抓取受阻恢复
blocked-page-recovery
当抓取失败时使用:403/429 状态码、付费墙(paywall)、WAF、机器人验证墙(bot wall)。
★ 5
软件实施计划编写
writing-plans
在创建或更新可执行的软件计划时使用。除非用户明确要求将计划注册到 Doct,否则请将计划保留为本地文件。
★ 5
测试驱动开发
test-driven-development
TDD:强制执行「红-绿-重构」(RED-GREEN-REFACTOR)循环,先写测试再写代码。
★ 5
系统化根因调试
systematic-debugging
四阶段根因调试:先理解缺陷,再着手修复。
★ 5
技术预研验证
spike
在正式构建前,通过一次性(可丢弃的)实验来验证某个想法。
★ 5
代码变更并行清理精简
simplify-code
并行使用 3 个智能体(agent)对近期代码变更进行清理精简。
★ 5