简介
OpenAI 官方本地终端编码智能体,支持代码审查、重构、CI修复与全栈开发,需 ChatGPT Plus/Pro 订阅。
原始描述
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.
通过你的 Agent 添加
安装目录:codex-cli/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Codex CLI Skill 是一套完整的 OpenAI Codex 命令行工具集成文档,旨在帮助 Clawdbot 用户高效调用 GPT-5-codex 模型完成各类编码任务。该 skill 本身为纯文档型,无可执行代码,仅提供标准化的配置指南和命令参考。
三种主要调用模式:
- 直接执行模式 (
codex exec):适合 CI 修复、批量重构等非交互场景,支持--full-auto自动批准工作区写入 - 交互式 TUI 模式:启动终端界面,支持
/review、/diff、/compact等斜杠命令,适合代码审查和复杂对话 - 子代理集成模式:可在 Clawdbot 中配置专用 coder 代理,将 Codex 作为子代理或 MCP 服务器调用
核心功能覆盖:
- 代码审查 (
/review):支持分支对比、未提交变更审查 - 安全沙箱:三级批准模式 (Auto/Read Only/Full Access)
- 多目录项目:通过
--add-dir支持 monorepo 跨包操作 - 会话管理:支持会话恢复、上下文压缩 (
/compact) - MCP 扩展:可接入外部 MCP 服务器扩展能力
- 图像输入:支持设计稿截图转代码实现
显著优点
- 官方权威来源:完整引用 OpenAI 官方文档 (developers.openai.com) 和 GitHub 官方仓库,内容准确性有保障
- 零安全风险:纯 Markdown 文档技能,无脚本、无依赖、无网络调用,扫描评分 S+/98分
- 集成灵活性高:提供 4 种 Clawdbot 集成模式(直接 exec、子代理、CLI 后端、MCP 服务器),适应不同工作流
- 实用配置示例:包含完整的 TOML/JSON 配置模板、自定义斜杠命令示例、多目录项目处理方案
- 隐私合规:无用户数据收集,符合 GDPR/CCPA,仅需标准 ChatGPT Plus/Pro 订阅授权
潜在缺点与局限性
- 订阅门槛:需 ChatGPT Plus/Pro/Business/Enterprise 订阅,免费用户无法使用
- 功能依赖外部工具:skill 本身不包含 Codex CLI 安装包,需用户自行
npm install -g @openai/codex
- 凭证同步注意事项:Clawdbot 集成时会从
~/.codex/auth.json 同步 OAuth token,多机器环境需自行管理凭证安全
- 快速迭代风险:Codex CLI 处于快速发展期,文档可能滞后于最新版本功能
- 网络要求:实际使用 Codex CLI 时需连接 OpenAI API,离线环境不可用
适合人群
- 已订阅 ChatGPT Pro 的开发者,希望将 Codex CLI 与 Clawdbot 工作流打通
- 需要代码审查、CI 修复、批量重构等自动化编码任务的团队
- 使用 monorepo 架构、需要跨目录代码操作的工程团队
- 希望通过 MCP 协议扩展 AI 编码工具链的高级用户
常规风险
风险类型
说明
缓解措施
自动执行风险
--full-auto 模式会自动批准工作区写入,可能产生意外修改
先在只读模式测试,确认后再启用自动模式
凭证泄露
~/.codex/auth.json 包含 OAuth token,同步至 Clawdbot 目录后需确保文件权限
检查 ~/.clawdbot/agents/ 目录权限为 700
上下文溢出
长会话可能导致 token 超限
定期使用 /compact 压缩对话历史
API 费用
GPT-5-codex 模型调用消耗 API 额度
监控 /status 中的 token 使用情况
沙箱边界
Full Access 模式授予完整机器访问权限,包括网络
仅在可信隔离环境使用,默认保持 Auto 模式
使用建议
- 订阅门槛:需 ChatGPT Plus/Pro/Business/Enterprise 订阅,免费用户无法使用
- 功能依赖外部工具:skill 本身不包含 Codex CLI 安装包,需用户自行
npm install -g @openai/codex - 凭证同步注意事项:Clawdbot 集成时会从
~/.codex/auth.json同步 OAuth token,多机器环境需自行管理凭证安全 - 快速迭代风险:Codex CLI 处于快速发展期,文档可能滞后于最新版本功能
- 网络要求:实际使用 Codex CLI 时需连接 OpenAI API,离线环境不可用
适合人群
- 已订阅 ChatGPT Pro 的开发者,希望将 Codex CLI 与 Clawdbot 工作流打通
- 需要代码审查、CI 修复、批量重构等自动化编码任务的团队
- 使用 monorepo 架构、需要跨目录代码操作的工程团队
- 希望通过 MCP 协议扩展 AI 编码工具链的高级用户
常规风险
风险类型
说明
缓解措施
自动执行风险
--full-auto 模式会自动批准工作区写入,可能产生意外修改
先在只读模式测试,确认后再启用自动模式
凭证泄露
~/.codex/auth.json 包含 OAuth token,同步至 Clawdbot 目录后需确保文件权限
检查 ~/.clawdbot/agents/ 目录权限为 700
上下文溢出
长会话可能导致 token 超限
定期使用 /compact 压缩对话历史
API 费用
GPT-5-codex 模型调用消耗 API 额度
监控 /status 中的 token 使用情况
沙箱边界
Full Access 模式授予完整机器访问权限,包括网络
仅在可信隔离环境使用,默认保持 Auto 模式
使用建议
| 风险类型 | 说明 | 缓解措施 |
|---|---|---|
| 自动执行风险 | --full-auto 模式会自动批准工作区写入,可能产生意外修改 |
先在只读模式测试,确认后再启用自动模式 |
| 凭证泄露 | ~/.codex/auth.json 包含 OAuth token,同步至 Clawdbot 目录后需确保文件权限 |
检查 ~/.clawdbot/agents/ 目录权限为 700 |
| 上下文溢出 | 长会话可能导致 token 超限 | 定期使用 /compact 压缩对话历史 |
| API 费用 | GPT-5-codex 模型调用消耗 API 额度 | 监控 /status 中的 token 使用情况 |
| 沙箱边界 | Full Access 模式授予完整机器访问权限,包括网络 |
仅在可信隔离环境使用,默认保持 Auto 模式 |
使用建议
建议首次使用者从交互式 TUI 开始 (codex),熟悉 /approvals、/review 等斜杠命令后再尝试 --full-auto 自动化模式。对于团队环境,推荐配置专用的 coder 子代理并限定 workspace 范围,避免直接暴露 Full Access 权限。
技能正文
name: codex-cli
description: "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."
OpenAI Codex CLI Skill
Use OpenAI Codex CLI (codex) for coding tasks including code review, refactoring, bug fixes, CI repairs, and feature implementation. Codex CLI runs locally on your machine with full filesystem access.
When to Use
- User asks for code changes, refactoring, or implementation
- CI/build failures need fixing
- Code review before commit/push
- Large codebase exploration or explanation
- Tasks requiring file editing + command execution
- When GPT-5-Codex model strengths are needed (code generation, tool use)
Installation & Auth
Codex CLI requires ChatGPT Plus/Pro/Business/Enterprise subscription.
# Install
npm i -g @openai/codex
# Authenticate (opens browser for OAuth)
codex login
# Or use API key
printenv OPENAI_API_KEY | codex login --with-api-key
# Verify auth
codex login status
Core Commands
Interactive Mode (TUI)
codex # Launch interactive terminal UI
codex "explain this codebase" # Start with a prompt
codex --cd ~/projects/myapp # Set working directory
Non-Interactive (Scripting)
codex exec "fix the CI failure" # Run and exit
codex exec --full-auto "add input validation" # Auto-approve workspace writes
codex exec --json "list all API endpoints" # JSON output for parsing
codex exec -i screenshot.png "match this design" # With image input
Session Management
codex resume # Pick from recent sessions
codex resume --last # Continue most recent
codex resume <SESSION_ID> # Resume specific session
Slash Commands (In TUI)
Command
Purpose
/model
Switch model (gpt-5-codex, gpt-5)
/approvals
Set approval mode (Auto, Read Only, Full Access)
/review
Code review against branch, uncommitted changes, or specific commit
/diff
Show Git diff including untracked files
/compact
Summarize conversation to free context
/init
Generate AGENTS.md scaffold
/status
Show session config and token usage
/undo
Revert most recent turn
/new
Start fresh conversation
/mcp
List configured MCP tools
/mention <path>
Attach file to conversation
Approval Modes
Mode
Behavior
Auto (default)
Read/edit/run commands in workspace; asks for outside access
Read Only
Browse files only; requires approval for changes
Full Access
Full machine access including network (use sparingly)
Key Flags
Flag
Purpose
--model, -m <model>
Override model (gpt-5-codex, gpt-5)
--cd, -C <path>
Set working directory
--add-dir <path>
Add additional writable roots
--image, -i <path>
Attach image(s) to prompt
--full-auto
Workspace write + approve on failure
--sandbox <mode>
read-only, workspace-write, danger-full-access
--json
Output newline-delimited JSON
--search
Enable web search tool
Clawdbot Integration Patterns
Pattern 1: Direct exec Tool
codex exec "fix the CI failure" # Run and exit
codex exec --full-auto "add input validation" # Auto-approve workspace writes
codex exec --json "list all API endpoints" # JSON output for parsing
codex exec -i screenshot.png "match this design" # With image input
codex resume # Pick from recent sessions
codex resume --last # Continue most recent
codex resume <SESSION_ID> # Resume specific session
Slash Commands (In TUI)
Command
Purpose
/model
Switch model (gpt-5-codex, gpt-5)
/approvals
Set approval mode (Auto, Read Only, Full Access)
/review
Code review against branch, uncommitted changes, or specific commit
/diff
Show Git diff including untracked files
/compact
Summarize conversation to free context
/init
Generate AGENTS.md scaffold
/status
Show session config and token usage
/undo
Revert most recent turn
/new
Start fresh conversation
/mcp
List configured MCP tools
/mention <path>
Attach file to conversation
Approval Modes
Mode
Behavior
Auto (default)
Read/edit/run commands in workspace; asks for outside access
Read Only
Browse files only; requires approval for changes
Full Access
Full machine access including network (use sparingly)
Key Flags
Flag
Purpose
--model, -m <model>
Override model (gpt-5-codex, gpt-5)
--cd, -C <path>
Set working directory
--add-dir <path>
Add additional writable roots
--image, -i <path>
Attach image(s) to prompt
--full-auto
Workspace write + approve on failure
--sandbox <mode>
read-only, workspace-write, danger-full-access
--json
Output newline-delimited JSON
--search
Enable web search tool
Clawdbot Integration Patterns
Pattern 1: Direct exec Tool
| Command | Purpose |
|---|---|
/model |
Switch model (gpt-5-codex, gpt-5) |
/approvals |
Set approval mode (Auto, Read Only, Full Access) |
/review |
Code review against branch, uncommitted changes, or specific commit |
/diff |
Show Git diff including untracked files |
/compact |
Summarize conversation to free context |
/init |
Generate AGENTS.md scaffold |
/status |
Show session config and token usage |
/undo |
Revert most recent turn |
/new |
Start fresh conversation |
/mcp |
List configured MCP tools |
/mention <path> |
Attach file to conversation |
| Mode | Behavior |
|---|---|
| Auto (default) | Read/edit/run commands in workspace; asks for outside access |
| Read Only | Browse files only; requires approval for changes |
| Full Access | Full machine access including network (use sparingly) |
Key Flags
Flag
Purpose
--model, -m <model>
Override model (gpt-5-codex, gpt-5)
--cd, -C <path>
Set working directory
--add-dir <path>
Add additional writable roots
--image, -i <path>
Attach image(s) to prompt
--full-auto
Workspace write + approve on failure
--sandbox <mode>
read-only, workspace-write, danger-full-access
--json
Output newline-delimited JSON
--search
Enable web search tool
Clawdbot Integration Patterns
Pattern 1: Direct exec Tool
| Flag | Purpose |
|---|---|
--model, -m <model> |
Override model (gpt-5-codex, gpt-5) |
--cd, -C <path> |
Set working directory |
--add-dir <path> |
Add additional writable roots |
--image, -i <path> |
Attach image(s) to prompt |
--full-auto |
Workspace write + approve on failure |
--sandbox <mode> |
read-only, workspace-write, danger-full-access |
--json |
Output newline-delimited JSON |
--search |
Enable web search tool |
Pattern 1: Direct exec Tool
Call Codex from Clawdbot's exec tool for coding tasks:
# In Clawdbot session
exec codex exec --full-auto --cd ~/projects/medreport "fix the TypeScript errors in src/components"
Pattern 2: Subagent Delegation
Spawn a coding subagent that uses Codex:
// In agents.defaults or per-agent config
{
agents: {
list: [
{
id: "coder",
workspace: "~/clawd-coder",
model: "openai-codex/gpt-5.2", // Uses Codex auth
tools: {
allow: ["exec", "read", "write", "edit", "apply_patch", "process"]
}
}
]
}
}
Pattern 3: CLI Backend Fallback
Configure Codex as a text-only fallback:
{
agents: {
defaults: {
cliBackends: {
"codex-cli": {
command: "codex",
args: ["exec", "--full-auto"],
output: "text",
sessionArg: null // Codex manages its own sessions
}
}
}
}
}
Pattern 4: MCP Server Mode
Run Codex as an MCP server for other agents:
codex mcp-server # Exposes Codex tools via stdio MCP
Clawdbot Config: OpenAI Codex Provider
Use your ChatGPT Pro subscription via the openai-codex provider:
{
agents: {
defaults: {
model: { primary: "openai-codex/gpt-5.2" },
models: {
"openai-codex/gpt-5.2": { alias: "Codex" },
"anthropic/claude-opus-4-5": { alias: "Opus" }
}
}
}
}
Auth syncs automatically from ~/.codex/auth.json to Clawdbot's auth profiles.
Code Review Workflow
# 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 apps/frontend --add-dir ../backend --add-dir ../shared
# Or in TUI
codex --cd ~/projects/myapp --add-dir ~/projects/shared-lib
Custom Slash Commands
# Interactive review
codex
/review # Choose: branch, uncommitted, or specific commit
# Non-interactive
codex exec "review the changes in this PR against main branch"
# Work across monorepo packages
codex --cd apps/frontend --add-dir ../backend --add-dir ../shared
# Or in TUI
codex --cd ~/projects/myapp --add-dir ~/projects/shared-lib
Custom Slash Commands
Create reusable prompts in ~/.codex/prompts/:
<!-- ~/.codex/prompts/pr.md -->
---
description: Prepare and open a draft PR
argument-hint: [BRANCH=<name>] [TITLE="<title>"]
---
Create branch `dev/$BRANCH` if specified.
Stage and commit changes with a clear message.
Open a draft PR with title $TITLE or auto-generate one.
Invoke: /prompts:pr BRANCH=feature-auth TITLE="Add OAuth flow"
MCP Integration
Add MCP servers to extend Codex:
# Add stdio server
codex mcp add github -- npx @anthropic/mcp-server-github
# Add HTTP server
codex mcp add docs --url https://mcp.deepwiki.com/mcp
# List configured
codex mcp list
Web Search
Enable in ~/.codex/config.toml:
[features]
web_search_request = true
[sandbox_workspace_write]
network_access = true
Then Codex can search for current docs, APIs, etc.
Best Practices
- Start with
/init to create AGENTS.md with repo-specific instructions
- Use
/review before commits for AI code review
- Set
/approvals appropriately — Auto for trusted repos, Read Only for exploration
- Use
--add-dir for monorepos instead of danger-full-access
- Resume sessions to maintain context across coding sessions
- Attach images for UI work, design specs, error screenshots
Example Workflows
Fix CI Failure
codex exec --full-auto "The CI is failing on the lint step. Fix all ESLint errors."
Refactor Component
/init to create AGENTS.md with repo-specific instructions/review before commits for AI code review/approvals appropriately — Auto for trusted repos, Read Only for exploration--add-dir for monorepos instead of danger-full-accessFix CI Failure
codex exec --full-auto "The CI is failing on the lint step. Fix all ESLint errors."
codex exec --cd src/components "Refactor UserProfile.tsx to use React Query instead of useEffect for data fetching"
Implement Feature from Spec
codex exec -i spec.png --cd ~/projects/app "Implement this feature based on the design spec"
Code Review PR
codex exec "Review the diff between main and feature/auth branch. Focus on security issues."
Troubleshooting
Issue
Solution
Auth fails
Run codex logout then codex login
Commands blocked
Check /approvals, may need --full-auto
Out of context
Use /compact to summarize
Wrong directory
Use --cd flag or check /status
Model unavailable
Verify subscription tier supports model
References
codex exec -i spec.png --cd ~/projects/app "Implement this feature based on the design spec"
codex exec "Review the diff between main and feature/auth branch. Focus on security issues."
Troubleshooting
Issue
Solution
Auth fails
Run codex logout then codex login
Commands blocked
Check /approvals, may need --full-auto
Out of context
Use /compact to summarize
Wrong directory
Use --cd flag or check /status
Model unavailable
Verify subscription tier supports model
References
| Issue | Solution |
|---|---|
| Auth fails | Run codex logout then codex login |
| Commands blocked | Check /approvals, may need --full-auto |
| Out of context | Use /compact to summarize |
| Wrong directory | Use --cd flag or check /status |
| Model unavailable | Verify subscription tier supports model |
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。