Invoke Codex CLI for complex coding tasks requiring high reasoning capabilities. This skill should be used when users explicitly mention "Codex", use Codex, ask Codex, run codex, codex exec, request complex implementation challenges, advanced reasoning, or need high-reasoning model assistance. Automatically triggers on codex-related requests and supports session continuation for iterative development.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
references/advanced-patterns.mdreferences/codex-config.mdreferences/codex-help.mdreferences/command-patterns.mdreferences/session-workflows.mdcodex 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.2 "prompt" (CORRECT)codex -m gpt-5.2 "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.
This skill should be invoked when:
When a user makes a request that falls into one of the above categories, determine the task type:
General Tasks (architecture, design, reviews, explanations):
gpt-5.2 (high-reasoning general model)Code Editing Tasks (file modifications, implementation):
gpt-5.2-codex-max (maximum capability for code editing - 27-42% faster)IMPORTANT: Always use codex exec for non-interactive execution. Claude Code's bash environment is non-terminal, so the interactive codex command will fail with "stdout is not a terminal" error.
codex exec -m gpt-5.2 -s read-only \
-c model_reasoning_effort=high \
--enable web_search_request \
"<user's prompt>"
codex exec -m gpt-5.2-codex-max -s workspace-write \
-c model_reasoning_effort=high \
--enable web_search_request \
"<user's prompt>"
Why codex exec?
Use gpt-5.2 (default) when:
Use gpt-5.2-codex-max when:
workspace-write sandboxNote: For backward compatibility, gpt-5.2-codex (standard model) is still available and works identically. Use gpt-5.2-codex-max as the default for better performance (27-42% faster, 30% fewer thinking tokens).
All Codex invocations use these defaults unless user specifies otherwise:
| Parameter | Default Value | CLI Flag | Notes |
|---|---|---|---|
| Model | gpt-5.2 | -m gpt-5.2 | General reasoning tasks |
| Model (code editing) | gpt-5.2-codex-max | -m gpt-5.2-codex-max | Code editing tasks (27-42% faster) |
| Sandbox | read-only | -s read-only | Safe default (general tasks) |
| Sandbox (code editing) | workspace-write | -s workspace-write | Allows file modifications |
| Reasoning Effort | high | -c model_reasoning_effort=high | Maximum reasoning capability |
| Verbosity | medium | -c model_verbosity=medium | Balanced output detail |
| Web Search | enabled | --enable web_search_request | Access to up-to-date information |
Codex CLI Version: 0.59.0+ (requires 0.59.0+ for gpt-5.2-codex-max support)
| Flag | Values | Description |
|---|---|---|
-m, --model | gpt-5.2, gpt-5.2-codex, gpt-5.2-codex-max | Model selection |
-s, --sandbox | read-only, workspace-write, danger-full-access | Sandbox mode |
-c, --config | key=value | Config overrides (e.g., model_reasoning_effort=high) |
-C, --cd | directory path | Working directory |
-p, --profile | profile name | Use config profile |
--enable | feature name | Enable a feature (e.g., web_search_request) |
--disable | feature name | Disable a feature |
-i, --image | file path(s) | Attach image(s) to initial prompt |
--full-auto | flag | Convenience for workspace-write sandbox with on-failure approval |
--oss | flag | Use local open source model provider |
--skip-git-repo-check | flag | Allow running outside Git repository |
--output-schema | file path | JSON Schema file for response shape |
--color | always, never, auto | Color settings for output |
--json | flag | Print events as JSONL |
-o, --output-last-message | file path | Save last message to file |
--dangerously-bypass-approvals-and-sandbox | flag | Skip confirmations (DANGEROUS) |
Pass these as -c key=value:
model_reasoning_effort: minimal, low, medium, high, xhigh (default: high)
xhigh: Extra-high reasoning for maximum capability (gpt-5.2-codex-max only)xhigh 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"])Note: To specify additional writable directories beyond the workspace, use:
-c 'sandbox_workspace_write.writable_roots=["/path1","/path2"]'
This replaces the removed --add-dir flag from earlier versions.
Default Models (Codex CLI v0.59.0+)
This skill defaults to the gpt-5.2 model family:
gpt-5.2 - General reasoning, architecture, reviews (default)Performance Characteristics:
gpt-5.2-codex-max is 27-42% faster than gpt-5.2-codexxhigh reasoning effort for maximum capabilityBackward Compatibility
You can override to use older models when needed:
# Use older gpt-5 model explicitly
codex exec -m gpt-5 -s read-only "Design a data structure"
# Use older gpt-5-codex model explicitly
codex exec -m gpt-5-codex -s workspace-write "Implement feature X"
When to Override
Model Override Examples
Override via -m flag:
# Override to gpt-5 for general task
codex exec -m gpt-5 "Explain algorithm complexity"
# Override to gpt-5-codex for code task
codex exec -m gpt-5-codex -s workspace-write "Refactor authentication"
# Override to gpt-4 if available
codex exec -m gpt-4 "Review this code"
Default Behavior
Without explicit -m override:
gpt-5.2gpt-5.2-codex-max (recommended for best performance)gpt-5.2-codex still works if explicitly specifiedWhen 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.
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.2' for general reasoning or 'gpt-5.2-codex-max' for code editing (gpt-5.2-codex also available for backward compatibility)
Example: codex exec -m gpt-5.2 "your prompt here"
Example: codex exec -m gpt-5.2-codex-max -s workspace-write "code editing task"
First Steps for Any Issues:
codex --help, codex exec --help, codex exec resume --helpreferences/ directorySkill 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?
User Request: "Help me design a binary search tree architecture in Rust"
Skill Executes:
codex exec -m gpt-5.2 -s read-only \
-c model_reasoning_effort=high \
"Help me design a binary search tree architecture in Rust"
Result: Codex provides high-reasoning architectural guidance using gpt-5. Session automatically saved for continuation.
User Request: "Edit this file to implement the BST insert method"
Skill Executes:
codex exec -m gpt-5.2-codex-max -s workspace-write \
-c model_reasoning_effort=high \
"Edit this file to implement the BST insert method"
Result: Codex uses gpt-5.2-codex-max (maximum capability for coding - 27-42% faster) with workspace-write permissions to modify files.
User Request: "Continue with the BST - add a deletion method"
Skill Executes:
codex exec resume --last
Result: Codex resumes the previous BST session and continues with deletion method implementation, maintaining full context.
User Request: "Use Codex with web search to research and implement async patterns"
Skill Executes:
codex exec -m gpt-5.2-codex-max -s workspace-write \
-c model_reasoning_effort=high \
--enable web_search_request \
"Research and implement async patterns"
Result: Codex uses web search capability for latest information, then implements with high reasoning and maximum code editing capability.
User Request: "Perform complex architectural refactoring of authentication system"
Skill Executes:
codex exec -m gpt-5.2-codex-max -s workspace-write \
-c model_reasoning_effort=xhigh \
"Perform complex architectural refactoring of authentication system"
Result: Codex uses extra-high reasoning effort (xhigh) for maximum capability on complex long-horizon tasks. Ideal for architectural refactoring where quality is more important than speed.
--enable / --disable)Enable or disable specific Codex features:
codex exec --enable web_search_request "Research latest patterns"
codex exec --disable some_feature "Run without feature"
-i, --image)Attach images to prompts for visual analysis:
codex exec -i screenshot.png "Analyze this UI design"
codex exec -i diagram1.png -i diagram2.png "Compare these architectures"
--skip-git-repo-check)Run Codex outside Git repositories:
codex exec --skip-git-repo-check "Help with this script"
--output-schema)Define JSON schema for model responses:
codex exec --output-schema schema.json "Generate structured data"
--color)Control colored output (always, never, auto):
codex exec --color never "Run in CI/CD pipeline"
Deprecated: --search flag (not available in codex exec)
New: Use --enable web_search_request instead
# Old (invalid for codex exec)
codex --search "research topic"
# New (correct)
codex exec --enable web_search_request "research topic"
xhigh reasoning effort)Default: When in doubt, use gpt-5.2 for general tasks. Use gpt-5.2-codex-max when specifically editing code for best performance and quality.
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:
Windows sandbox is now available in alpha (experimental). Use with caution in production environments.
The /exit slash-command alias is available in interactive codex mode (not applicable to codex exec non-interactive mode used by this skill).
All code editing models (gpt-5.2-codex-max, gpt-5.2-codex) support verbosity override via -c model_verbosity=<level> for controlling output detail levels.
For command construction examples and workflow patterns, Claude can reference:
references/command-patterns.md - Common codex exec usage patternsreferences/session-workflows.md - Session continuation and resume workflowsreferences/advanced-patterns.md - Complex configuration and flag combinationsThese files provide detailed examples for constructing valid codex exec commands for various scenarios.
For more details, see:
references/codex-help.md - Codex CLI command referencereferences/codex-config.md - Full configuration optionsREADME.md - Installation and quick start guide