Skip to main content
reopt Handbook
reopt Handbook
Advanced Codex Usage

Foundation

Setup and LoginConfigMemories

Safety and Operations

ApprovalsSecurity

Workflow

Slash CommandsPrompts and SkillsExec and AutomationThread LifecycleCloud TasksMulti-Agent Workflows

Extensions and IDE

Codex App and IDEMCP IntegrationModels and ReasoningGovernance and Rollout

Verification

VerificationUpdates
Handbook›Advanced Codex Usage›Exec and Automation
한국어English

Exec and Automation

Use Codex exec for non-interactive scripts, CI checks, and structured automation.

Python SDK 0.154.0 compatibility

The September 10 SDK release uses Python 3.10+ and a matching CLI runtime. ExternalMessage carries tool-level external content, not user authorization. include_turns changes returned history, not model context. Access HookMetadata through .root, such as hook.root.command, after checking the handler type. Late-attached turn handles do not replay earlier events; use thread.read(include_turns=True) for saved history. Custom codex_bin overrides need CLI 0.151.0+ for the new history/turn options.

official changelog · 2026-09-12 KST

Key takeaways

  • Since 0.143.0, codex remote-control pair generates a manual pairing code for a running daemon, and Codex can route authentication and Responses traffic through macOS/Windows system proxies including PAC/WPAD.

  • Use codex exec when a task is repeatable, scoped, and should produce structured evidence: dependency audits, doc checks, refactor plans, CI helpers, and batch reviews.

  • Keep prompts deterministic, pin model, permissions, and working directory, and prefer JSON or line-oriented output when scripts consume the result.

  • Log query time, sources, and network policy whenever automation depends on code-mode web search for fresh evidence.

  • Pin --cd and artifact directories for image flows, and validate app-server v2 clients with a smoke test like codex debug app-server send-message-v2 --help.

  • Never let exec make production-impacting changes automatically, and verify cloud exec provider behavior separately from local codex exec.

Interactive Codex is useful for exploration. exec is useful when the task is repeatable, scoped, and should produce structured evidence.

Good Exec Use Cases

Use caseExpected output
Dependency auditFindings, affected files, recommended fix
Documentation checkMissing pages, broken links, metadata gaps
Refactor planningChange list, risk, verification plan
CI helperMachine-readable result and concise summary
Batch reviewPer-file findings with severity

Automation Rules

  • Codex 0.147.0 removes deprecated codex exec --full-auto; select an explicit sandbox such as --sandbox workspace-write and keep approval policy in config or requirements.

  • Codex 0.148.0 adds codex exec fork for a non-interactive branch of an existing thread. Record the fork's output, approval state, and working directory as separate artifacts.

  • Keep prompts deterministic and scoped.

  • Pin model, permissions, and working directory where practical.

  • Prefer JSON or line-oriented output when consumed by scripts.

  • Fail clearly when required context is missing.

  • Archive outputs that support later review.

Current CLI Notes

  • Code mode can call standalone web search directly, including from nested JavaScript tool calls. Automation that depends on fresh web evidence should log query time, sources, and network policy.
  • codex exec --image and app/CLI image attachment flows now expose saved local file paths more reliably, so screenshot-based automation should pin --cd and artifact directories.
  • App-server integrations can read account token usage, and CLI/app-server auth supports ChatGPT v2 personal access tokens.
  • Include codex debug app-server send-message-v2 --help or an equivalent smoke test when validating internal app-server v2 clients.
  • Plugin automation should consume codex plugin add/remove --json, codex plugin list --available --json, and marketplace JSON outputs for audit logs.
  • Cloud exec provider behavior should be verified separately from local codex exec; do not assume identical permissions or environment requirements.

Anti-Patterns

  • Running broad write tasks without an owner.
  • Letting exec make production-impacting changes automatically.
  • Treating generated summaries as verification without tests or diffs.

Related docs

Terminal CLI Commands and Options

Codex Command Master · All 27 official Codex CLI command entries, global and command-specific option tables, and release additions

Automation and AI

CRM Standard · Design CRM automation and AI safely without spreading bad data faster.

Cmd. /add-dir

Claude Code Command Master · Add a working directory for file access in this session.

Automation and Web Commands

Claude Code Command Master · Commands for Claude Code on the web, PR automation, routines, Agent View background sessions, Desktop, and remote control.

Cmd. /review

Codex Command Master · Ask Codex to review the current working tree.

Prompts and Skills

Design prompts, repository instructions, and reusable skills for repeatable Codex work.

Thread Lifecycle

Manage Codex sessions across start, resume, fork, compact, archive, delete, and handoff.

On this page

Python SDK 0.154.0 compatibilityGood Exec Use CasesAutomation RulesCurrent CLI NotesAnti-Patterns