ScriptsApr 6, 2026·2 min read

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.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

npm install -g @openai/codex
# Start interactive session
codex

# Run with a task
codex "Add input validation to the signup endpoint"

# Full auto mode (no confirmations)
codex --auto "Write tests for the auth module"

Intro

OpenAI Codex CLI is the official terminal-based coding agent from OpenAI with 20,000+ GitHub stars. It reads your codebase, writes code, executes commands, and manages files directly from the command line — similar to Claude Code but powered by OpenAI models. Features include sandbox execution, multi-model support (o4-mini, o3, GPT-4o), and configurable approval modes from fully manual to fully autonomous. Best for developers who want an OpenAI-powered alternative to Claude Code. Works with: OpenAI models (o4-mini, o3, GPT-4o). Setup time: under 2 minutes.


Core Features

Three Approval Modes

Mode Behavior
suggest Shows suggestions, you approve each one
auto-edit Auto-applies file edits, asks for commands
auto Full autonomy — edits and runs commands
codex --mode auto "Refactor the database layer to use connection pooling"

Sandbox Execution

Commands run in a sandboxed environment by default:

  • Network access disabled
  • File system restricted to project directory
  • Configurable permissions

Multi-Model Support

# Use different models
codex --model o4-mini "Quick fix for the typo in README"
codex --model o3 "Design and implement a caching layer"
codex --model gpt-4o "Explain the authentication flow"

Context-Aware

Codex reads your project structure, git history, and relevant files to understand context before making changes.

Typical Workflow

# Navigate to your project
cd my-app

# Ask Codex to help
codex "The login endpoint returns 500 when the email has uppercase letters"

# Codex:
# 1. Reads relevant files (auth/login.ts, models/user.ts)
# 2. Identifies the case-sensitivity bug
# 3. Proposes a fix
# 4. Shows diff for approval
# 5. Applies the change
# 6. Runs tests to verify

Configuration

# ~/.codex/config.yaml
model: o4-mini
mode: auto-edit
approval:
  file_edits: auto
  commands: manual
context:
  max_files: 50
  include_git_diff: true

Key Stats

  • 20,000+ GitHub stars
  • Official OpenAI product
  • 3 approval modes
  • Sandboxed execution
  • Multi-model support (o4-mini, o3, GPT-4o)

FAQ

Q: What is OpenAI Codex CLI? A: The official OpenAI terminal coding agent that reads your codebase, writes code, runs commands, and manages files from the command line.

Q: Is Codex CLI free? A: The CLI is open-source. You need an OpenAI API key with usage-based billing.

Q: How does Codex CLI compare to Claude Code? A: Both are terminal coding agents. Codex uses OpenAI models (o4-mini, o3), Claude Code uses Claude models. Core functionality is similar — code editing, command execution, and project context awareness.


🙏

Source & Thanks

Created by OpenAI. Licensed under Apache 2.0.

codex — ⭐ 20,000+

Thanks to OpenAI for making terminal-based AI coding mainstream.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets