codex
Original:🇺🇸 English
Translated
This skill should be used when the user wants to invoke Codex CLI for complex coding tasks requiring high reasoning capabilities. Trigger phrases include "use codex", "ask codex", "run codex", "call codex", "codex cli", "GPT-5 reasoning", "OpenAI reasoning", or when users request complex implementation challenges, advanced reasoning, architecture design, or high-reasoning model assistance. Automatically triggers on codex-related requests and supports session continuation for iterative development.
2installs
Sourcelucklyric/cc-dev-tools
Added on
NPX Install
npx skill4agent add lucklyric/cc-dev-tools codexTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Codex: High-Reasoning AI Assistant for Claude Code
DEFAULT MODEL: Task-Based Model Selection with Read-Only Default
Codex uses task-based model selection. Sandbox is by default - only use when user explicitly requests file editing.
read-onlyworkspace-write| Task Type | Model | Sandbox (default) | Sandbox (explicit edit) |
|---|---|---|---|
| Code-related tasks | | read-only | workspace-write |
| General tasks | | read-only | workspace-write |
- Code-related tasks: Use - optimized for agentic coding (56.8% SWE-Bench Pro)
gpt-5.3-codex - General tasks: Use - high-reasoning general model
gpt-5.2 - Sandbox default: Always unless user explicitly requests editing
read-only - Explicit editing: Only when user says "edit", "modify", "write changes", etc., use
workspace-write - Always use for maximum capability
-c model_reasoning_effort=xhigh
bash
# Code task (read-only default)
codex exec -m gpt-5.3-codex -s read-only \
-c model_reasoning_effort=xhigh \
"analyze this function implementation"
# General task (read-only default)
codex exec -m gpt-5.2 -s read-only \
-c model_reasoning_effort=xhigh \
"explain this architecture"
# Code task with explicit edit request
codex exec -m gpt-5.3-codex -s workspace-write \
-c model_reasoning_effort=xhigh \
"edit this file to add the feature"
# General task with explicit edit request
codex exec -m gpt-5.2 -s workspace-write \
-c model_reasoning_effort=xhigh \
"modify the documentation file"Model Fallback Chain
If the primary model is unavailable, fallback gracefully:
- Code tasks: →
gpt-5.3-codexgpt-5.2 - General tasks: →
gpt-5.2gpt-5.3-codex - Reasoning effort: →
xhigh→highmedium
CRITICAL: Always Use codex exec
codex execMUST USE: for ALL Codex CLI invocations in Claude Code.
codex execNEVER USE: (interactive mode) - will fail with "stdout is not a terminal"
ALWAYS USE: (non-interactive mode)
codexcodex execExamples:
- (CORRECT)
codex exec -m gpt-5.2 "prompt" - (WRONG - will fail)
codex -m gpt-5.2 "prompt" - (CORRECT)
codex exec resume --last - (WRONG - will fail)
codex resume --last
Why? Claude Code's bash environment is non-terminal/non-interactive. Only works in this environment.
codex execIMPORTANT: Interactive vs Exec Mode Flags
Some Codex CLI flags are ONLY available in interactive mode, NOT in .
codex exec| Flag | Interactive | | Alternative for exec |
|---|---|---|---|
| ✅ Available | ❌ NOT available | |
| ✅ Available | ❌ NOT available | |
| ✅ Available | ✅ Available | N/A |
| ✅ Available | ✅ Available | N/A |
For web search in exec mode:
bash
# CORRECT - works in codex exec
codex exec --enable web_search_request "research topic"
# WRONG - --search only works in interactive mode
codex --search "research topic"For approval control in exec mode:
bash
# CORRECT - works in codex exec
codex exec --full-auto "task"
codex exec -c approval_policy=on-request "task"
# WRONG - -a only works in interactive mode
codex -a on-request "task"Trigger Examples
This skill activates when users say phrases like:
- "Use codex to analyze this architecture"
- "Ask codex about this design decision"
- "Run codex on this problem"
- "Call codex for help with this implementation"
- "I need GPT-5 reasoning for this task"
- "Get OpenAI's high-reasoning model on this"
- "Continue with codex" or "Resume the codex session"
- "Codex, help me with..." or simply "Codex"
When to Use This Skill
This skill should be invoked when:
- User explicitly mentions "Codex" or requests Codex assistance
- User needs help with complex coding tasks, algorithms, or architecture
- User requests "high reasoning" or "advanced implementation" help
- User needs complex problem-solving or architectural design
- User wants to continue a previous Codex conversation
How It Works
Detecting New Codex Requests
When a user makes a request, first determine the task type (code vs general), then determine sandbox based on explicit edit request:
Step 1: Determine Task Type (Model Selection)
- Code-related tasks: Use - for implementation, refactoring, code analysis, debugging, etc.
gpt-5.3-codex - General tasks: Use - for architecture design, explanations, reviews, documentation, etc.
gpt-5.2
Step 2: Determine Sandbox (Edit Permission)
- Default: - safe for all tasks unless user explicitly requests editing
read-only - Explicit edit request: - ONLY when user explicitly says to edit/modify/write files
workspace-write
Code-related task examples:
- Read-only: "Analyze this function", "Review this implementation", "Debug this code"
- With editing: "Edit this file to fix the bug", "Modify the function", "Refactor and save"
General task examples:
- Read-only: "Design a queue data structure", "Explain this algorithm", "Review the architecture"
- With editing: "Update the documentation file", "Modify the README"
⚠️ Important: The key distinction for sandbox is whether the user explicitly asks for file modifications. Use ONLY when user says "edit", "modify", "write changes", "save", etc.
workspace-writeBash CLI Command Structure
See the DEFAULT MODEL section above for complete command templates. Key points:
- Always use (non-interactive mode required)
codex exec - Add for research tasks
--enable web_search_request - See for additional patterns
references/command-patterns.md
Model Selection Logic
Step 1: Choose Model Based on Task Type
Use for code-related tasks:
gpt-5.3-codex- Implementation, refactoring, code analysis
- Debugging, fixing bugs, optimization
- Any task involving code understanding or modification
Use for general tasks:
gpt-5.2- Architecture and system design
- Explanations, documentation, reviews
- Planning, strategy, general reasoning
Step 2: Choose Sandbox Based on Edit Intent
Use (DEFAULT):
read-only- Analysis, review, explanation tasks
- ANY task where user does NOT explicitly request file editing
Use (ONLY when explicitly requested):
workspace-write- User explicitly says "edit this file", "modify the code", "write changes"
- User explicitly asks to "make edits" or "save the changes"
- User explicitly requests "refactor and save" or "implement and write"
Fallback: If primary model unavailable, fallback to the other 5.2 variant. See fallback chain in DEFAULT MODEL section.
Default Configuration
All Codex invocations use these defaults unless user specifies otherwise:
| Parameter | Default Value | CLI Flag | Notes |
|---|---|---|---|
| Model (code tasks) | | | For code-related tasks |
| Model (general tasks) | | | For general tasks |
| Sandbox (default) | | | Safe default for ALL tasks |
| Sandbox (explicit edit) | | | Only when user explicitly requests editing |
| Reasoning Effort | | | Maximum reasoning capability |
| Verbosity | | | Balanced output detail |
| Web Search | | | Access to up-to-date information |
CLI Flags Reference
Codex CLI Version: 0.98.0+
See: for the complete CLI flags table and feature documentation.
references/cli-features.mdKey flags for this skill:
- - Model selection (
-m, --model,gpt-5.3-codex)gpt-5.2 - - Sandbox mode (
-s, --sandbox,read-only)workspace-write - - Config overrides (e.g.,
-c, --config)model_reasoning_effort=xhigh - /
--enable- Feature toggles (e.g.,--disable)web_search_request
Configuration Parameters
Pass these as :
-c key=value- :
model_reasoning_effort,minimal,low,medium,highxhigh- CLI default: - The Codex CLI defaults to high reasoning
high - Skill default: - This skill explicitly uses xhigh for maximum capability
xhigh - : Extra-high reasoning for maximum capability (supported by gpt-5.2 models)
xhigh - Use for complex architectural refactoring, long-horizon tasks, or when quality is more important than speed
xhigh
- CLI default:
- :
model_verbosity,low,medium(default:high)medium - :
model_reasoning_summary,auto,concise,detailed(default:none)auto - : JSON array of additional writable directories (e.g.,
sandbox_workspace_write.writable_roots)["/path1","/path2"] - :
approval_policy,untrusted,on-failure,on-request(approval behavior)never
Additional Writable Directories:
Use flag (preferred) or config:
--add-dirbash
# Using --add-dir for multiple directories
codex exec --add-dir /path1 --add-dir /path2 "task"
# Alternative - config approach
codex exec -c 'sandbox_workspace_write.writable_roots=["/path1","/path2"]' "task"Model Selection Guide
Available Models:
- - Code tasks (implementation, refactoring, debugging)
gpt-5.3-codex - - General tasks (architecture, reviews, explanations)
gpt-5.2
Default: for code tasks, for general tasks with reasoning effort.
gpt-5.3-codexgpt-5.2xhighSession Continuation
Detecting Continuation Requests
When user indicates they want to continue a previous Codex conversation:
- Keywords: "continue", "resume", "keep going", "add to that"
- Follow-up context referencing previous Codex work
- Explicit request like "continue where we left off"
Resuming Sessions
For continuation requests, use the command:
codex resumeResume Most Recent Session (Recommended)
bash
codex exec resume --lastThis automatically continues the most recent Codex session with all previous context maintained.
Resume Specific Session
bash
codex exec resume <session-id>Resume a specific session by providing its UUID. Get session IDs from previous Codex output or by running to see the most recent session.
codex exec resume --lastNote: The interactive session picker ( without arguments) is NOT available in non-interactive/Claude Code environments. Always use or provide explicit session ID.
codex resume--lastForking Sessions (Interactive Only)
The command creates a new session from a previous one, allowing exploration of different directions without affecting the original session.
codex forkbash
# Fork the most recent session (interactive terminal only)
codex fork --last
# Fork a specific session by ID (interactive terminal only)
codex fork <session-id>⚠️ Important: is an interactive-only command. It is NOT available under and will fail with "stdin is not a terminal" in Claude Code's non-interactive environment.
codex forkcodex execWorkaround for Claude Code: To achieve similar functionality, use with a prompt that indicates you want to explore an alternative approach. The session history will be preserved.
codex exec resume --lastNote: Unlike which continues the same session, creates a new independent session with the same history as a starting point.
resumeforkDecision Logic: New vs. Continue
Use when:
codex exec -m ... "<prompt>"- User makes a new, independent request
- No reference to previous Codex work
- User explicitly wants a "fresh" or "new" session
Use when:
codex exec resume --last- User indicates continuation ("continue", "resume", "add to that")
- Follow-up question building on previous Codex conversation
- Iterative development on same task
- User wants to explore alternatives (provide new direction in prompt)
Session History Management
- Codex CLI automatically saves session history
- No manual session ID tracking needed
- Sessions persist across Claude Code restarts
- Use to access most recent session
codex exec resume --last - Use for specific sessions
codex exec resume <session-id>
Error Handling
Simple Error Response Strategy
When errors occur, return clear, actionable messages without complex diagnostics:
Error Message Format:
Error: [Clear description of what went wrong]
To fix: [Concrete remediation action]
[Optional: Specific command example]Common Errors
Command Not Found
Error: Codex CLI not found
To fix: Install Codex CLI and ensure it's available in your PATH
Check installation: codex --versionAuthentication Required
Error: Not authenticated with Codex
To fix: Run 'codex login' to authenticate
After authentication, try your request again.Invalid Configuration
Error: Invalid model specified
To fix:
- For coding tasks: Use 'gpt-5.3-codex' with workspace-write sandbox
- For reasoning tasks: Use 'gpt-5.2' with read-only sandbox
Example (coding): codex exec -m gpt-5.3-codex -s workspace-write -c model_reasoning_effort=xhigh "implement feature"
Example (reasoning): codex exec -m gpt-5.2 -s read-only -c model_reasoning_effort=xhigh "explain architecture"Troubleshooting
First Steps for Any Issues:
- Check Codex CLI built-in help: ,
codex --help,codex exec --helpcodex exec resume --help - Consult official documentation: https://github.com/openai/codex/tree/main/docs
- Verify skill resources in directory
references/
Note: Commands like , , , and work without the subcommand. The requirement only applies to task execution.
codex --helpcodex --versioncodex logincodex logoutexecexecSkill not being invoked?
- Check that request matches trigger keywords (Codex, complex coding, high reasoning, etc.)
- Explicitly mention "Codex" in your request
- Try: "Use Codex to help me with..."
Session not resuming?
- Verify you have a previous Codex session (check command output for session IDs)
- Try: to resume most recent session
codex exec resume --last - If no history exists, start a new session first
"stdout is not a terminal" error?
- Always use instead of plain
codex execin Claude Codecodex - Claude Code's bash environment is non-interactive/non-terminal
Errors during execution?
- Codex CLI errors are passed through directly
- Check Codex CLI logs for detailed diagnostics
- Verify working directory permissions if using workspace-write
- Check official Codex docs for latest updates and known issues
Examples
Code Analysis (Read-Only)
bash
codex exec -m gpt-5.3-codex -s read-only \
-c model_reasoning_effort=xhigh \
"Analyze this function implementation"Code Editing (Explicit Request)
bash
codex exec -m gpt-5.3-codex -s workspace-write \
-c model_reasoning_effort=xhigh \
"Edit this file to implement the feature"Session Continuation
bash
codex exec resume --lastSee: for more examples including web search, file context, and code review patterns.
references/examples.mdCode Review Subcommand (v0.71.0+)
The subcommand provides non-interactive code review capabilities:
codex reviewbash
# Review uncommitted changes (staged, unstaged, untracked)
codex review --uncommitted
# Review changes against a base branch
codex review --base main
# Review a specific commit
codex review --commit abc123
# Review with custom instructions
codex review --uncommitted "Focus on security vulnerabilities"
# Non-interactive via exec
codex exec review --uncommittedReview Options:
| Flag | Description |
|---|---|
| Review staged, unstaged, and untracked changes |
| Review changes against the given base branch |
| Review the changes introduced by a commit |
| Optional commit title for review summary |
Apply Command (v0.98.0+)
The command applies the latest diff produced by the Codex agent as a to your local working tree:
codex applygit applybash
# Apply the latest diff from Codex
codex applyThis is useful when Codex generates code changes in read-only mode and you want to apply those changes to your local files.
CLI Features Reference
For detailed CLI feature documentation, see .
references/cli-features.mdQuick Reference - Common features:
- - Enable web search
--enable web_search_request - - Attach images to prompts
-i, --image - - Add writable directories
--add-dir - - Low-friction workspace-write mode
--full-auto - - JSONL output for programmatic processing
--json
File Context Passing
IMPORTANT: Pass file paths to Codex CLI instead of embedding file content in prompts. This enables Codex to read files autonomously.
Quick reference:
- Use to set working directory
-C /path - Use for additional directories
--add-dir /path - Use syntax for explicit file references
@path/to/file
bash
# Example: analyze file with explicit @ syntax
codex exec -m gpt-5.3-codex -s read-only \
"Analyze @src/auth.ts and compare with @src/session.ts"
# Example: multi-directory analysis
codex exec -m gpt-5.3-codex -s read-only \
--add-dir /shared/libs \
"Review how auth module uses shared utilities"See: for complete file context documentation.
references/file-context.mdBest Practices
1. Use Descriptive Requests
Good: "Help me implement a thread-safe queue with priority support in Python"
Vague: "Code help"
Clear, specific requests get better results from high-reasoning models.
2. Indicate Continuation Clearly
Good: "Continue with that queue implementation - add unit tests"
Unclear: "Add tests" (might start new session)
Explicit continuation keywords help the skill choose the right command.
3. Specify Permissions When Needed
Good: "Refactor this code (allow file writing)"
Risky: Assuming permissions without specifying
Make your intent clear when you need workspace-write permissions.
4. Leverage High Reasoning
The skill defaults to high reasoning effort - perfect for:
- Complex algorithms
- Architecture design
- Performance optimization
- Security reviews
Reference Documentation
For detailed information, consult these reference files:
Core References
- - File and directory context passing guide
references/file-context.md - - Complete command examples by use case
references/examples.md - - Feature flags and CLI options
references/cli-features.md
Workflow References
- - Common codex exec usage patterns
references/command-patterns.md - - Session continuation and resume workflows
references/session-workflows.md - - Complex configuration and flag combinations
references/advanced-patterns.md
CLI References
- - Codex CLI command reference
references/codex-help.md - - Full configuration options
references/codex-config.md