Codex CLI: OpenAI's Terminal Coding Agent That Writes Code for You (2026) — What It Is and How to Use It
There is a program you can install in under a minute that turns your terminal into a working programmer. You type a sentence — "add a login page", "find why the tests fail" — and it reads your code, edits the files, runs the commands and the tests, and shows you exactly what it changed. It is called Codex CLI, it lives in the repository openai/codex, and it has about 136,000 stars. Its current release is v0.172.0, published on 24 November 2026, and the command-line tool itself is open source under the Apache 2.0 licence. All numbers here were checked live on 26 November 2026.
Codex CLI is OpenAI's coding agent for the terminal, released on 16 April 2025 alongside the o3 and o4-mini reasoning models. It is the local end of a wider Codex family — IDE extension, desktop app and cloud service — but the terminal tool is the part anyone can download, inspect and run for free. The catch is that the tool is free while the intelligence behind it is not: you sign in with a ChatGPT plan or an API key, and the model answers are billed through that account.
What Codex CLI Actually Is
Codex CLI is an agentic coding tool. A code completion tool suggests the next few lines while you type; an agent takes a whole task and carries it through: it reads the files involved, plans the change, writes the code, runs the build or the tests, reads the errors, fixes them, and reports back. You stay in charge — it asks before anything risky.
It works directly with the files and folders of a software project. You start it inside a project folder, type an instruction in plain English, and it proposes changes as diffs you can review. It can also run shell commands, use web search, run build and test tools, and work with images you paste in.
It is distinct from two things people confuse it with. First, it is not the original Codex model from 2021, the GPT-3 derivative behind the first GitHub Copilot — the name sat dormant for years before OpenAI reused it in April 2025. Second, it is not Codex Cloud, the hosted service that runs tasks on OpenAI's machines while you walk away. The CLI is the local component: it runs on your machine, against your files, and you watch every step.
The Story: From April 2025 to 136,000 Stars
OpenAI released Codex CLI on 16 April 2025, built by Fouad Matin and Michael Bolin, as a lightweight coding agent that runs locally in your terminal. The first version was written in TypeScript and Node.js, using the Ink terminal interface framework, and it needed Node.js version 22 or later. It shipped as an npm package, with a one-million-dollar fund in API grants for projects built on it.
The bet paid off quickly. The repository gathered tens of thousands of stars within months, and by its first birthday in April 2026 the wider Codex product had passed three million weekly active users. Under the surface, the tool was being rebuilt: in late May 2025 OpenAI announced that Codex CLI was "going native" — a full rewrite from TypeScript to Rust. By 2026 about 97 percent of the repository's code was Rust.
The release pace since then has been relentless. Stable versions arrive roughly every week: v0.167.0 on 6 November 2026 added an agent command centre, v0.168.0 and v0.169.0 shipped on the same day, 13 November, adding a terminal workspace with side-chat tabs, v0.170.0 on 18 November added realtime voice calls, v0.171.0 on 20 November made GPT-6.2 Sol the default model, and v0.172.0 on 24 November polished startup speed and remote sessions. The stars climbed from about 113,000 in late August 2026 to about 136,000 by 18 November, with around 21,500 forks.
The Licence, Explained Exactly: Apache 2.0 — and Where the Open Source Ends
Codex CLI is genuinely open source under the Apache 2.0 licence, confirmed by the repository's licence file and every independent tracker checked for this article. Apache 2.0 is a permissive licence: you may use the code for any purpose, including commercial use, copy it, modify it, and distribute your modified version, provided you keep the copyright notice and the licence text.
The qualification matters. Apache 2.0 covers the CLI, the SDK and the app server — the parts that run on your machine. It does not cover the whole Codex product. The IDE extension, the desktop app and Codex Cloud are closed source. The terminal tool is open source under Apache 2.0; the hosted and desktop parts of the Codex family are proprietary, and the models belong to OpenAI.
That boundary is worth keeping in mind for a second reason. Open source here means the tool, not the intelligence. The code that reads your files and runs your commands is yours to inspect. The model that decides what to write runs on OpenAI's servers and is billed through your ChatGPT plan or API key. You can, however, point the tool at a local open model instead — the --oss flag runs a local model through LM Studio or Ollama, covered on Tech Know on 13 November 2026.
How It Works: The Agent Loop, Step by Step
A session follows the same loop every time. First, it reads: it explores the repository, reads the relevant files, and reads your AGENTS.md file. Second, it plans and proposes: it shows you the plan, then the edits as diffs you can accept, reject or edit. Nothing is applied silently. Third, it acts: it writes the files, runs the shell commands and the project's build and test tools. If a test fails, it reads the error and tries a fix. Fourth, it reports what changed and what the tests said.
Recent releases add the terminal workspace (v0.168.0, on by default in v0.171.0) and the agent command centre (v0.167.0, opened with codex agents).
Sandbox and Approval Modes: The Safety System
The safety system is the part of Codex CLI that most sets it apart. Two settings decide what the agent may do: the sandbox, which limits what commands can touch, and the approval policy, which decides when it stops to ask you.
| What you want | Flags | Effect |
|---|---|---|
| The default (Auto) | --sandbox workspace-write --ask-for-approval on-request | Edits and runs commands in the workspace; asks before going outside it |
| Look, don't touch | --sandbox read-only --ask-for-approval on-request | Reads files; asks before anything else |
| Unattended and read-only | --sandbox read-only --ask-for-approval never | Never asks; cannot change anything |
| Fewer prompts | --approve-for-me | Approvals go to an automatic reviewer |
| No guard rails | --dangerously-bypass-approvals-and-sandbox | No sandbox, no approvals; containers only |
By default the agent runs with network access turned off, and it can write only inside the current workspace. Even inside the workspace, the folders .git, .agents, .codex and .aws stay read-only. Since v0.169.0, the non-interactive mode also keeps project configuration and MCP servers disabled in untrusted directories unless you pass --trust — a deliberate security default, because a repository you just cloned could otherwise smuggle in instructions of its own. Use Auto for folders under version control, read-only for everything else, and the no-guard-rails flag only inside a throwaway container.
Sign In and What It Costs
Codex CLI itself costs nothing to download. What costs money is the model, and you pay for it in one of two ways: sign in with a ChatGPT plan, or use an API key. The first run asks you to choose. With a ChatGPT account you sign in through a browser window and use your plan's included usage. With an API key you pay standard API rates but lose the cloud features: GitHub code review, Slack and similar.
| Plan | Price | Codex access |
|---|---|---|
| Free | 0 dollars | Luna in the desktop app only |
| Go | 8 dollars a month | Luna in the desktop app only |
| Plus | 20 dollars a month | CLI, IDE extension, web and iOS |
| Pro | 100, 200 or 500 dollars a month | Everything in Plus; no five-hour limit |
| Business | 20 dollars a user a month, billed annually | Larger cloud machines, SAML sign-on |
| API key | API rates | CLI, SDK, IDE; no cloud features |
The plan prices above were checked on 12 November 2026, and OpenAI changes them, so treat them as a snapshot and re-check before you commit. On Plus and Business, estimated usage per five hours (not fixed limits): GPT-6 Astra about 5 to 45 messages, GPT-6.1 Sol about 15 to 160, GPT-6.1 Terra about 35 to 285, and GPT-6 Luna about 350 to 3,000. Weekly limits may apply on top, and fast mode uses included usage two and a half times as fast.
The Models: GPT-6.2 Sol Is the Default Now
Codex CLI runs OpenAI's GPT-6 family, and the default changed as recently as 20 November 2026, when v0.171.0 made GPT-6.2 Sol the default selection. Switch with /model in a session, a flag at launch, or a line in the settings file. GPT-6.1 Sol has a 500,000-token context window inside Codex, large enough to hold a whole medium-sized codebase in one session.
| Model | Slug | What it is for |
|---|---|---|
| GPT-6.2 Sol | gpt-6.2-sol | The default; near-Astra performance, lower cost |
| GPT-6.2 Astra | gpt-6.2-astra | The most capable, for complex work |
| GPT-6.1 Terra | gpt-6.1-terra | Writing, visual understanding, computer use |
| GPT-6 Luna | gpt-6-luna | The most efficient, for high-volume tasks |
One change to note if you follow older guides: GPT-5.5 left Codex for ChatGPT sign-ins on 14 October 2026, and stays available only with an API key.
Install and First Run
Installing Codex CLI takes under a minute. Four ways install the same tool: the official installer script for macOS and Linux, the equivalent installer for Windows PowerShell, the npm package installed globally, or Homebrew on macOS. Check the version with codex --version, then run codex inside a project folder and sign in.
Spend ten minutes on your first session. Start with something small and verifiable: ask it to explain the project structure, or to find a bug you already know about, and watch how it reads files and shows its diffs before applying them. Then try a real edit, review the diff it proposes, and run the tests through it. The habit that saves trouble later is reviewing every diff before it is applied — the tool is fast, and fast is only good when the change is right.
AGENTS.md and config.toml: Teaching It Your Project
Codex reads AGENTS.md files before doing any work. It takes your global file first, then one file per folder from the repository root down to where you started, and it stops at 32 kilobytes of instructions. Files closer to your working folder come later, so they win when instructions conflict. The command /init writes a starter AGENTS.md for you.
This file is where the tool stops being generic and starts being yours. Put the project's build and test commands in it, the code style rules, the things it must never do. One file, written once, shapes every session after it. If the same repository also uses Claude Code, keep one AGENTS.md and import it from CLAUDE.md. Your settings live in config.toml inside the .codex folder under your home directory. One setting deserves attention for data work: the shell environment policy defaults to skipping automatic filtering for variable names containing KEY, SECRET or TOKEN, so a database password in your environment can reach the commands Codex runs. If you do not want that, set it to false in config.toml.
MCP, Skills and codex exec: Codex in Scripts and Automation
Codex connects to MCP servers — the Model Context Protocol — so it can use tools beyond its built-ins: documentation servers, databases, issue trackers. The command codex mcp add writes the server into config.toml, and the CLI, the IDE extension and the desktop app share the result. It speaks both stdio and streamable remote servers, with bearer tokens or OAuth sign-in. Since v0.172.0, optional stdio MCP servers start lazily, on their first tool call.
For scripts and continuous integration there is codex exec. It runs once without the interface: progress goes to standard error and only the final message to standard output, so you can pipe it. By default it runs in a read-only sandbox; add the workspace-write flag to let it edit. It refuses to run outside a Git repository, and it refuses to run in untrusted directories without --trust. Useful flags: --json prints every event as JSON Lines, -o saves the final message to a file, --output-schema makes the final answer match a JSON Schema, and --ephemeral keeps no session files. For GitHub, the official Codex GitHub Action runs codex exec behind a proxy for your key.
Version 0.172.0: What Actually Changed on 24 November 2026
The latest stable release, rust-v0.172.0, landed at 00:03 UTC on 24 November 2026. It is a startup-latency and polish release, not a model release — nothing in it changes the model catalogue. The changes that matter are a new MCP default, terminal navigation improvements, and fixes for resumed and remote sessions.
Lazy MCP startup is the headline: optional stdio servers with a cached tool list now start on first use. You can also set an approval reviewer for individual connected app tools in config.toml. The terminal gains tab completion for slash-command arguments, so typing /mcp lo completes to /mcp login; Shift plus Up and Down jump between task groups in the agent command centre; and Page Up and Page Down scroll answer choices taller than the answer area.
On providers, app-server clients can now select Amazon Bedrock Runtime during setup or sign-in. Resume is safer: codex exec resume now restores saved sandbox permissions, working directory and workspace roots unless explicitly overridden. Remote sessions preserve working directories and writable paths when the client and server run on different operating systems. Code Mode now uses gRPC for all host connections, so the old code_mode_host_grpc setting is deprecated.
Codex CLI vs Claude Code
Codex CLI's closest rival is Claude Code from Anthropic, covered on Tech Know on 20 November 2026. The two tools have converged hard in 2026, and the gap between them is now mostly about pricing, the safety model, and how much you care about open source.
| Codex CLI | Claude Code | |
|---|---|---|
| Made by | OpenAI | Anthropic |
| Models | GPT-6.2 Sol, GPT-6.2 Astra, GPT-6.1 Terra, GPT-6 Luna | Claude Opus and Claude Sonnet |
| Licence | Apache 2.0, fully open source (CLI, SDK, app server) | Proprietary; public repo holds issues and plugins |
| Install | Native installer, npm, Homebrew | Native installer, Homebrew, WinGet |
| Sign-in and billing | ChatGPT Plus, Pro, Business, Enterprise; or an API key | Claude plan or Console API; Bedrock supported |
| Safety model | Operating-system sandbox plus approval policy; network off by default | Tiered permission rules and modes |
| Project instructions | AGENTS.md | CLAUDE.md, plus auto memory |
| Parallel work | Subagents, agent command centre | Subagents, agent teams, git worktrees |
| Best for | Strictest default sandbox, open source, ChatGPT subscribers | Deepest harness for long, multi-file work |
The short version: pick Codex CLI when you want the strictest default sandbox and open source; pick Claude Code when you want the deepest harness for long, multi-file work. For local models with no cloud account at all, Ollama, covered on Tech Know on 13 November 2026, remains the free path — and Codex can drive those local models with its --oss flag.
Costs and Limits: What Is Free and What Is Not
The tool is free, but the limits are worth stating plainly. First, it is a terminal tool at heart: no polished graphical interface of its own. Second, it moves fast: stable releases arrive roughly weekly, defaults change, and settings get deprecated, as code_mode_host_grpc just was. Third, it is only as good as the model: the model can still misunderstand a large codebase, invent an API that does not exist, or write a plausible-looking test that tests nothing. Fourth, the sandbox protects your files, not your judgement: a command that deletes a database is not stopped by a file sandbox. Finally, the cloud features need a ChatGPT sign-in; an API key alone does not unlock them.
Who Should Use It, and Who Should Not
Codex CLI is worth learning if you write code and you already pay for ChatGPT Plus or Pro, or if you want an open-source agent you can inspect and modify. It is the right tool if you work in the terminal anyway, want the strictest default sandbox of any major coding agent, and want to automate coding work in scripts, where codex exec shines. It is not the right starting point if you do not code and only want to chat with an AI — the ChatGPT app itself will serve you better. It is not the tool for running models locally with no account — Ollama or LM Studio are, though Codex can drive them. It is not the tool for training a model; for that, use Transformers, covered on Tech Know on 25 November 2026. And it is not the tool for serving hundreds of users at once; for that, use vLLM, which is next in this series after OpenHands and AnythingLLM.
How to Try Codex CLI Safely
Trying Codex CLI takes an evening. The safest path is a throwaway project first: create a small test repository, install the tool, sign in, and ask it to add a feature you can verify by eye.
Three safety habits: never run it with the no-guard-rails flag outside an isolated container; keep it in a Git repository and commit before each session; and check the version you install — v0.172.0 is current at the time of writing, but stable releases arrive roughly weekly.
Frequently Asked Questions
Is Codex CLI really free?
The tool is free and open source under Apache 2.0 — no charge for the download, no paid tier. You pay for the model behind it, through a ChatGPT plan or an API key.
What is the difference between Codex CLI and Codex Cloud?
Codex CLI runs on your machine, against your files, and you watch every step. Codex Cloud is the hosted service that runs tasks on OpenAI's machines while you walk away. The CLI is open source; the cloud service is not.
What is the licence, exactly?
The CLI, the SDK and the app server are Apache 2.0 — genuinely open source, free for commercial use. The IDE extension, the desktop app and Codex Cloud are closed source.
Which model does Codex CLI use by default?
GPT-6.2 Sol, since v0.171.0 on 20 November 2026. GPT-6.2 Astra is the most capable, and GPT-6 Luna the most efficient. Switch with /model in a session.
What changed in version 0.172.0?
Released 24 November 2026, v0.172.0 is a startup-latency and polish release: lazy MCP startup, per-tool approval reviewers, slash-command tab completion, Amazon Bedrock Runtime as a provider choice, and safer resume of sandbox permissions. No model change.
Do I need a ChatGPT subscription to use it?
For the full tool, effectively yes — Plus at 20 dollars a month or higher unlocks the CLI. An API key works instead, but loses the cloud features. The --oss flag runs a local open model through LM Studio or Ollama with no account at all.
Is my code safe when Codex CLI runs?
By default it can write only inside your workspace, has no network access, and keeps .git, .agents, .codex and .aws read-only. Since v0.169.0 it also refuses project configuration and MCP servers in untrusted directories unless you pass --trust.
What is AGENTS.md?
The project's instruction file that Codex reads before doing any work: build and test commands, code style, things it must never do. /init writes a starter file.
Can I use Codex CLI in scripts and CI?
Yes, with codex exec: it runs once without the interface, prints progress to standard error and only the final message to standard output, so you can pipe it. It runs read-only by default and supports JSON Lines output, output schemas and resume.
Should I use Codex CLI or Claude Code?
Pick Codex CLI for the strictest default sandbox, open source, and if you already pay for ChatGPT. Pick Claude Code for the deepest harness for long, multi-file work.
The Bottom Line
Codex CLI is the most approachable way into agentic coding that OpenAI has shipped: a free, open-source terminal tool with about 136,000 stars and 21,500 forks, and the strictest default sandbox of any major coding agent. Its current release, v0.172.0 from 24 November 2026, defaults to GPT-6.2 Sol, and the tool itself costs nothing — the bill is the ChatGPT plan or the API key behind it.
The verdict is straightforward. If you already pay for ChatGPT Plus and you write code in a terminal, install it tonight and try it on a throwaway project: read the diffs, keep it in a Git repository, and let it earn your trust one reviewed change at a time. If you want no cloud account at all, pair Codex with a local model through Ollama. The terminal agent is no longer an experiment. At 136,000 stars, it is the way a growing share of developers now write code.
By Umar Farooq, Tech Know.


0 Comments