OpenAI Codex CLI — Terminal Coding Agent by OpenAI
Official OpenAI terminal coding agent. Reads your codebase, writes code, runs commands, and manages files from the command line. Multi-model support with sandbox execution. 20,000+ stars.
Safe staging for this asset
This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.
npx -y tokrepo@latest install 11647c80-61e5-40ba-951e-69f433cabc1c --target codexStages files first; activation requires review of the staged README and plan.
What it is
OpenAI Codex CLI is the official terminal-based coding agent from OpenAI. It reads your codebase, writes code, executes commands, and manages files directly from the command line. Features include sandbox execution, multi-model support (o4-mini, o3, GPT-4o), and configurable approval modes from fully manual to fully autonomous.
Codex CLI is designed as OpenAI's answer to Claude Code, targeting developers who prefer OpenAI models for their coding workflows.
How it saves time or tokens
Codex CLI provides three approval modes that let you control the automation level. In 'suggest' mode, it shows proposals for your approval. In 'auto-edit' mode, it applies file edits automatically but asks permission for commands. In 'auto' mode, it operates fully autonomously. The sandbox execution environment restricts network access and filesystem access to the project directory, making autonomous mode safe for development tasks.
How to use
- Install Codex CLI:
npm install -g @openai/codex
- Start an interactive session:
codex
- Run with a specific task:
codex 'Add input validation to the signup endpoint'
codex --auto 'Write tests for the auth module'
codex --model o3 'Design the database schema for user preferences'
Example
Using Codex CLI with different modes and models:
# Suggest mode: review each change before applying
codex --mode suggest 'Refactor the error handling in api/routes.ts'
# Auto-edit mode: auto-apply file changes, ask for commands
codex --mode auto-edit 'Add TypeScript types to all API handlers'
# Full auto with a specific model
codex --mode auto --model o4-mini 'Fix the failing test in auth.test.ts'
# Custom system prompt for project-specific context
codex --model o3 \
'This is a Next.js project with Prisma ORM. \
Add pagination to the /api/posts endpoint.'
Related on TokRepo
- Coding tools — More AI coding tools on TokRepo.
- Featured workflows — Discover curated developer tools.
Common pitfalls
- Running in 'auto' mode on production codebases without reviewing the changes first. Start with 'suggest' mode for unfamiliar tasks.
- Not setting the OPENAI_API_KEY environment variable before running. Export your API key in your shell profile.
- Codex CLI's sandbox disables network access by default, which can cause tests that call external APIs to fail. Configure sandbox permissions for your project's needs.
Frequently Asked Questions
Both are terminal-based coding agents that read code, write files, and execute commands. Codex CLI uses OpenAI models (o4-mini, o3, GPT-4o) while Claude Code uses Anthropic Claude models. Each has different strengths depending on the task and model preference.
Codex CLI runs commands in a sandboxed environment by default. Network access is disabled and filesystem access is restricted to the project directory. This prevents accidental modifications to system files or unintended network requests.
Codex CLI supports o4-mini (fast, cost-effective), o3 (highest capability), and GPT-4o. You can switch models per invocation with the --model flag.
No. Codex CLI sends your code and prompts to OpenAI's API for processing. It requires an internet connection and an OpenAI API key.
Yes. Codex CLI is open source on GitHub under the Apache 2.0 license. You can inspect the code, contribute, and fork it.
Citations (3)
- Codex CLI GitHub— OpenAI Codex CLI terminal coding agent
- OpenAI API Docs— OpenAI API documentation for models
- OpenAI Safety— Sandboxed code execution for AI agents
Related on TokRepo
Source & Thanks
Discussion
Related Assets
OpenAI Codex CLI — Official Coding Agent
OpenAI official coding agent CLI. Supports Agent Skills, custom prompts, and IDE integration. Open-source alternative to Cursor.
Claude Codex Bridge — Visible Multi-Agent CLI Teams
Claude Codex Bridge is an AGPL-3.0 CLI for visible multi-agent teams, coordinating Claude/Codex-style tools with PTY sessions and controlled handoff.
LLxprt Code — Multi-Provider AI Coding CLI
LLxprt Code is an open-source AI coding CLI that switches across providers (Anthropic, Gemini, Codex, local). Install via brew or npm.
Reasonix — DeepSeek-Native Coding Agent CLI
Reasonix is a DeepSeek-native coding agent CLI for the terminal; README reports a 99.82% cache hit in a real-day case study.