Skip to content

How to Get Started with OpenAI Codex 5.4 CLI

I recently started using OpenAI Codex 5.4 CLI as my AI coding assistant. The setup was straightforward, but I hit a few snags along the way. Here’s what I learned.

Why Codex CLI?

Most AI coding tools run in a browser. You copy-paste code back and forth. It gets tedious.

Codex CLI works directly in your terminal. It reads your files, understands your project structure, and makes changes locally. No more context switching between browser and editor.

The main advantage: GPT-5.4’s 1M token context window. Codex can understand large codebases without you having to explain everything.

Installation

I tried two methods. Here’s what worked.

install-via-npm.sh
# Check Node.js version first (need 18+)
node --version
# Install Codex globally
npm install -g @openai/codex
# Launch
codex

On my Mac, this just worked. The package installed in seconds.

Method 2: Homebrew

install-via-brew.sh
brew install codex

This also works but the npm version felt more straightforward. Pick whichever you prefer.

Authentication

When you first run codex, it prompts you to sign in. You have two options:

  1. ChatGPT account - Sign in with your existing ChatGPT Plus/Pro/Enterprise subscription
  2. API key - Use an OpenAI API key

I chose the ChatGPT account option. Here’s why: API key users lose access to cloud threads. Cloud threads let you sync conversations across devices. If you work from multiple machines, this matters.

First run flow:

$ codex
Welcome to Codex!
? How would you like to sign in?
> ChatGPT Account
API Key
[Opens browser for OAuth login]
Signed in as: [email protected]
? What would you like to work on?

My First Mistake

I jumped straight into a large project. Codex started analyzing files… and then asked me to confirm every single file read.

Lesson learned: Start smaller.

first-steps.sh
# Navigate to a small project first
cd ~/projects/my-small-app
# Start Codex
codex
# Simple prompt to test
> "Tell me about this project"

This gave me a feel for how Codex works without overwhelming it.

The Approval Modes

Codex modifies your files. This scared me at first. But there are safety controls:

  • Suggest mode - Codex proposes changes, you approve each one
  • Auto-edit mode - Codex makes changes automatically
  • Full-auto mode - Codex runs commands too

I started with suggest mode. It’s the safest option while learning.

config.json
{
"model": "gpt-5.4",
"approvalMode": "suggest",
"fullAutoErrorMode": "ask-user",
"notify": true
}

Place this file in your project root. Codex reads it automatically.

Model Selection

Codex 5.4 offers two models:

ModelUse CaseSpeed
gpt-5.4Complex reasoning, large codebasesStandard
gpt-5.3-codex-sparkQuick tasks, faster responsesFast

To switch models:

model-selection.sh
# Use default (gpt-5.4)
codex
# Specify faster model
codex --model gpt-5.3-codex-spark

Note: gpt-5.3-codex-spark requires a Pro subscription.

Mac Desktop App

OpenAI also offers a Mac app. It’s more visual but does the same thing.

launch-mac-app.sh
# Launch app from CLI with a workspace
codex app ~/projects/my-app

The app shows a split view: conversation on one side, file preview on the other. Useful if you prefer GUIs over terminal.

Current limitation: Apple Silicon only. Windows app is “coming soon.”

Useful First Prompts

After setup, here are prompts that worked well for me:

example-prompts.txt
# Understanding existing code
"Explain the architecture of this project"
# Finding issues
"Review this codebase for security vulnerabilities"
# Simple generation
"Add error handling to the API calls in src/api/"
# Debugging
"Why is the login test failing?"

Start with “explain” prompts. They help Codex build context without making changes.

The Git Checkpoint Rule

This is important: Always commit before asking Codex to make changes.

Codex modifies files directly. There’s no undo buffer. If it messes something up, you need Git to recover.

safety-first.sh
# Before any Codex session
git add -A
git commit -m "checkpoint before codex changes"
# Now safe to experiment
codex

I learned this the hard way. Codex refactored a function incorrectly, and I had no clean state to return to. Git is your safety net.

Skills System

Codex has a skills feature I haven’t fully explored yet. Skills are reusable modules for common tasks.

skills-example.sh
# Install a skill
$skill-installer linear
# Skills auto-detect after installation
# Restart Codex if they don't appear immediately

Skills extend Codex with domain-specific knowledge. Think of them as plugins.

Building from Source

If you want bleeding-edge features, you can build Codex from source:

build-from-source.sh
# Clone the repository
git clone https://github.com/openai/codex.git
cd codex/codex-rs
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
# Add Rust components
rustup component add rustfmt clippy
# Install build helpers
cargo install just
cargo install cargo-nextest
# Build
cargo build
# Run
cargo run --bin codex -- "explain this codebase"

This is overkill for most users. The npm package is more stable.

What I Wish I Knew Earlier

  1. Start with small projects - Don’t throw a 100K-line codebase at Codex immediately
  2. Use suggest mode first - Learn how Codex thinks before trusting auto-mode
  3. Commit before each session - Git is your undo button
  4. ChatGPT account > API key - Cloud threads are worth it

Summary

Getting started with Codex 5.4 CLI takes about 5 minutes:

  1. Install via npm: npm install -g @openai/codex
  2. Run codex and sign in with your ChatGPT account
  3. Navigate to a project and start prompting

The real power comes from GPT-5.4 understanding your entire codebase. It’s not just autocomplete—it’s a reasoning engine that works alongside you.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments