From First Command to Production Workflows
- About This Book
Introduction
- What This Book Covers
- Who This Book Is For
- How to Read This Book
- A Note on Safety
Chapter 1: What Is Codex CLI?
- From TypeScript to Rust: The Evolution of Codex
- Architecture Overview: How Codex Works Under the Hood
- The Five Surfaces: CLI, Desktop, Web, IDE Extension and Cloud
- When to Use Codex CLI (and When Not To)
- Ecosystem Context: Codex vs. Claude Code, Cursor, Copilot
- Acknowledging Codex CLI’s Shortcomings
Chapter 2: Installation and First Run
- System Requirements and Prerequisites
- Installing via npm, Homebrew, Install Script, or Binary
- Windows Installation: Native and WSL2
- Verifying Your Installation
- Your First Interactive Session
Chapter 3: Authentication and Credential Management
- ChatGPT OAuth Sign-In Flow
- API Key Authentication
- Enterprise Access Tokens
- Credential Storage: File vs. Keyring
- CI/CD Authentication Patterns
- Troubleshooting Auth Failures
Chapter 4: Configuration Deep Dive
- Config File Locations and Precedence
- Core Settings: Model, Sandbox, Approval Policy
- Feature Flags and Experimental Capabilities
- Profiles for Different Workflows
- Custom Model Providers (Azure, Bedrock, Ollama, OpenRouter)
- Enterprise Managed Configuration
Chapter 5: The Interactive Terminal Experience
- Starting an Interactive Session
- Slash Commands Reference
- Keyboard Shortcuts and Navigation
- Image Input and Visual Context
- Session Management: Resume, Clear and Compact
- TUI Customization and Themes
Chapter 6: Sandboxing, Permissions and Security
- Sandbox Modes: read-only, workspace-write, danger-full-access
- Approval Policies: untrusted, on-request, never, granular
- Auto-Review: Delegating Trust to an AI Reviewer
- Network Access Controls and Proxy Configuration
- OS-Level Sandboxing: Seatbelt, bwrap, Windows Sandbox
- Security Best Practices and Common Pitfalls
Chapter 7: Project Context with AGENTS.md
- What Is AGENTS.md and Where It Lives
- Writing Effective Project Instructions
- Layered Context: Global, Project and Override Files
- Context Window Management and Token Budgeting
- The .codexignore File
- Cross-Tool Portability with AGENTS.md
Chapter 8: Skills – Reusable Task Expertise
- What Are Skills and How They Work
- The SKILL.md Format and Directory Structure
- Skill Discovery: Implicit vs. Explicit Invocation
- Creating Skills with $skill-creator
- Installing and Distributing Skills
- Best Practices for Writing Effective Skills
Chapter 9: Model Context Protocol (MCP) Integration
- What Is MCP and Why It Matters
- Configuring MCP Servers in config.toml
- Managing Servers via codex mcp Commands
- STDIO vs. Streamable HTTP Servers
- Tool Control: Enabling, Disabling and Approval Modes
- Real-World MCP Server Recipes and Walkthroughs
Chapter 10: Subagents and Multi-Agent Orchestration
- How Subagents Work: Architecture and Benefits
- Triggering Subagents: Prompts, AGENTS.md and Skills
- Custom Agent Definitions in TOML
- Parallel Execution Patterns and Git Worktrees
- CSV Batching for High-Volume Tasks
- Multi-Agent Best Practices and Cost Management
Chapter 11: Non-Interactive Mode and Automation
- codex exec: Headless Execution
- JSON Output and Schema Validation
- Session Resumption in Automated Workflows
- GitHub Actions Integration (openai/codex-action)
- Scripting Patterns and Bash Wrappers
- Stdin Piping and Prompt Composition
Chapter 12: Code Review and Git Integration
- The /review Command: Modes and Scope
- Pre-Commit Review Workflows
- GitHub Pull Request Reviews with @codex review
- Branch and Commit Inspection
- Git Checkpoint Strategies
- Custom Review Guidelines
Chapter 13: Codex Cloud and Remote Execution
- What Is Codex Cloud and When to Use It
- codex cloud Commands: exec, list, apply
- Cloud Environment Setup Scripts and Container Caching
- Remote SSH Connections
- Best-of-N Attempts and Retry Strategies
- Cloud vs. Local: Decision Framework
Chapter 14: Model Selection and Reasoning Configuration
- The GPT-5.6 Family: Sol, Terra, Luna
- Legacy Models: GPT-5.4, GPT-5.3-Codex, Spark
- Known Model Limitations
- Reasoning Effort Levels: none to ultra
- Model Verbosity and Summary Modes
- Cost vs. Capability Trade-Offs
- Per-Agent and Per-Task Model Selection
Chapter 15: Performance Optimization
- Understanding Your Token Budget
- Context Compaction: How It Works
- Reducing MCP Server Overhead
- File Exclusion Strategies with .codexignore
- Session Length Management
- Cost Estimation and Monitoring
Chapter 16: Troubleshooting and Common Pitfalls
- Authentication and Billing Errors
- Sandbox and Permission Failures
- Context Window Overflow
- MCP Server Timeouts and Connection Issues
- Installation and Environment Problems
- The Diagnostic Mindset: Systematic Debugging
Chapter 17: Real-World Workflows and Case Studies
- Solo Developer: Full-Stack Feature Implementation
- Team Workflow: Code Review Pipeline Integration
- CI/CD: Automated Testing and Bug Fixing
- Legacy Codebase Refactoring
- Documentation Generation and Maintenance
- Security Audit Workflows
Chapter 18: Migration Strategies – From Other Tools to Codex CLI
- Why Migrate? The Business Case
- Migrating from Claude Code
- Migrating from Cursor
- Migrating from GitHub Copilot
- Migrating from Aider
- Team Migration: Onboarding Without Disruption
- Credential and Provider Transitions
- When Not to Migrate
Chapter 19: Advanced Techniques and Future Directions
- Codex as an MCP Server for External Orchestration
- The OpenAI Agents SDK Integration
- Record and Replay: Building Skills from Sessions
- Plugins: Distributable Skill Bundles
- Hook Systems and Event-Driven Automation
- The Road Ahead: What to Watch For