codex

A command that sends the current coding problem and Claude’s proposed solution to OpenAI’s Codex command-line tool for review.

In plain words
What is it for?
Use it to compare designs, investigate errors, evaluate alternatives, and find a simpler or more maintainable implementation.
Why use it?
It provides an additional technical opinion without requiring you to assemble the project context yourself. Codex can challenge the current approach and identify trade-offs or risks.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/jerrylalala/compound-engineering/codex
Clone the repo
git clone --depth 1 https://github.com/Jerrylalala/compound-engineering
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 915 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00016 $0.00915
Opus 5 $0.00008 $0.00458
Sonnet 5 $0.00003 $0.00183
Haiku 4.5 $0.00002 $0.00092

Measured 2d ago against content hash d563363f852b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

codex scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

- 沙箱权限 → 确保 ~/.codex/config.toml 中 [windows] sandbox = "elevated"
plugins/compound-engineering/commands/codex.md · 107 lines

What it actually says

Codex 上下文感知咨询

向 Codex 寻求当前问题的更优方案。核心目的:挑战现有方案,寻找最优解

Step 1: 构建结构化 prompt

分析当前对话上下文,智能构建 prompt。必须附上 Claude 当前方案供 Codex 评判。

## 项目背景
[技术栈、框架]

## 当前问题
[从对话中提取的问题描述]

## 相关代码
[关键代码片段,标注文件路径和行号]

## 错误信息(如有)
[错误日志/堆栈]

## 当前方案(Claude 的建议)
[Claude 已给出的方案]

## 需要你回答的问题
$ARGUMENTS

## 请特别评估
1. 当前方案是否是最优解?如果不是,更好的方案是什么?
2. 有没有我们忽略的替代方案或开源库?
3. 性价比方面:是否存在更简洁、更高效的实现方式?
4. 有没有潜在的坑或者长期维护风险?

只包含与问题相关的上下文,不要倾倒整个对话。

Step 2: 调用 Codex CLI

使用 heredoc 避免特殊字符问题,通过 codex exec 非交互模式调用:

模型策略:本项目统一使用 gpt-5.4(Codex 当前最新模型)。 不使用 gpt-4.1 等旧版本(ChatGPT 账户不支持)。 如需覆盖:export CODEX_MODEL=gpt-5.4(保持默认即可)。

CODEX_OUTPUT="${TEMP:-/tmp}/codex-ask-$(date +%s).md"
# 不指定 model 参数,使用 Codex 默认(当前为 gpt-5.4)
# 如需显式指定:codex exec -c "model=${CODEX_MODEL:-gpt-5.4}" ...
cat <<'PROMPT_EOF' | codex exec --output-last-message "$CODEX_OUTPUT" -
<构建好的prompt>
PROMPT_EOF
echo "---EXIT_CODE: $?---"
cat "$CODEX_OUTPUT" 2>/dev/null

使用 Bash 工具执行,设置 300 秒超时。

$CODEX_OUTPUT 文件读取 Codex 的回答。

如果失败

  • 模型不支持 → 检查 codex --version,运行 npm update -g @openai/codex 升级
  • 显式指定模型(当需要覆盖时):codex exec -c "model=gpt-5.4" ...
  • 未安装 → 提示:npm install -g @openai/codex
  • 网络/认证问题 → 运行 codex login 重新认证
  • 沙箱权限 → 确保 ~/.codex/config.toml 中 [windows] sandbox = "elevated"
  • 输出文件不存在 → Codex 可能未正常返回,建议重试
  • 运行 /workflows:doctor 进行完整健康检查

Step 3: 综合回答

## Codex 的方案
[Codex 的完整回答]

disable-model-invocation: true
---

## 方案对比与最优解分析

### 是否有更优方案?
[基于 Codex 反馈判断]

### 性价比评估
[实现复杂度、维护成本、性能]

### 两方一致的观点
- [共识要点,可信度更高]

### 分歧与取舍(如有)
- [各自理由和适用场景]

### 最终建议
[综合两方观点的最优解推荐]

如果 Codex 提出了更好的方案,诚实承认并推荐采纳。不为面子辩护,只看方案本身的优劣。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 107 lines · 16 tokens per session scan B d563363f852b

Subscribe to this mod's changes

codex is a command published in the GitHub repository Jerrylalala/compound-engineering (5 stars, last pushed 3mo ago), licensed MIT. It adds 16 tokens to every session and 915 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.