OpenAI Codex Sub Agents — OpenAI Codex Sub 代理s
v1.0.0Use OpenAI Codex 命令行工具 for coding tasks. Triggers: codex, code review, fix CI, refactor code, implement feature, coding 代理, gpt-5-codex. Enables Clawd机器人 to delegate coding work to Codex 命令行工具 as a sub代理 or direct 工具.
运行时依赖
版本
Full 访问 Full machine 访问 including network (use sparingly)
安装命令
点击复制技能文档
OpenAI Codex 命令行工具 技能
Use OpenAI Codex 命令行工具 (codex) for coding tasks including code review, refactoring, bug fixes, CI repAIrs, and feature implementation. Codex 命令行工具 运行s locally on your machine with full file系统 访问.
When to Use User asks for code changes, refactoring, or implementation CI/build 失败s need fixing Code review before commit/push Large codebase exploration or explanation Tasks requiring file editing + command execution When GPT-5-Codex 模型 strengths are needed (code generation, 工具 use) 安装ation & Auth
Codex 命令行工具 requires ChatGPT Plus/Pro/Business/Enterprise subscription.
# 安装 npm i -g @openAI/codex
# 认证 (opens browser for OAuth) codex 记录in
# Or use API key printenv OPENAI_API_KEY | codex 记录in --with-API-key
# 验证 auth codex 记录in 状态
Core Commands Interactive Mode (TUI) codex # Launch interactive terminal UI codex "explAIn this codebase" # 启动 with a prompt codex --cd ~/projects/my应用 # 设置 working directory
Non-Interactive (Scripting) codex exec "fix the CI 失败" # 运行 and exit codex exec --full-auto "添加 输入 验证" # Auto-应用rove workspace writes codex exec --json "列出 all API 端点s" # JSON 输出 for parsing codex exec -i screenshot.png "match this de签名" # With image 输入
会话 Management codex 恢复 # Pick from recent 会话s codex 恢复 --last # Continue most recent codex 恢复 <会话_ID> # 恢复 specific 会话
Slash Commands (In TUI) Command Purpose /模型 Switch 模型 (gpt-5-codex, gpt-5) /应用rovals 设置 应用roval mode (Auto, Read Only, Full 访问) /review Code review agAInst branch, uncommitted changes, or specific commit /diff Show Git diff including un追踪ed files /compact Summarize conversation to free 上下文 /init 生成 代理S.md scaffold /状态 Show 会话 config and 令牌 usage /undo Revert most recent turn /new 启动 fresh conversation /mcp 列出 配置d MCP 工具s /mention Attach file to conversation 应用roval Modes Mode Behavior Auto (default) Read/edit/运行 commands in workspace; asks for outside 访问 Read Only Browse files only; requires 应用roval for changes Full 访问 Full machine 访问 including network (use sparingly) Key Flags Flag Purpose --模型, -m <模型> Override 模型 (gpt-5-codex, gpt-5) --cd, -C 设置 working directory --添加-dir 添加 添加itional writable roots --image, -i Attach image(s) to prompt --full-auto Workspace write + 应用rove on 失败 --sandbox read-only, workspace-write, danger-full-访问 --json 输出 newline-delimited JSON --搜索 Enable 网页 搜索 工具 Clawd机器人 Integration Patterns Pattern 1: Direct exec 工具
Call Codex from Clawd机器人's exec 工具 for coding tasks:
# In Clawd机器人 会话 exec codex exec --full-auto --cd ~/projects/med报告 "fix the TypeScript errors in src/组件s"
Pattern 2: Sub代理 Delegation
Spawn a coding sub代理 that uses Codex:
// In 代理s.defaults or per-代理 config { 代理s: { 列出: [ { id: "coder", workspace: "~/clawd-coder", 模型: "openAI-codex/gpt-5.2", // Uses Codex auth 工具s: { allow: ["exec", "read", "write", "edit", "应用ly_补丁", "process"] } } ] } }
Pattern 3: 命令行工具 Backend Fallback
配置 Codex as a text-only fallback:
{ 代理s: { defaults: { 命令行工具Backends: { "codex-命令行工具": { command: "codex", args: ["exec", "--full-auto"], 输出: "text", 会话Arg: null // Codex manages its own 会话s } } } } }
Pattern 4: MCP Server Mode
运行 Codex as an MCP server for other 代理s:
codex mcp-server # Exposes Codex 工具s via stdio MCP
Clawd机器人 Config: OpenAI Codex 提供者
Use your ChatGPT Pro subscription via the openAI-codex 提供者:
{ 代理s: { defaults: { 模型: { primary: "openAI-codex/gpt-5.2" }, 模型s: { "openAI-codex/gpt-5.2": { alias: "Codex" }, "anthropic/claude-opus-4-5": { alias: "Opus" } } } } }
Auth 同步s automatically from ~/.codex/auth.json to Clawd机器人's auth 性能分析s.
Code Review 工作流 # Interactive review codex /review # Choose: branch, uncommitted, or specific commit
# Non-interactive codex exec "review the changes in this PR agAInst mAIn branch"
Multi-Directory Projects # Work across monorepo packages codex --cd 应用s/frontend --添加-dir ../backend --添加-dir ../分享d
# Or in TUI codex --cd ~/projects/my应用 --添加-dir ~/projects/分享d-lib
Custom Slash Commands
创建 reusable prompts in ~/.codex/prompts/:
description: Prepare and open a draft PR argument-hint: [BRANCH=] [TITLE="