Codex Skill Guide
When to Use Codex
- Tricky Debugging: Exceptional at finding elusive bugs that are hard to track down (mystery bugs, race conditions, edge cases)
- Security Analysis: Industry-leading vulnerability discovery - found zero-day CVEs in production frameworks, autonomous patch generation
- Code Review: Comprehensive security-focused code reviews, identifying vulnerabilities and anti-patterns
- Complex Refactoring: Large-scale code transformations with deep understanding of codebase context
- Agentic Coding: Multi-step autonomous software engineering tasks
Defaults
- Model: use the Codex CLI default (currently
gpt-5.3-codex; the CLI picks this automatically, so omit -m unless overriding).
- Reasoning effort:
medium unless the user selects otherwise.
- Sandbox mode:
read-only unless edits or network access are needed.
- stderr: suppress with
2>/dev/null to drop thinking tokens. Show stderr only when the user asks for thinking output or when debugging an error.
Running a Task
- Ask the user (via
AskUserQuestion) which reasoning effort to use (xhigh, high, medium, or low). Default to medium if the user does not specify.
- Select the sandbox mode required for the task; default to
--sandbox read-only unless edits or network access are necessary.
- Assemble the command with the appropriate options:
-m, --model <MODEL> (omit to use the CLI default)
--config model_reasoning_effort="<high|medium|low>"
--sandbox <read-only|workspace-write|danger-full-access>
--full-auto
-C, --cd <DIR>
--skip-git-repo-check (include after confirming with user on first use per session)
- To continue a previous session, pipe the new prompt via stdin:
echo "your prompt here" | codex exec [flags] resume --last 2>/dev/null. Flags go between exec and resume. Resume inherits the model, reasoning effort, and sandbox mode from the original session. Pass flags only to override one of those values.
- Append
2>/dev/null to every codex exec command to suppress thinking tokens (stderr). Show stderr only if the user asks to see thinking tokens or if you need to debug a failure.
- Run the command, capture stdout/stderr (filtered as appropriate), and summarise the outcome for the user.
- After Codex edits files, verify changes before proceeding:
- Run
git diff to review modifications
- Run tests if applicable (
npm test, pytest, etc.)
- Only commit or continue after validation passes
- After Codex completes, tell the user: "You can resume this Codex session at any time by saying 'codex resume' or asking me to continue with additional analysis or changes."
Task Checklist
- [ ] 1. Select reasoning effort (default: medium)
- [ ] 2. Select sandbox mode (default: read-only)
- [ ] 3. Assemble command with flags (model defaults to CLI's current default)
- [ ] 4. Get permission for high-impact flags (if --full-auto or danger-full-access)
- [ ] 5. Run command with 2>/dev/null
- [ ] 6. Summarise outcome
- [ ] 7. Verify changes (git diff, tests) if edits made
- [ ] 8. Inform user about resume option
Following Up
- After every
codex command, use AskUserQuestion to confirm next steps, collect clarifications, or decide whether to resume with codex exec resume --last.
- Restate the chosen reasoning effort and sandbox mode when proposing follow-up actions.
Error Handling
- Stop and report failures whenever
codex --version or a codex exec command exits non-zero; request direction before retrying.
- Before using high-impact flags (
--full-auto, --sandbox danger-full-access, --skip-git-repo-check), ask the user for permission using AskUserQuestion unless permission was already granted.
- When output includes warnings or partial results, summarise them and ask how to adjust using
AskUserQuestion.
Quick Reference
Append 2>/dev/null to every command below to suppress thinking tokens.
| Use case |
Sandbox mode |
Key flags |
| Read-only review or analysis |
read-only |
--sandbox read-only |
| Apply local edits |
workspace-write |
--sandbox workspace-write --full-auto |
| Permit network or broad access |
danger-full-access |
--sandbox danger-full-access --full-auto |
| Resume recent session |
Inherited from original |
echo "prompt" | codex exec resume --last (add flags between exec and resume only to override inherited values) |
| Run from another directory |
Match task needs |
-C <DIR> plus other flags |
Examples
Claude assembles:
codex exec --skip-git-repo-check --config model_reasoning_effort="high" --sandbox read-only 2>/dev/null
After completion: "Analysis complete. Found 2 potential SQL injection vulnerabilities in db/queries.ts. You can resume this Codex session at any time by saying 'codex resume' or asking me to continue with additional analysis."
Claude assembles:
codex exec --skip-git-repo-check --config model_reasoning_effort="high" --sandbox workspace-write --full-auto 2>/dev/null
After edits: Runs git diff to show changes, runs npm test to verify fix, then: "Fixed the race condition by adding mutex locks. Tests pass. You can resume this session with 'codex resume'."
Claude assembles:
echo "Continue the security analysis, focusing on authentication flows" | codex exec --skip-git-repo-check resume --last 2>/dev/null
Note: No model/sandbox flags needed -- inherited from original session.
Reasoning Effort Levels
Codex CLI context window: 400K input / 128K output. Check Codex releases for current pricing and benchmarks.
| Reasoning |
Best for |
xhigh |
Zero-day vulnerability discovery, deep architecture analysis, multi-hour agentic tasks |
high |
Security analysis, complex refactoring, performance optimisation, debugging race conditions |
medium (default) |
Feature additions, bug fixes, code review, standard refactoring |
low |
Quick fixes, formatting, documentation, simple changes |
Cached input tokens receive a significant discount. Repeated context within 24 hours benefits from this automatically.
CLI Version
Requires a recent Codex CLI version. Check with codex --version. See Codex releases for the latest version and current default model.
Use the /model slash command within a Codex session to switch models, or configure the default in ~/.codex/config.toml.
1---2name: codex3description: Invokes Codex CLI for code analysis, refactoring, or automated editing. Use when the user asks to run codex exec, codex resume, or references OpenAI Codex.4license: MIT5context: fork6---78# Codex Skill Guide910## When to Use Codex11- **Tricky Debugging**: Exceptional at finding elusive bugs that are hard to track down (mystery bugs, race conditions, edge cases)12- **Security Analysis**: Industry-leading vulnerability discovery - found zero-day CVEs in production frameworks, autonomous patch generation13- **Code Review**: Comprehensive security-focused code reviews, identifying vulnerabilities and anti-patterns14- **Complex Refactoring**: Large-scale code transformations with deep understanding of codebase context15- **Agentic Coding**: Multi-step autonomous software engineering tasks1617## Defaults1819- **Model**: use the Codex CLI default (currently `gpt-5.3-codex`; the CLI picks this automatically, so omit `-m` unless overriding).20- **Reasoning effort**: `medium` unless the user selects otherwise.21- **Sandbox mode**: `read-only` unless edits or network access are needed.22- **stderr**: suppress with `2>/dev/null` to drop thinking tokens. Show stderr only when the user asks for thinking output or when debugging an error.2324<instructions>2526## Running a Task27281. Ask the user (via `AskUserQuestion`) which reasoning effort to use (`xhigh`, `high`, `medium`, or `low`). Default to `medium` if the user does not specify.292. Select the sandbox mode required for the task; default to `--sandbox read-only` unless edits or network access are necessary.303. Assemble the command with the appropriate options:31 - `-m, --model <MODEL>` (omit to use the CLI default)32 - `--config model_reasoning_effort="<high|medium|low>"`33 - `--sandbox <read-only|workspace-write|danger-full-access>`34 - `--full-auto`35 - `-C, --cd <DIR>`36 - `--skip-git-repo-check` (include after confirming with user on first use per session)374. To continue a previous session, pipe the new prompt via stdin: `echo "your prompt here" | codex exec [flags] resume --last 2>/dev/null`. Flags go between `exec` and `resume`. Resume inherits the model, reasoning effort, and sandbox mode from the original session. Pass flags only to override one of those values.385. Append `2>/dev/null` to every `codex exec` command to suppress thinking tokens (stderr). Show stderr only if the user asks to see thinking tokens or if you need to debug a failure.396. Run the command, capture stdout/stderr (filtered as appropriate), and summarise the outcome for the user.407. After Codex edits files, verify changes before proceeding:41 - Run `git diff` to review modifications42 - Run tests if applicable (`npm test`, `pytest`, etc.)43 - Only commit or continue after validation passes448. After Codex completes, tell the user: "You can resume this Codex session at any time by saying 'codex resume' or asking me to continue with additional analysis or changes."4546### Task Checklist4748```49- [ ] 1. Select reasoning effort (default: medium)50- [ ] 2. Select sandbox mode (default: read-only)51- [ ] 3. Assemble command with flags (model defaults to CLI's current default)52- [ ] 4. Get permission for high-impact flags (if --full-auto or danger-full-access)53- [ ] 5. Run command with 2>/dev/null54- [ ] 6. Summarise outcome55- [ ] 7. Verify changes (git diff, tests) if edits made56- [ ] 8. Inform user about resume option57```5859## Following Up6061- After every `codex` command, use `AskUserQuestion` to confirm next steps, collect clarifications, or decide whether to resume with `codex exec resume --last`.62- Restate the chosen reasoning effort and sandbox mode when proposing follow-up actions.6364## Error Handling6566- Stop and report failures whenever `codex --version` or a `codex exec` command exits non-zero; request direction before retrying.67- Before using high-impact flags (`--full-auto`, `--sandbox danger-full-access`, `--skip-git-repo-check`), ask the user for permission using `AskUserQuestion` unless permission was already granted.68- When output includes warnings or partial results, summarise them and ask how to adjust using `AskUserQuestion`.6970</instructions>7172### Quick Reference7374Append `2>/dev/null` to every command below to suppress thinking tokens.7576| Use case | Sandbox mode | Key flags |77| --- | --- | --- |78| Read-only review or analysis | `read-only` | `--sandbox read-only` |79| Apply local edits | `workspace-write` | `--sandbox workspace-write --full-auto` |80| Permit network or broad access | `danger-full-access` | `--sandbox danger-full-access --full-auto` |81| Resume recent session | Inherited from original | `echo "prompt" \| codex exec resume --last` (add flags between `exec` and `resume` only to override inherited values) |82| Run from another directory | Match task needs | `-C <DIR>` plus other flags |8384## Examples8586<example>87**User**: "Review this file for security vulnerabilities"8889**Claude assembles**:90```bash91codex exec --skip-git-repo-check --config model_reasoning_effort="high" --sandbox read-only 2>/dev/null92```9394**After completion**: "Analysis complete. Found 2 potential SQL injection vulnerabilities in `db/queries.ts`. You can resume this Codex session at any time by saying 'codex resume' or asking me to continue with additional analysis."95</example>9697<example>98**User**: "Fix the race condition bug in the worker pool"99100**Claude assembles**:101```bash102codex exec --skip-git-repo-check --config model_reasoning_effort="high" --sandbox workspace-write --full-auto 2>/dev/null103```104105**After edits**: Runs `git diff` to show changes, runs `npm test` to verify fix, then: "Fixed the race condition by adding mutex locks. Tests pass. You can resume this session with 'codex resume'."106</example>107108<example>109**User**: "Continue analysing that code" (after previous session)110111**Claude assembles**:112```bash113echo "Continue the security analysis, focusing on authentication flows" | codex exec --skip-git-repo-check resume --last 2>/dev/null114```115116**Note**: No model/sandbox flags needed -- inherited from original session.117</example>118119## Reasoning Effort Levels120121Codex CLI context window: 400K input / 128K output. Check [Codex releases](https://github.com/openai/codex/releases) for current pricing and benchmarks.122123| Reasoning | Best for |124| --- | --- |125| `xhigh` | Zero-day vulnerability discovery, deep architecture analysis, multi-hour agentic tasks |126| `high` | Security analysis, complex refactoring, performance optimisation, debugging race conditions |127| `medium` (default) | Feature additions, bug fixes, code review, standard refactoring |128| `low` | Quick fixes, formatting, documentation, simple changes |129130Cached input tokens receive a significant discount. Repeated context within 24 hours benefits from this automatically.131132## CLI Version133134Requires a recent Codex CLI version. Check with `codex --version`. See [Codex releases](https://github.com/openai/codex/releases) for the latest version and current default model.135136Use the `/model` slash command within a Codex session to switch models, or configure the default in `~/.codex/config.toml`.