Black Friday sale: 30% off Flywrite

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.

cd ~/Writing/course
codex
Turn the notes in lesson-03.md into a short lesson.

Instructions and undo

  • Standing instructions go in an 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. Its /diff command shows the Git diff of the folder, 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. Flywrite's automatic 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 and the guide to course lessons with the Codex CLI.

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.

Write with your agent in a writing app.

Buy now