Codex Cheat Sheet
This appendix contains a command cheat sheet, frequently asked questions, and version update information.
Command Cheat Sheet
CLI Basic Commands
| Command | Description |
|---|---|
codex | Launch interactive TUI |
codex "任务" | Launch and execute specified task |
codex exec "任务" | Execute task in non-interactive mode |
codex --version | Display version information |
codex --help | Display help information |
Slash Commands
| Command | Description |
|---|---|
/model <name> | Switch model |
/fast | Toggle Fast mode |
/plan | Enter plan mode |
/review | Review code changes |
/new | Start new session |
/resume | Resume historical session |
/fork | Clone current session |
/compact | Compact context |
/status | Show session status |
/clear | Clear screen |
/quit | Exit Codex |
/approval <mode> | Toggle approval mode |
CLI Arguments
| Argument | Description |
|---|---|
-m <model> | Specify model |
--sandbox <mode> | Set sandbox mode |
--approval-mode <mode> | Set approval mode |
-i <file> | Attach image |
-o <file> | Output to file (exec) |
--full-auto | Fully automatic execution |
--ephemeral | Do not save session files |
--reasoning-effort <level> | Reasoning effort |
Shell Command Execution
| Format | Description |
|---|---|
! <command> | Execute Shell command in Codex |
! git status | View Git status |
! npm test | Run tests |
Configuration File Paths
Configuration File Locations
| File | Path | Purpose |
|---|---|---|
| User configuration | ~/.codex/config.toml | Global default configuration |
| Project configuration | .codex/config.toml | Project-specific configuration |
| Project instructions | AGENTS.md | Project behavior guidelines |
| Log directory | ~/.codex/log/ | Run logs |
| Session directory | ~/.codex/sessions/ | Session records |
Skills Directory
| Location | Path |
|---|---|
| Project-level | .agents/skills/ |
| User-level | ~/.agents/skills/ |
| System-level | /etc/codex/skills/ |
Keyboard Shortcuts
CLI Shortcuts
| Shortcut | Function |
|---|---|
Enter | Send message |
Shift+Enter | New line |
Ctrl+C | Interrupt operation |
Ctrl+C (两次) | Exit Codex |
Ctrl+D | Exit (when input is empty) |
Ctrl+R | Search history |
Up/Down | Browse history |
Tab | Auto-completion |
Esc Esc | Edit previous message |
Ctrl+O | Copy last reply |
App Shortcuts
| Shortcut | Function |
|---|---|
Cmd/Ctrl+N | New session |
Cmd/Ctrl+Shift+N | New window |
Cmd/Ctrl+W | Close window/tab |
Cmd/Ctrl+[ | Previous tab |
Cmd/Ctrl+] | Next tab |
Frequently Asked Questions
Installation and Authentication
Q: How do I install Codex CLI?
Use npm or Homebrew:
npm install -g @openai/codex # 或 brew install codex
Q: How to authenticate on first use?
Running the codex command automatically opens a browser for authentication. Log in with a ChatGPT account or API Key.
Q: Windows support?
Native Windows support is experimental; WSL2 is recommended for the best experience.
Usage Issues
Q: How to view current configuration?
Use/statuscommand to view the current session's configuration and status.
Q: How to disable the alternate screen?
Usecodex --no-alt-screenor configurealternate_screen = "never"。
Q: What if the command is not found?
Make sure PATH includes the npm global installation directory, or use Homebrew for installation.
Q: How to view logs?
Logs are located in the~/.codex/log/directory.
Feature Issues
Q: What is the difference between exec and interactive mode?
exec exits after a single execution, suitable for automation scripts; interactive mode supports continuous conversation, suitable for daily development.
Q: How to resume a historical session?
Use/resumecommand orcodex resume --last。
Q: Can GitHub Actions modify files?
Yes, set sandbox: workspace-write.
Q: How to authenticate in CI/CD?
Use the CODEX_API_KEY environment variable, stored as Secrets.
Security Issues
Q: How to prevent Codex from deleting important files?
Use read-only or workspace-write sandbox mode, and configure Rules to prohibit dangerous commands.
Q: Is full-auto mode safe?
full-auto automatically executes all operations, including deleting files; use with caution.
Q: How to handle sensitive data?
Use Secrets storage, available only in setup scripts.
Version Updates
Recent Updates
| Version | Date | Update Content |
|---|---|---|
| v1.5.0 | 2026-04 | Added support for GPT-5.4 series models |
| v1.4.0 | 2026-03 | Improved Worktree functionality |
| v1.3.0 | 2026-02 | Added Review Mode |
| v1.2.0 | 2026-01 | Optimized MCP Server support |
| v1.1.0 | 2025-12 | Added GitHub integration |
| v1.0.0 | 2025-11 | Codex officially released |
Updating CLI
Update Commands
npm install -g @openai/codex@latest
# Homebrew update
brew upgrade codex
# View current version
codex --version
Related Resources
Official Resources
| Resource | Address |
|---|---|
| Official Documentation | https://developers.openai.com/codex |
| GitHub | https://github.com/openai/codex |
| Codex Web | https://chatgpt.com/codex |
| Discord | https://discord.gg/openai |
Tutorial Series
| Chapter | Title | Content |
|---|---|---|
| 01 | Codex Getting Started | Core capabilities, plan comparison |
| 02 | Core Concepts | Prompt、Thread、Context、Sandbox |
| 03 | Desktop Application | App features, Review mode |
| 04 | IDE Extension | VS Code、Cursor、Windsurf |
| 05 | Command Line Tool | CLI installation, TUI, Approval |
| 06 | Cloud Version | Web interface, Environments |
| 07 | Integration & Connectivity | GitHub、Slack、Linear、MCP |
| 08 | Configuration & Customization | Config、Rules、Skills |
| 09 | Automation & CI/CD | exec、SDK、GitHub Action |
| 10 | Workflow Modes | Development workflow, refactoring, bug fixes |
| 11 | Prompt Best Practices | Prompt structure, task decomposition |
| 12 | Security & Enterprise Management | Sandbox, permissions, audit logs |
| 13 | Model Selection | GPT-5.4 series, reasoning strength |
| 14 | Appendix | Command quick reference, FAQ |
Glossary
| Term | Description |
|---|---|
| Agent | Codex's core execution unit, capable of understanding tasks and executing operations |
| Prompt | Task instructions sent by the user to Codex |
| Thread | Session sequence, containing complete conversation history |
| Context | Scope of information available to Codex, including files, conversations, and configuration |
| Sandbox | Isolated execution environment, restricting the scope of Codex's operations |
| Approval | Approval policies, controlling confirmation behavior before executing operations |
| AGENTS.md | Project instruction files, defining Codex's behavior guidelines |
| Skill | Reusable custom capability modules |
| Subagent | Sub-agents, used for parallel processing of complex tasks |
| Rules | Rules engine, defining command execution permissions |
| MCP | Model Context Protocol, a protocol for connecting external tools |
| Worktree | Git worktree, used for isolating working directories for different tasks |
Feedback and Support
Getting Help
- Usage
/helpUse commands to view built-in help - Visit official documentation for detailed instructions
- Join the Discord community to communicate and discuss
Reporting Issues
- GitHub Issues:Submit bugs or feature requests
- Submit suggestions through the Codex feedback feature
Other ExtensionsCodex is continuously updated and iterated; follow official channels for the latest information.