# Codex CLI

The Codex CLI is OpenAI's agent that runs in your terminal and works on the files in a folder. What it does, how to start it and how to undo its edits.

**Definition:** The Codex CLI is OpenAI's AI agent for the terminal, which you start in a folder and ask in plain language to read files, edit them and run commands there.

## What it does

Start Codex in a folder and it works on what's there: it reads the files, makes the edits you ask for and runs tools installed on your computer. You sign in with your ChatGPT account for subscription access, or with an API key for usage-based access.

```prompt
Turn the notes in lesson-03.md into a short lesson.
```

## Instructions and undo

- **Standing instructions** go in an [AGENTS.md](/glossary/agents-md) file. Codex reads it before doing any work.
- **Undo** comes from Git. The CLI lists no undo or rewind command, and its docs say to create Git checkpoints before and after a task so you can revert changes. Ask it for the [Git diff](/glossary/git-diff) of the folder and it shows the changes, new files included.

## In Flywrite

Codex runs from its own launcher in Flywrite's terminal: press ⌃3 (the default, customizable). It doesn't see the open file or selection on its own, so @-mention the file in your prompt, or select text and press ⌘⇧L to [send that selection to the terminal](/guides/send-selection-to-cli-agent). Flywrite's automatic [checkpoint](/glossary/checkpoint) doesn't run for Codex, so press ⌘⇧C before you start it. You use your own ChatGPT plan or API key, with no Flywrite AI fee. More in [Writing with Codex](/docs/writing-with-codex) and the guide to [course lessons with the Codex CLI](/guides/codex-cli-course-lessons).

## Questions

### Is the Codex CLI the same as Codex in ChatGPT?

It's one of several Codex surfaces. The CLI runs in your terminal on the files in a folder; the Codex desktop app, the IDE extension and Codex cloud are the others.

### How do I undo what Codex changed?

The Codex CLI has no undo command of its own, and its docs advise a Git checkpoint before and after each task. Restore from that checkpoint to take the changes back.

## Sources

1. [OpenAI Codex docs: Codex CLI](https://learn.chatgpt.com/docs/codex/cli), checked 2026-11-10
2. [OpenAI Codex docs: Authentication](https://learn.chatgpt.com/docs/auth), checked 2026-11-04
3. [OpenAI Codex docs: Developer commands (CLI)](https://learn.chatgpt.com/docs/developer-commands?surface=cli), checked 2026-11-17
4. [OpenAI Codex docs: Custom instructions with AGENTS.md](https://learn.chatgpt.com/docs/agent-configuration/agents-md), checked 2026-11-10
5. [Flywrite docs: Writing with Codex](/docs/writing-with-codex), checked 2026-11-17

---

This is the Markdown copy of https://flywrite.app/glossary/codex-cli.
