Get the FREE Ultimate OpenClaw Setup Guide →

codex-cli

npx machina-cli add skill georgekhananaev/claude-skills-vault/codex-cli --openclaw
Files (1)
SKILL.md
3.7 KB

Codex CLI

Run OpenAI Codex CLI locally for second-opinion audits, code review, and non-interactive task execution.

Prerequisites

Codex CLI must be installed and authenticated:

  1. Install: npm install -g @openai/codex
  2. Auth: codex login
  3. Verify: codex --version

Core Execution Pattern

Use codex exec for delegated prompts (non-interactive):

codex exec "Your prompt here"

When the user says "codex prompt", treat it as:

codex exec "<user prompt>"

Model Guidance

Use the default configured model unless the user asks otherwise.

Latest tested working model in this environment:

codex exec -m gpt-5.3-codex "Your prompt"

Compatibility note:

  • gpt-5-codex may fail if config uses model_reasoning_effort = "xhigh".
  • If you must use gpt-5-codex, set reasoning effort explicitly:
codex exec -m gpt-5-codex -c model_reasoning_effort="high" "Your prompt"

Commands

Non-Interactive Execution

# Basic task
codex exec "Audit this logic for edge cases"

# Explicit model
codex exec -m gpt-5.3-codex "Review this implementation strategy"

# Full-auto mode (sandboxed, lower friction)
codex exec --full-auto "Implement the requested refactor"

# Read-only sandbox (analysis only)
codex exec -s read-only "Find bugs in this code path"

# Workspace-write sandbox
codex exec -s workspace-write "Apply the fix and update tests"

# Custom working directory
codex exec -C /path/to/project "Evaluate this repository"

# Save final output to file
codex exec -o output.txt "Summarize key risks"

# JSONL event stream
codex exec --json "Produce structured findings"

# Pipe context from stdin
cat context.txt | codex exec -

Code Review

Use codex review for repository diffs:

# Review uncommitted changes
codex review --uncommitted

# Review against a base branch
codex review --base main

# Review a specific commit
codex review --commit abc123

# Custom review instructions
codex review "Focus on security issues"

# Combined
codex review --base main "Check for performance regressions"

Important Flag Placement

--search and -a/--ask-for-approval are top-level flags. Put them before exec or review.

Correct:

codex --search -a on-request exec "Your prompt"
codex --search -a on-request review --uncommitted

Avoid:

codex exec --search "Your prompt"
codex exec -a on-request "Your prompt"

Useful Flags

FlagDescription
-mModel (recommended explicit example: gpt-5.3-codex)
-sSandbox: read-only, workspace-write, danger-full-access
-aApproval policy (untrusted, on-failure, on-request, never) as a top-level flag
-CWorking directory
-oWrite last message to file
--full-autoSandboxed auto-execution (-a on-request -s workspace-write)
--jsonJSONL event output
--searchEnable web search tool as a top-level flag
--add-dirAdditional writable directories
-c key=valueOverride config (example: -c model_reasoning_effort="high")

Best Practices

  • Prefer codex exec for delegated prompts instead of interactive codex
  • Start with -s read-only for audits and second opinions
  • Use --full-auto only when you expect autonomous edits
  • Keep prompts explicit about expected output format
  • Add -o when another tool or agent must consume the result
  • Run codex review --uncommitted before committing as a quick extra pass

Source

git clone https://github.com/georgekhananaev/claude-skills-vault/blob/main/.claude/skills/codex-cli/SKILL.mdView on GitHub

Overview

Codex CLI runs OpenAI Codex locally for second-opinion audits, code reviews, and non-interactive task execution. Use it when someone asks to run Codex, mentions codex prompt, or wants Claude to delegate a logic or code review to OpenAI models. It requires installation and authentication before use.

How This Skill Works

Install and authenticate the Codex CLI (npm install -g @openai/codex; codex login; codex --version). For non-interactive prompts, run codex exec with your prompt; if the user says codex prompt, treat it as codex exec "<user prompt>". For code review workflows, use codex review with options like --base, --uncommitted, or --commit to tailor the scope.

When to Use It

  • User asks to run Codex or references a codex prompt
  • Executing a delegated non-interactive prompt via codex exec
  • Performing a repository code review with codex review
  • Auditing logic for edge cases, security, or correctness
  • Reviewing changes against a base branch or specific commit

Quick Start

  1. Step 1: Install and login: npm install -g @openai/codex; codex login
  2. Step 2: Verify installation: codex --version
  3. Step 3: Run a prompt non-interactively: codex exec "Audit this logic for edge cases"

Best Practices

  • Prefer codex exec for delegated prompts instead of interactive codex
  • Start with -s read-only for audits and second opinions
  • Use --full-auto only when autonomous edits are expected
  • Keep prompts explicit about the expected output format
  • Add -o when another tool or agent must consume the result

Example Use Cases

  • Audit this logic for edge cases
  • Review this implementation strategy
  • Review uncommitted changes using codex review --uncommitted
  • Apply the fix and update tests with full-auto
  • Evaluate this repository in /path/to/project with -C /path/to/project

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers