C.W.K.
Stream
Lesson 01 of 11 · published

Install & Authenticate

~12 min · codex, install, auth, openai

Level 0🌱 Novice
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

One npm package, three auth paths

Codex CLI ships as @openai/codex. After install, codex is on your PATH. Like Claude Code, it requires a Git repository (use --skip-git-repo-check for one-off directories). Three authentication paths cover the spectrum from individual to CI.

ChatGPT OAuth via codex login — easiest if you have ChatGPT Plus/Pro. Browser flow, no API key to manage, billing rolls up under your subscription. API key in environmentOPENAI_API_KEY env var, the path for servers and CI. API key via stdin — pipe the key through echo "$KEY" | codex exec ... for jobs where you don't want the key in process listings or shell history.

After install, drop a minimum ~/.codex/config.toml and a global ~/.codex/AGENTS.md, and you're ready. codex status verifies setup.

Code

Install + auth·bash
# Prereqs
node --version    # 18+
git --version

# Install
npm install -g @openai/codex
codex --version

# Auth path A — ChatGPT OAuth (individuals)
codex login

# Auth path B — API key (servers, CI)
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.zshrc
source ~/.zshrc

# Auth path C — stdin (CI without leaking)
aws secretsmanager get-secret-value --secret-id openai-key \
  --query SecretString --output text | \
  codex exec "review src/auth.ts for security issues"

# Verify
cd ~/myproject && codex status
Minimum config.toml + AGENTS.md·bash
mkdir -p ~/.codex

cat > ~/.codex/config.toml <<'EOF'
model            = "gpt-5-codex"
approval_policy  = "on-request"
sandbox_mode     = "workspace-write"

[history]
persistence = "save-all"
EOF

cat > ~/.codex/AGENTS.md <<'EOF'
# Personal Codex Instructions
- Prefer TypeScript over JavaScript
- Tests use Vitest
- Add JSDoc to exported functions
- Functions max 40 lines
EOF

External links

Exercise

Install Codex, authenticate via the path that fits your situation. Drop a minimum ~/.codex/config.toml and ~/.codex/AGENTS.md. Run codex status in a real repo. Capture the output as your install receipt.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.