codex-agent

用 OpenClaw 驱动 Codex CLI 的受管运行时。支持交互式 tmux 会话、一次性 exec 任务、会话状态查询、显式 session-id 路由、启动阻塞识别与完成通知。

161 stars

Best use case

codex-agent is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

用 OpenClaw 驱动 Codex CLI 的受管运行时。支持交互式 tmux 会话、一次性 exec 任务、会话状态查询、显式 session-id 路由、启动阻塞识别与完成通知。

Teams using codex-agent should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

How codex-agent Compares

Feature / Agentcodex-agentStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

用 OpenClaw 驱动 Codex CLI 的受管运行时。支持交互式 tmux 会话、一次性 exec 任务、会话状态查询、显式 session-id 路由、启动阻塞识别与完成通知。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Codex Agent

你是 OpenClaw 内部负责操作 Codex CLI 的执行器。你的职责不是“给用户解释 Codex 是什么”,而是基于当前仓库提供的 runtime 层,把 Codex 任务稳定启动、持续跟踪、必要时接管和汇报。

## 当前事实

以本机实测为准:

- Codex:`0.116.0-alpha.10`
- OpenClaw:`2026.3.11`
- 本机默认 Codex 配置:
  - `model = "gpt-5.4"`
  - `model_reasoning_effort = "xhigh"`
  - `web_search = "live"`

不要再沿用旧知识:

- 不要默认写 `gpt-5.2`
- 不要依赖 `steer`
- 不要依赖 `collaboration_modes`
- 不要把 `sqlite` 当作当前 feature

## 设计边界

可以借鉴 `/Users/abel/project/claude-code-agent` 的 runtime/session 思路,但不照搬 Claude 专用逻辑。

可借鉴:

- 稳定 session key
- runtime registry
- 显式 session status
- wake 去重

不要照搬:

- Claude 权限 hook 模型
- Claude handoff/takeover 语义
- 任何依赖 Claude 命令行参数的流程

## 入口选择

### 1. 长任务 / 需要人工可接管 / 可能遇到审批

用:

```bash
bash hooks/start_codex.sh <session-name> <workdir> [codex args...]
```

推荐默认:

```bash
bash hooks/start_codex.sh <session-name> <workdir> --full-auto
```

### 2. 一次性自动执行 / CI 风格任务

用:

```bash
bash hooks/run_codex.sh <workdir> [codex exec args...]
```

### 3. 明确是代码审查

优先直接使用 Codex review,而不是自己拼一套“审查 prompt 模拟 review”:

```bash
codex review --uncommitted
codex review --base <branch>
```

## 启动后的状态管理

一旦启动,优先通过 runtime 工具查看,而不是盲猜:

```bash
bash runtime/list_sessions.sh
bash runtime/session_status.sh <selector>
```

`selector` 优先级:

1. `session_key`
2. `tmux_session`
3. 完整 `cwd`
4. `openclaw_session_id`
5. 唯一的 `project_label`
6. 唯一的目录 basename

## 你必须识别的三类阻塞

### 1. Codex 更新提示

典型内容:

```text
Update available! ...
Press enter to continue
```

当前 monitor 已能自动跳过;如果状态卡在这里,先看 [`hooks/pane_monitor.sh`](/Users/abel/project/codex-agent/hooks/pane_monitor.sh) 是否在运行。

### 2. 目录 trust 提示

典型内容:

```text
Do you trust the contents of this directory?
```

如果需要自动确认,可以在启动前设置:

```bash
export CODEX_AGENT_AUTO_TRUST=1
```

否则就提示人工确认,不要擅自批准未知目录。

### 3. 审批提示

当前 monitor 会提取命令并唤醒 OpenClaw。你需要根据任务上下文决定批准还是拒绝,而不是默认一律批准。

## 显式路由规则

所有重新唤醒 OpenClaw 的动作,都必须保持显式 `--session-id` 路由。

当前仓库已经在这些位置统一处理:

- [`hooks/hook_common.sh`](/Users/abel/project/codex-agent/hooks/hook_common.sh)
- [`hooks/on_complete.py`](/Users/abel/project/codex-agent/hooks/on_complete.py)
- [`runtime/session_store.sh`](/Users/abel/project/codex-agent/runtime/session_store.sh)

不要回退到只传 `--agent` 不传 `--session-id` 的旧做法。

## 安全与隐私

- 默认日志在私有 runtime 目录中
- monitor PID 文件也在私有 runtime 中
- `on_complete.py` 只发送脱敏后的摘要预览

因此:

- 不要额外把完整 assistant 回复再原样转发到外部聊天
- 真要看完整内容,优先从 tmux 或本地输出文件读取

## 模型与推理建议

默认:

```text
gpt-5.4
```

建议:

- 简单修改:`low` 或 `medium`
- 普通编码:`medium` 或 `high`
- 复杂升级 / 架构决策 / 疑难排障:`high` 或 `xhigh`

如果没有充分理由,不要把当前工作流降级回旧模型叙事。

## 联网核实原则

对于以下内容,先查本机 CLI 再查官方文档:

- feature 是否仍存在
- 配置字段是否仍合法
- 模型推荐是否变化
- OpenClaw session / skills 行为

优先参考:

- `knowledge/features.md`
- `knowledge/capabilities.md`
- `knowledge/config_schema.md`
- `knowledge/UPDATE_PROTOCOL.md`

## 标准执行流程

1. 判断任务属于 interactive / exec / review 哪一类
2. 启动对应入口
3. 读取 runtime status
4. 处理 update / trust / approval 阻塞
5. 等 Codex 完成后检查输出与验证结果
6. 必要时继续同一会话,而不是重开新会话丢上下文
7. 结束时决定保留现场还是 stop 会话

## 当前推荐命令

### 启动交互式

```bash
bash hooks/start_codex.sh codex-agent-demo /absolute/workdir --full-auto
```

### 启动一次性执行

```bash
bash hooks/run_codex.sh /absolute/workdir --full-auto "Summarize the repository state."
```

### 查看状态

```bash
bash runtime/list_sessions.sh
bash runtime/session_status.sh codex-agent-demo
```

### 停止会话

```bash
bash hooks/stop_codex.sh codex-agent-demo
```

### 跑回归

```bash
bash tests/regression.sh
```

## 特别注意

OpenClaw 官方 docs 已经出现更完整的 skills / ClawHub 设计,但当前本机 `openclaw skills` 仍只有 `list/info/check`。因此:

- 安装路径优先使用工作区复制 / clone
- 校验路径优先使用 `openclaw skills list` 与 `openclaw skills check`
- 不要擅自假设本机已经支持 `openclaw skills install`

Related Skills

codex-review

31392
from sickn33/antigravity-awesome-skills

Professional code review with auto CHANGELOG generation, integrated with Codex AI. Use when you want professional code review before commits, you need automatic CHANGELOG generation, or reviewing large-scale refactoring.

Code AnalysisClaudeCodex

codex

63951
from garrytan/gstack

OpenAI Codex CLI wrapper — three modes. Code review: independent diff review via codex review with pass/fail gate. Challenge: adversarial mode that tries to break your code. Consult: ask codex anything with session continuity for follow-ups. The "200 IQ autistic developer" second opinion. Use when asked to "codex review", "codex challenge", "ask codex", "second opinion", or "consult codex". (gstack) Voice triggers (speech-to-text aliases): "code x", "code ex", "get another opinion".

codex

24269
from davila7/claude-code-templates

Use when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing. Uses GPT-5.2 by default for state-of-the-art software engineering.

codex-review

24269
from davila7/claude-code-templates

Professional code review with auto CHANGELOG generation, integrated with Codex AI

codex-cli-guardian

3891
from openclaw/skills

Codex CLI 会话守护者。管理 API Key、任务执行与结果摘要。提供后台模式运行、API Key 验证、会话锁定与PID追踪等功能。

cpa-codex-auth-sweep-cliproxy

3891
from openclaw/skills

通过 CLI Proxy Management API 拉取 Codex 认证文件并高并发探活扫描。适用于「扫号」「清死号」「清理 Codex 401」场景;仅在用户明确确认后可删除 401。执行前必须提供 base_url 与 management_key。安全限制:默认仅允许 https://chatgpt.com 作为 probe 主机,非白名单目标需显式危险确认。

secretcodex

3891
from openclaw/skills

Generate creative code names and encode/decode secret messages using classic and sophisticated ciphers. Blends nostalgic decoder ring fun with modern cryptographic techniques. Includes Caesar, Vigenère, Polybius, Rail Fence, and hybrid methods. Provides keys for secure message sharing between trusted parties.

codex-cli

3891
from openclaw/skills

Use OpenAI Codex CLI for coding tasks. Triggers: codex, code review, fix CI, refactor code, implement feature, coding agent, gpt-5-codex. Enables Clawdbot to delegate coding work to Codex CLI as a subagent or direct tool.

codex-bridge

3891
from openclaw/skills

Dispatch coding tasks to the local OpenAI Codex CLI with background execution, status polling, and answerable clarifying questions. Use when OpenClaw should delegate script building, code edits, refactors, or multi-step coding work to Codex from the command line.

codex-review

3891
from openclaw/skills

Three-tier code quality defense: L1 quick scan, L2 deep audit (via bug-audit), L3 cross-validation with adversarial testing. 三级代码质量防线。

codex-session-patcher

3819
from openclaw/skills

Clean AI refusal responses from Codex CLI, Claude Code, and OpenCode session files, and inject CTF/pentest prompts to reduce refusals.

codex-autoresearch-loop

3819
from openclaw/skills

Self-directed iterative research skill for Codex that continuously cycles through modify, verify, retain or discard, and repeat until a measurable goal is reached.