← All posts

How to Install Codex CLI on Mac (and Set Up Your Terminal)

How to install OpenAI's Codex CLI on a Mac: Homebrew, npm or the install script, signing in with ChatGPT, AGENTS.md, and a terminal setup that helps.

To install Codex CLI on a Mac, run brew install --cask codex if you use Homebrew, or npm install -g @openai/codex if you use Node, then type codex in a project folder and choose Sign in with ChatGPT. OpenAI also offers a one-line install script. Codex works on Apple Silicon and Intel Macs and is included with ChatGPT Plus, Pro, Business, Edu and Enterprise plans, or you can use an API key. This guide covers the three install methods, first run, the AGENTS.md file that makes Codex useful in a real repo, and how to set up a terminal for running Codex (and maybe Claude Code) side by side.

Install methods compared
Method Command Good for
Homebrew brew install --cask codex Most Mac users; updates with brew upgrade
npm npm install -g @openai/codex You already manage tools with Node
Install script curl -fsSL https://chatgpt.com/codex/install.sh | sh No Homebrew or Node on the machine

All three give you the same codex command. Pick one and stick to it; two installs on one PATH is the classic "why is it running the old version" bug. Check which one wins with which -a codex.

Codex CLI is open source under the Apache-2.0 license, and prebuilt binaries exist for both Apple Silicon (arm64) and Intel (x86_64) Macs.

First run and sign-in

Move into a project folder and start it:

cd ~/code/my-project
codex

On first launch, pick Sign in with ChatGPT. A browser window opens, you approve, and you are back in the terminal. This uses the usage included in your ChatGPT plan, which is what OpenAI recommends for most people. If you would rather pay per token, you can use an OpenAI API key instead, which takes a little extra setup described in OpenAI's auth docs.

Then ask for something small to get a feel for it: "explain the folder structure" or "add a unit test for the slugify helper." Codex will show what it wants to change and ask for approval based on its current approval mode. Start cautious; loosen it once you trust the workflow.

AGENTS.md: the file that makes Codex good

Codex reads an AGENTS.md file at the root of your repo for project instructions: how to build, how to run tests, conventions, things to avoid. It is the Codex equivalent of Claude Code's CLAUDE.md, and it is the single biggest quality lever you have.

Keep it short and practical:

# AGENTS.md
- Build: npm run build
- Test: npm test (run before saying a task is done)
- Use TypeScript strict mode; no any.
- Never edit files in /generated.

If you also use Claude Code, many teams keep one source of truth and point the other file at it. Our CLAUDE.md best practices apply almost word for word to AGENTS.md.

Settings like your default model live in ~/.codex/config.toml.

Common install problems
  • command not found: codex: open a new terminal window. With npm, make sure your global npm bin folder is on your PATH.
  • npm EACCES errors: do not use sudo npm. Use Homebrew or the install script instead.
  • Sign-in page never opens: copy the URL Codex prints into your browser.
  • Wrong account or plan: sign out and back in, and check that your ChatGPT plan includes Codex.
Set up your terminal for Codex

Codex runs in any terminal, including the built-in Terminal app. A few things make long sessions nicer:

  • A readable font and size. Agent output is dense. See our best monospace fonts list.
  • Option as Meta in Terminal or iTerm2 settings, so Option-key shortcuts work in terminal apps generally.
  • tmux if you run Codex on a remote machine and want sessions to survive a disconnect. Our tmux guide is written for Claude Code but the config is the same.
  • A way to watch several sessions. Codex users increasingly run more than one task at a time, often alongside Claude Code or Gemini CLI.

That last point is where MOLTamp fits. It is a skinnable terminal shell for AI coding agent CLIs on Mac, and it is agent-agnostic: Codex, Claude Code, Gemini CLI, Aider and others all run in it unchanged. Each session gets a tab (up to 50), attention badges flag which one finished or is waiting on an approval, and you get a desktop notification when a session goes quiet while you are in another app. Skins, widgets and visualizers make it yours. It is free to use with every feature working; a one-time $10 license removes a recurring popup. See the MOLTamp page for Codex CLI or download MOLTamp.

For a deeper comparison of terminals, read best terminal for Codex CLI. Deciding between agents? Claude Code vs Codex CLI and Gemini CLI vs Codex CLI cover the trade-offs.

FAQ

Is Codex CLI free? The CLI is free and open source. Using it requires a ChatGPT plan that includes Codex (Plus, Pro, Business, Edu or Enterprise) or an OpenAI API key with billing.

How do I install Codex CLI with Homebrew? Run brew install --cask codex. Update later with brew upgrade codex.

Does Codex CLI work on Intel Macs? Yes. OpenAI publishes builds for both Apple Silicon and Intel Macs.

What is AGENTS.md in Codex? A Markdown file at the root of your repo with project instructions, such as build and test commands and coding conventions. Codex reads it automatically.

Can I run Codex CLI and Claude Code at the same time? Yes. They are separate tools and do not conflict. Many developers run both in separate tabs; a terminal like MOLTamp shows which session needs attention.