Codex CLI — Official OpenAI Documentation
by OpenAI
The official manual for OpenAI's terminal coding agent — permissions, AGENTS.md, MCP, subagents and non-interactive codex exec.
Overview
Codex is OpenAI's coding agent, and this is the first-party reference for its terminal surface. The pages sit inside OpenAI's developer documentation hub and are organised into Get started (quickstart, importing from another agent), Foundations (prompting, skills and plugins, permissions), Explore (what's new, models, pricing, glossary), Available on (ChatGPT desktop app, web, Codex CLI, Codex IDE extension, Codex cloud), Releases (changelog, feature maturity, open source), Features (long-running work, scheduled tasks, browser, computer use, web search, file handling, plugins), Configuration (config file, agent configuration, MCP, platform-specific notes), Developers (development workflows, extensions, environments, integrations) and Security and Administration (Codex Security, permissions, authentication, admin setup, workspace controls, compliance). The CLI page itself documents installing via curl -fsSL https://chatgpt.com/codex/install.sh | sh, with npm install -g @openai/codex and brew install --cask codex as alternatives; resuming earlier sessions from the current repository or searching local chat history; passing error screenshots, architecture diagrams and design references with the first prompt; delegating focused work to specialised subagents; switching a run to live web search when a task depends on current releases or external behaviour; and attaching local or remote MCP servers with authentication where needed. The /init command generates an AGENTS.md file of durable project instructions, /permissions sets the boundaries for file edits and command execution, and codex exec runs the agent non-interactively for scripting and CI. The CLI is Apache-2.0 and open source at github.com/openai/codex with 118.9k stars; running it authenticates against a ChatGPT Plus, Pro, Business, Edu or Enterprise plan.
At a Glance
- Topic
- Agentic
- Level
- Intermediate
- Format
- Documentation
- Cost
- Freemium
- Duration
- ~1-2 hours to read the CLI, configuration and permissions sections; ongoing reference thereafter
- Provider
- OpenAI
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Install Codex CLI and run it interactively or headlessly with codex exec in CI
- ✓Configure permissions and sandboxing so the agent cannot edit or execute beyond set boundaries
- ✓Write an AGENTS.md file that gives Codex durable, project-specific operating instructions
- ✓Attach local and remote MCP servers, including authentication, to extend the agent's tools
- ✓Delegate focused sub-tasks to subagents instead of overloading one long context window
- ✓Resume earlier sessions and search local chat history to pick work back up
- ✓Feed screenshots, architecture diagrams and live web search results into a run as context
Highlights
- •First-party documentation rather than a blog write-up — the permissions and security sections have no third-party equivalent
- •Covers every surface in one place: CLI, IDE extension, Codex cloud and the ChatGPT desktop app
- •The CLI is Apache-2.0 with 118.9k GitHub stars, so the documentation can be checked against the source
- •Explicit MCP and AGENTS.md coverage, the two interop standards most coding-agent setups depend on
- •Any documentation page is available as raw markdown by appending .md to its URL, which agents can fetch directly
Who It’s For
Best For
- ✓Engineers standardising a coding agent across a shared team repository
- ✓Anyone scripting agent runs into CI, cron or a build pipeline
- ✓Developers comparing Codex against Claude Code and other terminal agents
- ✓Platform teams that need the sandboxing, authentication and workspace-control details
Prerequisites
- •Comfort with a terminal, git and running commands against a real repository
- •A ChatGPT Plus, Pro, Business, Edu or Enterprise plan to authenticate the CLI
- •Familiarity with MCP helps for the tool-configuration sections
FAQ
What is Codex CLI — Official OpenAI Documentation?
OpenAI's official documentation for Codex CLI, the coding agent that runs locally in your terminal. It covers installation, interactive and non-interactive modes, the permissions and sandboxing model, AGENTS.md project instructions, skills and plugins, MCP server configuration, subagent delegation, web search and image context. Read it and you can wire Codex into real repositories and CI pipelines rather than using it as a chat box.
Is Codex CLI — Official OpenAI Documentation free?
Codex CLI — Official OpenAI Documentation offers free content, with paid options for certificates or premium features.
What level is Codex CLI — Official OpenAI Documentation for?
Codex CLI — Official OpenAI Documentation is aimed at a intermediate audience. Recommended background: Comfort with a terminal, git and running commands against a real repository, A ChatGPT Plus, Pro, Business, Edu or Enterprise plan to authenticate the CLI, Familiarity with MCP helps for the tool-configuration sections.
How long does Codex CLI — Official OpenAI Documentation take?
Expect roughly ~1-2 hours to read the CLI, configuration and permissions sections; ongoing reference thereafter. Most learners work through it at their own pace.
What will I learn from Codex CLI — Official OpenAI Documentation?
You'll learn: Install Codex CLI and run it interactively or headlessly with codex exec in CI; Configure permissions and sandboxing so the agent cannot edit or execute beyond set boundaries; Write an AGENTS.md file that gives Codex durable, project-specific operating instructions; Attach local and remote MCP servers, including authentication, to extend the agent's tools; Delegate focused sub-tasks to subagents instead of overloading one long context window; Resume earlier sessions and search local chat history to pick work back up; Feed screenshots, architecture diagrams and live web search results into a run as context.
Topics
Sources
This page was written from 2 sources, 1 on domains other than learn.chatgpt.com.