Select Your Operating System
Commands and environment variables update instantly to match your target shell.
Verify Node.js Runtime & Package Manager
ChatGPT Codex CLI runs on Node.js and requires version 18.0.0 or later (v20 LTS recommended).
Check Installed Node Version
Open your terminal and verify whether Node.js and npm are present and meet the minimum runtime requirements:
nvm install 20 (macOS/Linux) or download the Windows LTS installer from nodejs.org.
Paste the exact output of your node -v command below to verify runtime version compliance:
Install OpenAI ChatGPT Codex CLI Globally
Install the official Codex command-line interface package and ensure its binary is discoverable in your system path.
Install Global CLI Package
Install the package globally via npm. If you encounter permission errors on Unix, configure your user npm prefix or use nvm.
codex: command not found, verify that the npm global binary folder is added to your PATH environment variable, then restart your terminal.
Paste the output of codex --version to verify binary installation:
Configure OpenAI API Authentication
Codex CLI requires an active OpenAI API secret key stored in your shell environment variables.
Set Persistent OPENAI_API_KEY
Generate an API key at platform.openai.com/api-keys and configure it as an environment variable in your profile:
.env file.
Paste your API key prefix (e.g. sk-proj-...) or the confirmation text showing key is active:
Interactive REPL & Sandbox Execution Modes
Launch an interactive pair-programming session and configure workspace sandbox permissions.
Start Codex with Sandbox Protection
Launch Codex in workspace-write mode to restrict file system modifications strictly inside your working project directory:
/help for available commands, /model gpt-4o to switch active model, and /exit to return to your normal terminal shell.
Paste the interactive banner or sandbox mode confirmation text from your terminal:
Non-Interactive Execution & STDIN Piping
Execute single-shot queries and pipe files or terminal outputs into Codex for automated code reviews and CI scripting.
Execute Single Prompt & Pipe File Content
Run single-shot commands using codex exec, or pipe file contents directly into the LLM context:
Paste the response generated by your codex exec command:
Default Preferences & Run It Later Card
Lock in persistent model defaults and save the quick reference card for daily terminal development.
Set Default Model Configuration
Configure your preferred default model and view persistent settings:
Paste the output of codex config list showing your saved preferences:
⚡ Run It Later — Quick Reference
codex
Launches full interactive pair programming terminal agent
codex --sandbox workspace-write
Restricts file modifications strictly inside workspace directory
codex exec "Review git diff"
Executes non-interactive prompt and prints output to stdout
cat file.py | codex exec "Add types"
Pipes standard input stream directly into Codex context
Build Bot Better & Wipe Resistance
Apply profile and workspace protections so an agent cannot casually wipe your home folder or project data. Fleet rule: Hub conversation #31.
An autonomous agent running without boundary constraints executed a recursive delete targeting the user profile. Prompt rules and command-text deny lists (like rm or Remove-Item) fail when paths are passed inside variables or child scripts. BuildBotsBetter requires the complete defense trio: PreToolUse path inspection, off-volume backups, and a practised restore.
1. Per-Agent Onboarding Checklist (Run Once Per Agent)
Onboarding does not end when software installs. Generate and maintain a six-line checklist file for each agent operating on your system:
2. Variable-Limit Delete Guard Demo
Demonstrate why command-text pattern matching misses variable-derived deletions, while true path resolution catches and refuses them:
3. Off-Volume Profile & Data Backup
Back up ChatGPT Codex configuration and profile directory off the OS volume:
4. Practised Restore Drill
Never trust an unverified backup. Run this safe, self-contained restore drill inside your temp folder:
5. Fail-Closed Workspace Policy
Codex runs with danger-full-access on this fleet to allow sqlcmd, hub.py, and DEV_LOG operations. Full access requires the protect_user_folders.py PreToolUse hook in ~/.codex/hooks.json and off-volume backups.
Paste terminal output from the restore drill or variable demo confirming protection: