YouTip LogoYouTip

Codex Cli

Codex CLI is the official command line tool, written in Rust, lightweight and efficient, suitable for terminal enthusiasts. * * * ## Install CLI Codex CLI supports macOS, Linux, and Windows (experimental). ### npm Installation ## Global npm Installation # Install using npm npm install -g @openai/codex # Verify installation codex --version ### Homebrew Installation ## Homebrew Installation # macOS using Homebrew brew install codex ### Update CLI ## Update Version # npm update npm install -g @openai/codex@latest # Homebrew update brew upgrade codex * * * ## First Use The first time you run Codex, it will guide you through authentication: ## Start Codex # Start interactive interface codex # Or specify initial task codex "Explain this project structure" Codex will open your browser for authentication: 1. Log in with your ChatGPT account 2. Or use an OpenAI API Key 3. Return to the terminal after authorization to continue * * * ## Interactive TUI The CLI enters Terminal User Interface (TUI) mode by default, providing an immersive experience. ### TUI Interface Areas | Area | Function | | --- | --- | | **Message Area** | Displays conversation history, tool calls, execution results | | **Input Area** | Bottom input box for sending Prompts | | **Status Bar** | Displays model, context usage, thread information | ### TUI Mode Settings ## TUI Configuration # ~/.codex/config.toml # Alternate screen mode alternate_screen = "auto" # auto | always | never # Preserve scroll history when alternate screen is disabled # alternate_screen = "never" > Alternate screen mode allows Codex to use an independent screen, restoring the original terminal state upon exit. * * * ## Approval Mode Approval mode controls Codex's confirmation behavior before executing operations. ### Four Modes | Mode | Description | Behavior | | --- | --- | --- | | **suggest** | Suggest mode | Codex provides suggestions but does not execute | | **auto-edit** | Auto edit | Automatically executes file edits, commands require confirmation | | **full-auto** | Fully automatic | Automatically executes all operations (use with caution) | | **interactive** | Interactive mode | Asks before sensitive operations (default) | ## Set Approval Mode # Specify mode via command line codex --approval-mode full-auto # Or switch during session /approval full-auto > In full-auto mode, Codex will automatically execute all operations, including deleting files. Please use with caution. * * * ## Sandbox Mode Sandbox mode limits Codex's file and command access scope. | Mode | File Modification | Command Execution | Network Access | | --- | --- | --- | --- | | **read-only** | Prohibited | Prohibited | Prohibited | | **workspace-write** | Workspace only | Allowed | Prohibited | | **danger-full-access** | Allowed | Allowed | Allowed | ## Set Sandbox Mode # Read-only mode codex --sandbox read-only # Workspace write mode (recommended) codex --sandbox workspace-write # Full access mode (dangerous) codex --sandbox danger-full-access * * * ## Slash Commands The CLI provides rich slash commands: | Command | Function | | --- | --- | | `/model` | Switch model (e.g., /model gpt-5.4-mini) | | `/fast` | Switch to Fast mode | | `/plan` | Enter plan mode | | `/review` | Review code changes | | `/new` | Start new session | | `/resume` | Resume historical session | | `/fork` | Clone current session to new thread | | `/compact` | Compress context history | | `/status` | Display session status | | `/clear` | Clear screen | | `/quit` | Exit Codex | ### Command Usage Examples ## Slash Commands # Switch model /model gpt-5.4-mini # Plan mode /plan Implement user authentication system # View status /status * * * ## Shell Command Execution Execute Shell commands directly in the CLI: ## Execute Commands # Execute command starting with ! !ls -la # Execute git command !git status # View processes !ps aux ### Command Confirmation Dangerous commands require confirmation: * Delete files (rm) * Terminate processes (kill) * Modify system configuration * * * ## Image Input The CLI supports attaching images as context: ## Attach Images # Attach screenshot codex -i screenshot.png # Attach design mockup codex --image design.png "Implement page based on this design" # Multiple images codex -i img1.png -i img2.png ### Image Use Cases * Screenshot analysis for error messages * UI design mockup to code conversion * Chart data interpretation * * * ## Non-Interactive Mode (exec) Use the exec command to run single tasks, suitable for scripts and CI/CD: ## exec Command # Execute single task codex exec "Review code and output report" # Output to file codex exec "Generate README" -o README.md # Use specific model codex exec -m gpt-5.4-mini "Analyze project structure" # Fully automatic mode codex exec --full-auto "Run tests and fix failures" ### Common exec Parameters | Parameter | Description | | --- | --- | | `-m` | Specify model | | `-o` | Output to file | | `--full-auto` | Fully automatic execution | | `--ephemeral` | Do not save session file | | `--json` | JSON output format | * * * ## Keyboard Shortcuts | Shortcut | Function | | --- | --- | | `Enter` | Send message | | `Shift+Enter` | New line | | `Ctrl+C` | Interrupt operation | | `Ctrl+C (twice)` | Exit Codex | | `Ctrl+D` | Exit (when input is empty) | | `Ctrl+R` | Search history | | `Up/Down` | Browse history | | `Tab` | Auto-complete | | `Esc Esc` | Edit previous message | | `Ctrl+O` | Copy last response | * * * ## FAQ ### Q: Windows support status? Windows native support is experimental; WSL2 is recommended for the best experience. ### Q: How to disable alternate screen? Use `codex --no-alt-screen` or configure `alternate_screen = "never"`. ### Q: Command not found? Ensure PATH includes the npm global installation directory, or use Homebrew installation. ### Q: How to view detailed logs? Logs are located in the `~/.codex/log/` directory.
← Codex IntegrationsCodex App β†’