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 --version

Expected: 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 | sh

Expected: The installer completes without errors. Close and reopen the terminal if the command is not yet available.

3. Verify the installation

codex --version

Expected: 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
codex

Expected: 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:

/init

Expected: 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 status

Useful commands

CommandPurpose
codexStart an interactive session.
/statusShow session configuration.
/modelChoose an available model and reasoning effort.
/reviewReview 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.