# What is OpenAI's Codex CLI, and how does a coding agent work in your terminal?

Date: 2025-04-17 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/what-is-openai-codex-cli/

**Answer:** Codex CLI is a free, open-source coding agent that OpenAI released on April 16, 2025, alongside its o3 and o4-mini models. It runs in the terminal on your own computer, reads your project, proposes or makes code changes and runs commands, with three approval modes that let you decide how much it may do without asking.

Yesterday, in the same announcement that introduced its new reasoning models o3 and o4-mini, OpenAI shared what it calls a new experiment: **Codex CLI**, a small coding agent you run from the terminal on your own computer. The code was published the same day on GitHub under the Apache 2.0 license, which means anyone can read it, change it and reuse it.

The name may sound familiar. In 2021 OpenAI released a model called Codex that turned plain-language requests into code. The project's own FAQ makes clear that the new tool is separate: that older model was retired in March 2023, and Codex CLI is a program that connects today's models to your files.

## What OpenAI released

A **CLI**, or command-line interface, is a program you use by typing commands in a terminal window instead of clicking buttons. Many programmers spend their day in the terminal, running tests, managing code with Git and starting servers. Codex CLI brings an AI assistant into that same window.

In practice you install it with one command, give it your OpenAI API key (the private code that lets a program use OpenAI's models and bills your account), and type a request in plain English. The agent can read your files, propose edits, run commands such as tests, and show you what changed. OpenAI's announcement says you can also pass it screenshots or rough sketches, so you can show it what a screen should look like.

The default model is o4-mini, and the tool works with any model available through OpenAI's Responses API. OpenAI says support for more API models, including GPT-4.1, is on the way. To encourage projects built on it, the company also announced a $1 million program of grants, paid as API credits in blocks of $25,000.

## How a coding agent in the terminal works

A chatbot answers in text, and you copy its code into your project yourself. An **agent** goes a step further: it works in a loop. It reads the relevant files, decides on a step, takes it (editing a file or running a command), looks at the result and decides what to do next, until the task is done or it needs your input.

That power raises an obvious worry: what if the agent deletes the wrong thing? Codex CLI answers with **approval modes**, which set how much it may do on its own:

| Mode | Can do without asking | Asks you first |
|---|---|---|
| Suggest (default) | Read any file in the project | Every file change and every command |
| Auto Edit | Read files and apply edits | Every command |
| Full Auto | Read, write and run commands | Nothing |

Full Auto adds a **sandbox**, a fenced-off area the agent cannot leave. Commands run with network access switched off and can only touch the current folder and temporary files. On a Mac this uses Apple's built-in sandbox system; on Linux the project recommends running it inside a Docker container. Codex CLI also warns you if you start an automatic mode in a folder that Git is not tracking, because Git is your undo button.

You can leave standing instructions in a file called `codex.md` at the root of your project, such as "use tabs, and run `npm test` after each change," and in a personal file for preferences that apply everywhere.

## A worked example

Here is what a first session might look like on a small JavaScript project, step by step:

1. Open the terminal in your project folder and make sure your work is saved in Git.
2. Start Codex CLI in its default Suggest mode with a question rather than a change:

```prompt
codex "Explain how this project is organized, which file starts the app, and how the tests are run."
```

3. Read the explanation and check it against what you know.
4. Ask for one small, testable change: "Write unit tests for the date helper functions and run them."
5. Approve or reject each proposed edit and command as it appears.
6. Review the final difference with `git diff` before you keep anything.

The project page itself suggests requests of this size: converting a component to a newer style, writing tests until they pass, renaming files safely, or explaining what a confusing pattern of text-matching code does.

> **Try it:** Pick a small project you know well and ask Codex CLI, in Suggest mode, only to explain it. Compare its explanation with your own understanding before you let it change a single line.

## Why it matters

Codex CLI is a sign of where coding help is going. It is no longer just autocomplete in an editor; it is an assistant that can carry out a task across several files and check its own work by running the tests. TechCrunch reads it as a small step toward the "agentic software engineer" that OpenAI's chief financial officer, Sarah Friar, has described.

Two choices stand out. It runs locally, next to your code, rather than in a distant data center. And it is open source, so developers can inspect what it sends to the model and adapt it. Requirements are modest but specific: macOS 12 or later, a recent Ubuntu or Debian, or Windows 11 through its Linux subsystem, plus Node.js 22 or newer.

The usual caution applies. TechCrunch points to studies showing that code-writing models often miss security problems and sometimes create new ones. An agent that can run commands deserves the same care you would give a new teammate on their first day.

## How do you try Codex CLI safely on your own project?

Start with a copy or a Git branch of a project that does not hold secrets such as passwords or customer data. Install Node.js 22 or newer, install Codex CLI with npm as the project page describes, and set your API key in the terminal. Remember that every request uses paid API tokens, so watch your usage page during the first sessions.

Stay in the default Suggest mode until you trust how it behaves on your code. Ask for explanations first, then small changes with a clear test, and read each proposed edit. Move to Auto Edit only when you are comfortable, and keep Full Auto for throwaway experiments inside its sandbox. Whatever the mode, review the changes in Git before you merge them, exactly as you would review a colleague's work.

## Sources

- Introducing OpenAI o3 and o4-mini: https://openai.com/index/introducing-o3-and-o4-mini/
- OpenAI Codex CLI (README): https://github.com/openai/codex
- OpenAI debuts Codex CLI, an open source coding tool for terminals: https://techcrunch.com/2025/04/16/openai-debuts-codex-cli-an-open-source-coding-tool-for-terminals/
