当前位置: 首页 > Skill >

Codex Sub Agents 1

Codex Sub Agents 1

1.0.1 2026.11.26 浏览:907
获取Skill文件查看使用说明
作者:沈安许可证:
本文目录展开

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

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

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

  1. Start with /init to create AGENTS.md with repo-specific instructions
  2. Use /review before commits for AI code review
  3. Set /approvals appropriately — Auto for trusted repos, Read Only for exploration
  4. Use --add-dir for monorepos instead of danger-full-access
  5. Resume sessions to maintain context across coding sessions
  6. 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

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 CLI Overview
  • Codex CLI Features
  • Codex CLI Reference
  • Slash Commands Guide
  • AGENTS.md Spec
  • Codex GitHub

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,013
Skill 文件
  • SKILL.md
    • OpenAI Codex CLI Skill
    • When to Use
    • Installation & Auth
    • Core Commands
      • Interactive Mode (TUI)
      • Non-Interactive (Scripting)
      • Session Management
    • Slash Commands (In TUI)
    • Approval Modes
    • Key Flags
    • Clawdbot Integration Patterns
      • Pattern 1: Direct exec Tool
      • Pattern 2: Subagent Delegation
      • Pattern 3: CLI Backend Fallback
      • Pattern 4: MCP Server Mode
    • Clawdbot Config: OpenAI Codex Provider
    • Code Review Workflow
    • Multi-Directory Projects
    • Custom Slash Commands
    • MCP Integration
    • Web Search
    • Best Practices
    • Example Workflows
      • Fix CI Failure
      • Refactor Component
      • Implement Feature from Spec
      • Code Review PR
    • Troubleshooting
    • References
  • 项目或源文件

相关 Skill

更多
OpenAI Codex Sub Agents OpenAI Codex Sub Agents 使用 OpenAI Codex CLI 处理编码任务。触发词:codex、code review、fix CI、refactor code、implement feature、coding agent、gpt-5-codex。Clawdbot 可将编码工作委托给 Codex CLI 作为子代理或直接工具。
claude-code-review claude-code-review Workflow-backed code review — 多角度发现者 + 按位置独立验证 + 合成报告
cr skill cr skill Review pull requests, code diffs, and changed files for correctness, regression risk, security issues, maintainability, and missing tests. Use when the user asks for code review, PR review, review comments, risk assessment, merge readiness, or wants findings prioritized by severity.
Coding Agent (Claude Print + PTY Rules) Coding Agent (Claude Print + PTY Rules) 通过后台进程将编码任务委托给 Codex、Claude Code 或 Pi 代理。适用场景:(1) 构建/创建新功能或应用,(2) 审查 PR(原文不完整)
project-lifecycle-navigator project-lifecycle-navigator Bilingual EN/ZH project lifecycle navigator for non-technical users and AI Coding Agent workflows. Use when a user is starting a new software/AI project, feels a project is drifting mid-development, or has code ready for review. Routes into New Project Intake, Mid-Project Realignment, or Code Review & Upgrade Planning with structured questions, MVP control, stop-loss decisions, and executable handoff plans.