OpenAI Codex
A coding agent available through the CLI, desktop app, IDE extension, and web. Codex can inspect repositories, edit files, run commands, and work within approval and sandbox controls.
Use a trusted project, back up your work, and review changes and commands before accepting them.
What it is and what it does
Codex is an AI coding agent that can work from your terminal, desktop app, IDE, or web. It can inspect repositories, edit files, run development commands, and use configured tools. Treat it as a collaborator that needs context and supervision; verify changes before relying on them.
Install
Use the official installer for your platform, or install the CLI with npm.
Windows
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"Official CLI installer. npm is also supported: npm install -g @openai/codex
macOS
curl -fsSL https://chatgpt.com/codex/install.sh | shOfficial CLI installer. Homebrew is also supported: brew install --cask codex
Linux
curl -fsSL https://chatgpt.com/codex/install.sh | shOfficial CLI installer. npm is also supported: npm install -g @openai/codex
Official source: OpenAI Codex repository ↗
First time setup
- Run
codexin your terminal. - Select Sign in with ChatGPT if you have an eligible ChatGPT plan, or configure API key access if you are using the API path.
- Review approval and sandbox settings before allowing changes.
- Add
AGENTS.mdwhen the project needs persistent instructions.
Run in a project folder
- Change into the repository root.
- Check
git status. - Run
codexand start with a read only project overview.
Copy ready prompts
Replace bracketed details with your goal, constraints, or error message.
Explain this repo and how to run it. Do not edit.
Investigate [bug], explain its cause, then fix minimally.
Implement [feature] using the existing architecture. Ask before adding dependencies.
Review my diff for bugs and security issues. Do not edit.
Add tests for [behavior] and run focused tests.
Refactor [module] for [goal], preserving behavior.
Diagnose [command/error] and fix its root cause.
Update docs for [feature] using verified behavior.
Common errors and fixes
Restart the terminal and check that the installed CLI directory is on PATH.
Run codex again and complete browser authentication, or check the selected API configuration.
Review the current approval and sandbox settings, then allow only the action you understand.
If your config uses the old approval_policy = "untrusted" setting, remove it. Current Codex versions no longer support that policy.
Tips for best results
- Commit first.
- Request a plan.
- Define success criteria.
- Inspect diffs.
- Run the relevant checks.