.claude/skills/openai-codex-cli-usage/SKILL.md
Correct usage patterns for OpenAI Codex CLI (@openai/codex). Use when: (1) Need to run Codex for plan/doc review (use exec not review), (2) Getting "config profile not found" errors from -p flag, (3) Want non-interactive Codex execution, (4) Need to understand the difference between codex review and codex exec commands, (5) Need structured JSON output from Codex, (6) Want web search in exec mode.
npx skillsauth add Dbochman/dotfiles openai-codex-cli-usageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Confusion about how to invoke Codex CLI for different tasks. Common mistakes include:
-p flag for prompts (it's for config profiles, not prompts)codex review for documentation review (only works for code diffs)--search in exec mode (doesn't work — use -c web_search=live)--output-schema| Task | Command |
|------|---------|
| Interactive session | codex "your prompt" |
| Non-interactive execution | codex exec "your prompt" or codex e "your prompt" |
| Code review (diffs only) | codex exec review --base main |
| Review specific commit | codex exec review --commit abc123 |
| Review uncommitted changes | codex exec review --uncommitted |
| Resume last session | codex exec resume --last "follow up" |
| Review file content | codex exec "review this: $(cat file.md)" |
codex exec --ephemeral "analyze this codebase for security issues"
# WRONG — --search flag doesn't work with exec
codex exec --search "latest React version"
# CORRECT — use config override
codex exec -c web_search=live "latest React version"
# Stream events, extract agent messages
codex exec --json "summarize the repo" | jq -r 'select(.type == "item.completed") | .item.text // empty'
# Get token usage
codex exec --json "hello" | jq 'select(.type == "turn.completed") | .usage'
# Define schema (strict mode: additionalProperties: false, all props required)
cat > /tmp/schema.json << 'EOF'
{
"type": "object",
"properties": {
"issues": { "type": "array", "items": { "type": "string" } },
"severity": { "type": "string" },
"summary": { "type": "string" }
},
"required": ["issues", "severity", "summary"],
"additionalProperties": false
}
EOF
codex exec --ephemeral --output-schema /tmp/schema.json -o /tmp/result.json \
"Analyze this code for issues"
codex exec --ephemeral "Review the last 5 commits for potential issues. Be concise."
# Let Codex make changes autonomously
codex exec --full-auto "fix the failing tests"
# Full auto is always workspace-write sandbox. For broader access:
codex exec --sandbox danger-full-access "your task"
# or equivalently:
codex exec --yolo "your task"
# Stdin pipe
cat logs.txt | codex exec -
# Here-doc for multi-line prompts
codex exec <<EOF
Review this code for bugs:
$(cat file.py)
Focus on: error handling, edge cases.
EOF
# Image input
codex exec "explain this error" -i screenshot.png
# -o captures final message to file (stdout still gets it too)
codex exec "generate release notes" -o release-notes.md
# With JSONL: stdout gets events, -o gets just the final message
codex exec --json "task" -o result.txt
| Flag | Sandbox | Use Case |
|------|---------|----------|
| (default) | read-only | Safe analysis |
| --full-auto | workspace-write | Local automation |
| --yolo | danger-full-access | Isolated CI only |
Note: --full-auto silently overrides --sandbox. To get full access, use --sandbox danger-full-access directly.
# Ephemeral (no disk persistence)
codex exec --ephemeral "triage this repo"
# Resume most recent session
codex exec resume --last "now fix those issues"
# Resume specific session
codex exec resume SESSION_ID "follow up"
Key settings in ~/.codex/config.toml:
model = "gpt-5.4"
model_reasoning_effort = "high" # minimal|low|medium|high|xhigh
model_reasoning_summary = "concise" # auto|concise|detailed|none
service_tier = "fast"
web_search = "live" # disabled|cached|live
sandbox_mode = "workspace-write"
[features]
multi_agent = true
shell_snapshot = true
[agents]
max_threads = 6
max_depth = 1
codex exec requires a Git repo by default — use --skip-git-repo-check to overrideCODEX_API_KEY only works with codex exec, not other commands--output-schema requires strict mode JSON Schema (additionalProperties: false)never (no interactive user to prompt)development
Search the web for current information, news, facts, and answers. Use when asked questions about current events, needing to look something up, finding websites, researching topics, or when you need up-to-date information beyond your training data.
development
Summarize any URL, YouTube video, podcast, PDF, or file into concise text. Use when asked to read an article, summarize a link, get the gist of a video or podcast, extract content from a URL, or when you need to understand what a web page or document contains.
development
Play music via Spotify and control Google Home speakers. Use when asked to play music, songs, artists, playlists, podcasts, or control speakers/volume/audio.
testing
Create new OpenClaw skills, modify and improve existing skills, and measure skill performance with evals. Use when users want to create a skill from scratch, update or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. Also use when asked to "make a skill", "turn this into a skill", "improve this skill", or "test this skill".