Codex CLI is OpenAI’s terminal coding agent. It can inspect a repository, edit files, run local tools, and help review changes. This guide uses the current official installer and signs in through the CLI—there is no need to paste a secret into a project file.
Before you begin: Use Ubuntu with an internet connection and a supported OpenAI/ChatGPT sign-in method. Run Codex only inside projects you trust.
1. Check your terminal tools
sudo apt update
sudo apt install -y curl git
git --version
curl --versionExpected: Ubuntu reports installed versions for Git and curl.
2. Install Codex CLI
Run the official installer exactly as shown:
curl -fsSL https://chatgpt.com/codex/install.sh | shExpected: The installer completes without errors. Close and reopen the terminal if the command is not yet available.
3. Verify the installation
codex --versionExpected: A Codex version number, for example codex x.y.z.
4. Open a project and connect your account
mkdir -p ~/Projects/demo-app
cd ~/Projects/demo-app
git init
codexExpected: Codex opens an interactive terminal session and presents an available sign-in method. Choose Sign in with ChatGPT (or another offered method), complete the browser flow, then return to the terminal. Never share your account password or access token in a repository.
5. Run a first, read-only task
Inside Codex, paste this prompt:
Explain this project structure. Do not edit files or run commands.Expected: Codex describes the directory and files it can inspect. This is a safe way to become familiar with a repository before making changes.
6. Create project instructions
Ask Codex to generate a project instruction file:
/initExpected: Codex proposes an AGENTS.md file. Review it before accepting; it should contain only project-specific development and test instructions.
7. Work safely
Use /permissions to see or adjust what Codex can do, and keep Git checkpoints around agent work:
git status
git add -A
git commit -m "Checkpoint before Codex task"After an edit, inspect the result before committing:
git diff
git statusUseful commands
| Command | Purpose |
|---|---|
codex | Start an interactive session. |
/status | Show session configuration. |
/model | Choose an available model and reasoning effort. |
/review | Review changes before committing. |
codex exec "explain this project" | Run a repeatable non-interactive task. |
For changes in installation or account availability, refer to the official OpenAI Codex CLI documentation.
