codex-cli
OpenAI Codex CLI fundamentals for code analysis, review, and validation. Use when (1) executing codex commands for code review/analysis, (2) configuring models (gpt-5.3-codex/gpt-5.2/gpt-5.1-codex-max/gpt-5-codex-mini), sandbox modes (read-only/workspace-write), or reasoning effort (low/medium/high/xhigh), (3) managing Codex sessions with resume, (4) integrating Codex into automation scripts. Do NOT use for orchestration patterns (use codex-claude-loop instead).
Best use case
codex-cli is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
OpenAI Codex CLI fundamentals for code analysis, review, and validation. Use when (1) executing codex commands for code review/analysis, (2) configuring models (gpt-5.3-codex/gpt-5.2/gpt-5.1-codex-max/gpt-5-codex-mini), sandbox modes (read-only/workspace-write), or reasoning effort (low/medium/high/xhigh), (3) managing Codex sessions with resume, (4) integrating Codex into automation scripts. Do NOT use for orchestration patterns (use codex-claude-loop instead).
Teams using codex-cli should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/codex-cli/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How codex-cli Compares
| Feature / Agent | codex-cli | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
OpenAI Codex CLI fundamentals for code analysis, review, and validation. Use when (1) executing codex commands for code review/analysis, (2) configuring models (gpt-5.3-codex/gpt-5.2/gpt-5.1-codex-max/gpt-5-codex-mini), sandbox modes (read-only/workspace-write), or reasoning effort (low/medium/high/xhigh), (3) managing Codex sessions with resume, (4) integrating Codex into automation scripts. Do NOT use for orchestration patterns (use codex-claude-loop instead).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Codex CLI Skill ## ⚠️ Environment Notice | Environment | Git Repo | Command Format | |-------------|----------|----------------| | Interactive terminal | Any | `codex "prompt"` | | **Claude Code / CI** | ✅ Yes | `codex exec -s read-only "prompt"` | | **Claude Code / CI** | ❌ No | `codex exec --skip-git-repo-check -s read-only "prompt"` | **Non-TTY environments** (Claude Code, CI pipelines, scripts) require `codex exec`. ### Git Repository Detection Before executing Codex commands, check if the working directory is a Git repository: ```bash # Check Git repository status git rev-parse --git-dir 2>/dev/null && echo "Git repo: YES" || echo "Git repo: NO" ``` - **Git repo exists**: Use standard commands - **No Git repo**: Add `--skip-git-repo-check` flag (requires user awareness of security implications) ## Quick Start ### In Git Repository (Standard) ```bash # Basic code review (terminal) codex "Review this code for bugs" # Non-interactive mode (Claude Code/CI) codex exec -s read-only "Review this code for bugs" # With specific model and reasoning effort codex exec -s read-only -m gpt-5.3-codex -c model_reasoning_effort=high "Deep analysis" # With image input codex exec -s read-only -i screenshot.png "What's shown here?" ``` ### Outside Git Repository ```bash # IMPORTANT: --skip-git-repo-check required for non-Git directories # Ask user permission before using this flag codex exec --skip-git-repo-check -s read-only "Review this code for bugs" # With options codex exec --skip-git-repo-check -s read-only -m gpt-5.3-codex "Deep analysis" ``` ### Session Resume (Special Syntax) ```bash # IMPORTANT: Options must come BEFORE 'resume' subcommand # SESSION_ID is from previous command output (e.g., 019ae3a3-f1cf-7dc1-8eee-8f424ae7a6f0) # In Git repository codex exec -s read-only resume [SESSION_ID] "Continue the analysis" # Outside Git repository codex exec --skip-git-repo-check -s read-only resume [SESSION_ID] "Continue the analysis" ``` ## Reference Documentation - **[Commands Reference](references/commands.md)** - `codex`, `resume`, `apply`, input/output patterns - **[Options Reference](references/options.md)** - Models, sandbox, reasoning effort, approval modes - **[Examples](references/examples.md)** - Code review, security analysis, automation scripts ## Available Models > **Full model details**: See [Options Reference](references/options.md#model-selection--m---model) > > **Note**: Model names change frequently as OpenAI releases new versions. Run `codex --help` or check [OpenAI Codex Models](https://developers.openai.com/codex/models/) for the current list. | Model | Best For | |-------|----------| | `gpt-5.3-codex` | Most capable agentic coding model (recommended) | | `gpt-5.2` | General AI tasks, multi-domain | | `gpt-5.1-codex-max` | Long-horizon agentic coding, security audits | | `gpt-5-codex-mini` | Quick checks, batch operations (cost-effective) | ## Reasoning Effort > **Usage examples**: See [Options Reference](references/options.md#reasoning-effort) | Level | Use Case | |-------|----------| | `low` | Simple checks, syntax review | | `medium` | Standard code review (default) | | `high` | Security audits, complex logic | | `xhigh` | Critical systems, exhaustive analysis | ## Sandbox Modes | Mode | Description | |------|-------------| | `read-only` | Cannot modify files (safest, recommended) | | `workspace-write` | Can modify workspace files | | `danger-full-access` | Full system access (use sparingly) | ## Key Options > **Full options list**: See [Options Reference](references/options.md#quick-reference) ## Common Patterns > **Full examples**: See [Examples](references/examples.md) for detailed patterns ### Essential Patterns ```bash # Code review (Claude Code/CI) codex exec -s read-only "Review: $(cat src/auth.js)" # Maximum depth analysis codex exec -m gpt-5.3-codex -c model_reasoning_effort=xhigh -s read-only "Security audit" # Session continuity codex exec -s read-only resume [SESSION_ID] "Continue analysis" # Cross-directory codex exec -C ./backend --add-dir ./frontend -s read-only "Review API" # Non-Git directory (ask user first) codex exec --skip-git-repo-check -s read-only "Analyze code" ``` ## Platform-Specific Notes ### Windows Limitations | Issue | Description | Workaround | |-------|-------------|------------| | `-C` with absolute paths | `cwd is not absolute` error with Windows paths like `C:\path` | Use relative paths (`./subdir`) or run from target directory | | Path separators | Backslashes may cause issues | Use forward slashes (`/`) in paths | ```bash # AVOID on Windows: codex exec -C C:\Projects\myapp -s read-only "analyze" # USE instead: cd C:\Projects\myapp && codex exec -s read-only "analyze" # OR use relative paths: codex exec -C ./myapp -s read-only "analyze" ``` ## Error Handling > **Error recovery patterns**: See [Examples](references/examples.md#automation) | Error | Cause | Solution | |-------|-------|----------| | `stdin is not a terminal` | Using `codex` in non-TTY | Use `codex exec` | | `Not inside a trusted directory` | Not in Git repo | Ask user, then use `--skip-git-repo-check` | | `invalid value for '--ask-for-approval'` | Invalid approval value | Use: `untrusted`, `on-failure`, `on-request`, `never` | | `unexpected argument` after `resume` | Options after `resume` | Place options BEFORE `resume` subcommand | | `cwd is not absolute` | Windows absolute path | Use relative paths or `cd` first | | `No prompt provided via stdin` | Empty prompt | Ensure prompt string is not empty | ## Timeout Configuration | Task Type | Recommended Timeout | Claude Code Tool | |-----------|---------------------|------------------| | Quick checks | 2 minutes | `timeout: 120000` | | Standard review | 5 minutes | `timeout: 300000` | | Deep analysis | **10 minutes** | `timeout: 600000` | **Recommendation**: Use `timeout: 600000` for all Codex exec commands (model_reasoning_effort=high/xhigh can take 3-7 minutes). ## Best Practices 1. **Use `codex exec`** in Claude Code and CI environments (non-TTY) 2. **Default to `-s read-only`** for all review tasks 3. **Match model + reasoning effort** to task complexity 4. **Use `resume`** to maintain session context 5. **Use `--add-dir`** for cross-project context 6. **Use `--full-auto`** only in controlled environments 7. **Ask user before `--skip-git-repo-check`** - explain implications 8. **Check valid approval values** - only use `untrusted`/`on-failure`/`on-request`/`never` 9. **Set 10-minute timeout** for all Codex exec commands (`timeout: 600000`)
Related Skills
codex-claude-loop
Dual-AI engineering loop orchestrating Claude Code (planning/implementation) and Codex (validation/review). Use when (1) complex feature development requiring validation, (2) high-quality code with security/performance concerns, (3) large-scale refactoring, (4) user requests codex-claude loop or dual-AI review. Do NOT use for simple one-off fixes or prototypes.
unity-vcontainer
VContainer dependency injection expert specializing in IoC container configuration, lifecycle management, and Unity-optimized DI patterns. Masters dependency resolution, scoped containers, and testable architecture design. Use PROACTIVELY for VContainer setup, service registration, or SOLID principle implementation.
unity-unitask
UniTask library expert specializing in allocation-free async/await patterns, coroutine migration, and Unity-optimized asynchronous programming. Masters UniTask performance optimizations, cancellation handling, and memory-efficient async operations. Use PROACTIVELY for UniTask implementation, async optimization, or coroutine replacement.
unity-unirx
UniRx (Reactive Extensions) library expert for legacy Unity projects. Specializes in UniRx-specific patterns, Observable streams, and ReactiveProperty. Use for maintaining existing UniRx codebases. For new projects, use unity-r3 skill instead.
unity-ui
Build and optimize Unity UI with UI Toolkit and UGUI. Masters responsive layouts, event systems, and performance optimization. Use for UI implementation, Canvas optimization, or cross-platform UI challenges.
unity-textmeshpro
TextMeshPro (TMPro) expert for Unity text rendering with advanced typography, performance optimization, and professional text effects. Masters font asset creation, dynamic fonts, rich text formatting, material presets, and text mesh optimization. Use PROACTIVELY for text rendering, font management, localization text, UI text performance, or text effects implementation.
unity-testrunner
Unity Test Framework CLI automation and test writing patterns. Masters batchmode execution, NUnit assertions, EditMode/PlayMode testing, and TDD workflows. Use PROACTIVELY for test automation, CI/CD pipelines, or test-driven development in Unity.
unity-r3
R3 (Reactive Extensions) library expert specializing in modern reactive programming patterns, event-driven architectures, and Observable streams. Masters R3-specific features, async enumerable integration, and Unity-optimized reactive patterns. Use PROACTIVELY for R3 implementation, reactive programming, or MVVM/MVP architecture.
unity-performance
Optimize Unity game performance through profiling, draw call reduction, and resource management. Masters batching, LOD, occlusion culling, and mobile optimization. Use for performance bottlenecks, frame rate issues, or optimization strategies.
unity-networking
Implement multiplayer games with Unity Netcode, Mirror, or Photon. Masters client-server architecture, state synchronization, and lag compensation. Use for multiplayer features, networking issues, or real-time synchronization.
unity-mobile
Optimize Unity games for mobile platforms with IL2CPP, platform-specific code, and memory management. Masters iOS/Android deployment, app size reduction, and battery optimization. Use for mobile builds, platform issues, or device-specific optimization.
unity-csharp-fundamentals
Unity C# fundamental patterns including TryGetComponent, SerializeField, RequireComponent, and safe coding practices. Essential patterns for robust Unity development. Use PROACTIVELY for any Unity C# code to ensure best practices.