This skill should be used when the user wants to invoke Codex CLI for complex coding tasks requiring high reasoning capabilities.
GPT-5.4 is the default model for ALL tasks. Sandbox is read-only by default - only use workspace-write when user explicitly requests file editing.
| Model | Use Case | Reasoning Effort |
|---|---|---|
gpt-5.4 |
ALL tasks (default) | xhigh |
gpt-5.4-fast |
On-demand when user requests speed | high (default) |
gpt-5.4: OpenAI's most capable frontier model - unified for both code and general tasksgpt-5.4-fast: Faster variant for speed-sensitive tasks (use ONLY when user explicitly requests "fast", "quick", or "speed")read-only unless user explicitly requests editingworkspace-write-c model_reasoning_effort=xhigh for maximum capability# Default (read-only)
codex exec -m gpt-5.4 -s read-only \
-c model_reasoning_effort=xhigh \
"analyze this function implementation"
# With explicit edit request
codex exec -m gpt-5.4 -s workspace-write \
-c model_reasoning_effort=xhigh \
"edit this file to add the feature"
# Fast mode (on demand only)
codex exec -m gpt-5.4-fast -s read-only \
"quick analysis of this function"
If the primary model is unavailable, fallback gracefully:
gpt-5.4 → gpt-5.4-fast → gpt-5.4xhigh → high → mediumcodex execMUST USE: codex exec for ALL Codex CLI invocations in Claude Code.
NEVER USE: codex (interactive mode) - will fail with "stdout is not a terminal"
ALWAYS USE: codex exec (non-interactive mode)
Examples:
codex exec -m gpt-5.4 "prompt" (CORRECT)codex -m gpt-5.4 "prompt" (WRONG - will fail)codex exec resume --last (CORRECT)codex resume --last (WRONG - will fail)Why? Claude Code's bash environment is non-terminal/non-interactive. Only codex exec works in this environment.
Some Codex CLI flags are ONLY available in interactive mode, NOT in codex exec.
| Flag | Interactive codex |
codex exec |
Alternative for exec |
|---|---|---|---|
--search |
✅ Available | ❌ NOT available | Web search is now built-in (no flag needed) |
-a/--ask-for-approval |
✅ Available | ❌ NOT available | --full-auto or -c approval_policy=... |
--add-dir |
✅ Available | ✅ Available | N/A |
--full-auto |
✅ Available | ✅ Available | N/A |
⚠️ Web Search Note (v0.114.0+): The web_search_request feature flag is deprecated. Web search is now built-in when the model supports it. No --enable flag is needed in exec mode.
For approval control in exec mode:
# 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"
This skill activates when users say phrases like:
This skill should be invoked when:
When a user makes a request, determine sandbox based on explicit edit request:
Step 1: Model Selection
gpt-5.4 for ALL tasks (code and general)gpt-5.4-fast ONLY when user explicitly requests speedStep 2: Determine Sandbox (Edit Permission)
read-only - safe for all tasks unless user explicitly requests editingworkspace-write - ONLY when user explicitly says to edit/modify/write filesRead-only examples: "Analyze this function", "Design a queue", "Explain this algorithm" Edit examples: "Edit this file to fix the bug", "Modify the function", "Update the README"
⚠️ Important: Use workspace-write ONLY when user says "edit", "modify", "write changes", "save", etc.
See the DEFAULT MODEL section above for complete command templates. Key points:
codex exec (non-interactive mode required)references/command-patterns.md for additional patternsModel: gpt-5.4 for ALL tasks (unified model, no task-based selection needed)
gpt-5.4-fast ONLY when user explicitly requests speed/fast modeSandbox:
read-only (DEFAULT): Analysis, review, explanation, any task without explicit edit requestworkspace-write: ONLY when user explicitly says "edit", "modify", "write changes", "save"Fallback: gpt-5.4 → gpt-5.4-fast → gpt-5.4. See fallback chain in DEFAULT MODEL section.
All Codex invocations use these defaults unless user specifies otherwise:
| Parameter | Default Value | CLI Flag | Notes |
|---|---|---|---|
| Model | gpt-5.4 |
-m gpt-5.4 |
For ALL tasks (default) |
| Model (fast) | gpt-5.4-fast |
-m gpt-5.4-fast |
Only when user requests speed |
| Sandbox (default) | read-only |
-s read-only |
Safe default for ALL tasks |
| Sandbox (explicit edit) | workspace-write |
-s workspace-write |
Only when user explicitly requests editing |
| Reasoning Effort | xhigh |
-c model_reasoning_effort=xhigh |
Maximum reasoning capability |
| Verbosity | medium |
-c model_verbosity=medium |
Balanced output detail |
| Web Search | enabled |
--search (interactive) |
Access to up-to-date information (see note below) |
Codex CLI Version: 0.114.0+
See: references/cli-features.md for the complete CLI flags table and feature documentation.
Key flags for this skill:
-m, --model - Model selection (gpt-5.4, gpt-5.4-fast)-s, --sandbox - Sandbox mode (read-only, workspace-write)-c, --config - Config overrides (e.g., model_reasoning_effort=xhigh)--enable / --disable - Feature toggles (e.g., multi_agent)Pass these as -c key=value:
model_reasoning_effort: none, minimal, low, medium, high, xhighhigh - The Codex CLI defaults to high reasoningxhigh - This skill explicitly uses xhigh for maximum capabilityxhigh: Extra-high reasoning for maximum capabilityxhigh for complex architectural refactoring, long-horizon tasks, or when quality is more important than speedmodel_verbosity: low, medium, high (default: medium)model_reasoning_summary: auto, concise, detailed, none (default: auto)sandbox_workspace_write.writable_roots: JSON array of additional writable directories (e.g., ["/path1","/path2"])approval_policy: untrusted, on-failure, on-request, never (approval behavior)Additional Writable Directories:
Use --add-dir flag (preferred) or config:
# 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"
Available Models:
gpt-5.4 - ALL tasks (default, highest capability)gpt-5.4-fast - Speed-sensitive tasks (on demand only)Default: gpt-5.4 with xhigh reasoning effort for all tasks.
When user indicates they want to continue a previous Codex conversation:
For continuation requests, use the codex resume command:
codex exec resume --last
This automatically continues the most recent Codex session with all previous context maintained.
codex exec resume <session-id>
Resume a specific session by providing its UUID. Get session IDs from previous Codex output or by running codex exec resume --last to see the most recent session.
Note: The interactive session picker (codex resume without arguments) is NOT available in non-interactive/Claude Code environments. Always use --last or provide explicit session ID.
The codex fork command creates a new session from a previous one, allowing exploration of different directions without affecting the original session.
# 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: codex fork is an interactive-only command. It is NOT available under codex exec and will fail with "stdin is not a terminal" in Claude Code's non-interactive environment.
Workaround for Claude Code: To achieve similar functionality, use codex exec resume --last with a prompt that indicates you want to explore an alternative approach. The session history will be preserved.
Note: Unlike resume which continues the same session, fork creates a new independent session with the same history as a starting point.
Use codex exec -m ... "<prompt>" when:
Use codex exec resume --last when:
codex exec resume --last to access most recent sessioncodex exec resume <session-id> for specific sessionsWhen 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]
Error: Codex CLI not found
To fix: Install Codex CLI and ensure it's available in your PATH
Check installation: codex --version
Error: Not authenticated with Codex
To fix: Run 'codex login' to authenticate
After authentication, try your request again.
Error: Invalid model specified
To fix:
- Use 'gpt-5.4' for all tasks
- Use 'gpt-5.4-fast' for speed-sensitive tasks
Example: codex exec -m gpt-5.4 -s workspace-write -c model_reasoning_effort=xhigh "implement feature"
Example (fast): codex exec -m gpt-5.4-fast -s read-only "quick analysis"
First Steps for Any Issues:
codex --help, codex exec --help, codex exec resume --helpreferences/ directoryNote: Commands like codex --help, codex --version, codex login, and codex logout work without the exec subcommand. The exec requirement only applies to task execution.
Skill not being invoked?
Session not resuming?
codex exec resume --last to resume most recent session"stdout is not a terminal" error?
codex exec instead of plain codex in Claude CodeErrors during execution?
codex exec -m gpt-5.4 -s read-only \
-c model_reasoning_effort=xhigh \
"Analyze this function implementation"
codex exec -m gpt-5.4 -s workspace-write \
-c model_reasoning_effort=xhigh \
"Edit this file to implement the feature"
codex exec resume --last
See: references/examples.md for more examples including web search, file context, and code review patterns.
The codex review subcommand provides non-interactive code review capabilities:
# 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 --uncommitted
Review Options:
| Flag | Description |
|---|---|
--uncommitted |
Review staged, unstaged, and untracked changes |
--base <BRANCH> |
Review changes against the given base branch |
--commit <SHA> |
Review the changes introduced by a commit |
--title <TITLE> |
Optional commit title for review summary |
The codex apply command applies the latest diff produced by the Codex agent as a git apply to your local working tree:
# Apply the latest diff from Codex
codex apply
This is useful when Codex generates code changes in read-only mode and you want to apply those changes to your local files.
For detailed CLI feature documentation, see references/cli-features.md.
Quick Reference - Common features:
-i, --image - Attach images to prompts--add-dir - Add writable directories--full-auto - Low-friction workspace-write mode--json - JSONL output for programmatic processingIMPORTANT: Pass file paths to Codex CLI instead of embedding file content in prompts. This enables Codex to read files autonomously.
Quick reference:
-C /path to set working directory--add-dir /path for additional directories@path/to/file syntax for explicit file references# Example: analyze file with explicit @ syntax
codex exec -m gpt-5.4 -s read-only \
"Analyze @src/auth.ts and compare with @src/session.ts"
# Example: multi-directory analysis
codex exec -m gpt-5.4 -s read-only \
--add-dir /shared/libs \
"Review how auth module uses shared utilities"
See: references/file-context.md for complete file context documentation.
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.
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.
Good: "Refactor this code (allow file writing)" Risky: Assuming permissions without specifying
Make your intent clear when you need workspace-write permissions.
The skill defaults to high reasoning effort - perfect for:
For detailed information, consult these reference files:
references/file-context.md - File and directory context passing guidereferences/examples.md - Complete command examples by use casereferences/cli-features.md - Feature flags and CLI optionsreferences/command-patterns.md - Common codex exec usage patternsreferences/session-workflows.md - Session continuation and resume workflowsreferences/advanced-patterns.md - Complex configuration and flag combinationsreferences/codex-help.md - Codex CLI command referencereferences/codex-config.md - Full configuration options