codex
TLDR
Launch interactive terminal UI
SYNOPSIS
codex [options] [prompt]
DESCRIPTION
Codex is OpenAI's official terminal-based coding agent. It launches into a full-screen terminal UI that can read your repository, suggest and implement code changes, and execute commands while you iterate conversationally.
The tool maintains security through OS-level sandboxing with three safety modes: read-only (consultative, no changes), auto (default, asks before touching files outside workspace), and full access (unrestricted, use with caution). Model-generated commands run in isolated environments using macOS seatbelt or Linux Landlock.
Codex integrates with ChatGPT Plus, Pro, Business, and Enterprise subscriptions, or can be used with API credits. It supports cloud tasks for offloading complex work and provides MCP integration for extended capabilities.
PARAMETERS
--model, -m MODEL
Override the default model (e.g., gpt-5.2-codex, codex-mini-latest)--sandbox, -s POLICY
Sandbox policy: read-only, workspace-write, or danger-full-access--ask-for-approval, -a MODE
Control approval timing: untrusted, on-failure, on-request, or never--full-auto
Enable low-friction mode with on-request approvals and workspace-write sandbox--yolo
Disable approvals and sandboxing (use only in hardened environments)--cd, -C PATH
Set working directory before processing--add-dir PATH
Grant additional directories write access--image, -i PATH
Attach image files to the initial prompt--oss
Use local open-source model via Ollama--search
Enable web search capability--profile, -p NAME
Load configuration profile from config.toml--help
Display help information
COMMANDS
exec, e
Run non-interactively; supports --json, --output-last-messageresume
Continue a previous session by ID or use --lastfork
Branch a previous session into a new threadapply, a
Apply latest diff from Codex Cloud task to local repositorycloud
Browse or execute cloud taskslogin
Authenticate via ChatGPT OAuth or API keylogout
Remove stored credentialsmcp
Manage Model Context Protocol servers (add, list, remove)sandbox
Run commands under macOS seatbelt or Linux Landlock sandboxingcompletion
Generate shell completions (bash, zsh, fish, powershell)
CAVEATS
Requires authentication with a ChatGPT account or OpenAI API key. The --yolo flag bypasses all safety measures and should only be used in isolated environments. Network access is restricted by default; enable with --search or full-access sandbox mode.
HISTORY
OpenAI originally launched Codex as a code autocompletion API in August 2021, which powered GitHub Copilot. The Codex CLI terminal agent was released on April 16, 2025 under the Apache 2.0 license, with version 1.0.0 shipping in May 2025. Codex Cloud launched in June 2025 for ChatGPT Plus users. The GPT-5.2-Codex model was released in December 2025 with enhanced agentic coding capabilities.


