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.
Method 1: npm (Recommended)
# Check Node.js version first (need 18+)node --version
# Install Codex globallynpm install -g @openai/codex
# LaunchcodexOn my Mac, this just worked. The package installed in seconds.
Method 2: Homebrew
brew install codexThis 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:
- ChatGPT account - Sign in with your existing ChatGPT Plus/Pro/Enterprise subscription
- 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.
# Navigate to a small project firstcd ~/projects/my-small-app
# Start Codexcodex
# 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.
{ "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:
| Model | Use Case | Speed |
|---|---|---|
gpt-5.4 | Complex reasoning, large codebases | Standard |
gpt-5.3-codex-spark | Quick tasks, faster responses | Fast |
To switch models:
# Use default (gpt-5.4)codex
# Specify faster modelcodex --model gpt-5.3-codex-sparkNote: 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 app from CLI with a workspacecodex app ~/projects/my-appThe 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:
# 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.
# Before any Codex sessiongit add -Agit commit -m "checkpoint before codex changes"
# Now safe to experimentcodexI 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.
# Install a skill$skill-installer linear
# Skills auto-detect after installation# Restart Codex if they don't appear immediatelySkills 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:
# Clone the repositorygit clone https://github.com/openai/codex.gitcd codex/codex-rs
# Install Rust (if not already installed)curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -ysource "$HOME/.cargo/env"
# Add Rust componentsrustup component add rustfmt clippy
# Install build helperscargo install justcargo install cargo-nextest
# Buildcargo build
# Runcargo run --bin codex -- "explain this codebase"This is overkill for most users. The npm package is more stable.
What I Wish I Knew Earlier
- Start with small projects - Don’t throw a 100K-line codebase at Codex immediately
- Use suggest mode first - Learn how Codex thinks before trusting auto-mode
- Commit before each session - Git is your undo button
- ChatGPT account > API key - Cloud threads are worth it
Summary
Getting started with Codex 5.4 CLI takes about 5 minutes:
- Install via npm:
npm install -g @openai/codex - Run
codexand sign in with your ChatGPT account - 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:
- 👨💻 OpenAI Codex GitHub
- 👨💻 OpenAI Platform
- 👨💻 Node.js Downloads
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments