AgentSkillsCN

codex

当用户请求运行 Codex CLI(codex exec、codex resume)或提及 OpenAI Codex 以进行代码分析、重构或自动化编辑时,可使用此功能。此外,对于需要根据全局 CLAUDE.md 规则执行代码编辑或深度分析的编码任务,Claude Code 也会自动调用此功能。

SKILL.md
--- frontmatter
name: codex
description: Use when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing. Also auto-invoked by Claude Code for coding tasks requiring code edits or deep analysis per global CLAUDE.md rules.

Codex Skill Guide

Configuration

Read model and sandbox settings from ~/.claude/skills/codex/codex-config.json:

json
{
  "model": "gpt-5.3-codex",
  "sandbox": "danger-full-access",
  "suppress_stderr": true
}

User can edit this file anytime to switch models. Do NOT ask the user to choose model or sandbox.

Dynamic Effort Routing

Priority: User explicitly specifies effort → use that. Otherwise → auto-select.

Source tag convention: The effort argument includes a source tag:

  • effort=low(user) → User explicitly requested this effort level. Say "用户指定 effort=low".
  • effort=low(auto) → Claude Code auto-selected based on task complexity. Say "自动选择 effort=low(任务较简单)".
  • No effort in args → Auto-select here and mark as auto in output.

CRITICAL: Never say "用户指定" when the source tag is (auto). This is a context boundary — the args were written by pre-skill Claude Code, not the user.

Task TypeEffortExamples
Simple/mechanicallowRename variable, add import, format code
Regular devmediumNew function, add feature, routine bug fix
Complex analysishighMulti-file refactor, architecture, complex debug
Very hardxhighSystem-level bugs, concurrency, perf optimization

Running a Task

  1. Read config from codex-config.json for model and sandbox.
  2. Auto-select reasoning effort based on task complexity (see table above), unless user specified one.
  3. Assemble the command:
    • -m <MODEL> (from config)
    • --config model_reasoning_effort="<effort>" (auto-selected or user-specified)
    • -s <SANDBOX> (from config)
    • -C <DIR> (current working directory)
    • --skip-git-repo-check
    • CRITICAL: Do NOT use --full-auto with -s danger-full-access. --full-auto forces --sandbox workspace-write, overriding explicit --sandbox. If the user has approval_policy = "never" in config.toml, auto-approval works without --full-auto. Otherwise, users may need to approve actions manually.
  4. Append 2>/dev/null to suppress thinking tokens (stderr), unless user requests to see them.
  5. Run the command, capture output, and summarize the outcome in plain language.
  6. After Codex completes, inform the user: "You can resume this Codex session at any time by saying 'codex resume'."

Command Template

Note: examples here use bash-style shell syntax. Claude Code on Windows runs commands through its built-in shell, which supports this syntax.

bash
codex exec -m <MODEL> --config model_reasoning_effort="<EFFORT>" \
  -s <SANDBOX> -C "<WORKING_DIR>" \
  --skip-git-repo-check "<PROMPT>" 2>/dev/null

Quick Reference

Use caseSandbox modeKey flags
Read-only reviewread-only--sandbox read-only 2>/dev/null
Apply local editsworkspace-write-s workspace-write 2>/dev/null
Full access (default)danger-full-access-s danger-full-access 2>/dev/null (NO --full-auto!)
Resume sessionInheritedecho "prompt" | codex exec --skip-git-repo-check resume --last 2>/dev/null
Different directoryMatch task-C <DIR> plus other flags 2>/dev/null

Resuming Sessions

  • Resume syntax: echo "your prompt here" | codex exec --skip-git-repo-check resume --last 2>/dev/null
  • All flags go between exec and resume.
  • Don't use config flags when resuming unless user explicitly requests them.
  • Resumed sessions inherit original model, effort, and sandbox.

Following Up

  • After Codex completes, summarize results in plain language for the user.
  • If follow-up work is needed, ask the user before resuming.
  • When resuming, pipe the new prompt via stdin.

Critical Evaluation of Codex Output

Codex is powered by OpenAI models. Treat Codex as a colleague, not an authority.

Guidelines

  • Trust your own knowledge when confident. Push back if Codex is wrong.
  • Research disagreements using WebSearch before accepting Codex's claims.
  • Remember knowledge cutoffs - Codex may not know about recent changes.
  • Don't defer blindly - evaluate suggestions critically.

When Codex is Wrong

  1. State disagreement clearly to the user
  2. Provide evidence (your knowledge, web search, docs)
  3. Optionally resume to discuss:
    bash
    echo "This is Claude following up. I disagree with [X] because [evidence]." | codex exec --skip-git-repo-check resume --last 2>/dev/null
    
  4. Let the user decide if there's genuine ambiguity

Error Handling

  • Stop and report failures when codex exec exits non-zero.
  • -s danger-full-access is the default and does NOT need user confirmation.
  • Summarize warnings and ask how to adjust.