Codex Cheat Sheet

This appendix contains a command cheat sheet, frequently asked questions, and version update information.


Command Cheat Sheet

CLI Basic Commands

CommandDescription
codexLaunch interactive TUI
codex "任务"Launch and execute specified task
codex exec "任务"Execute task in non-interactive mode
codex --versionDisplay version information
codex --helpDisplay help information

Slash Commands

CommandDescription
/model <name>Switch model
/fastToggle Fast mode
/planEnter plan mode
/reviewReview code changes
/newStart new session
/resumeResume historical session
/forkClone current session
/compactCompact context
/statusShow session status
/clearClear screen
/quitExit Codex
/approval <mode>Toggle approval mode

CLI Arguments

ArgumentDescription
-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-autoFully automatic execution
--ephemeralDo not save session files
--reasoning-effort <level>Reasoning effort

Shell Command Execution

FormatDescription
! <command>Execute Shell command in Codex
! git statusView Git status
! npm testRun tests

Configuration File Paths

Configuration File Locations

FilePathPurpose
User configuration~/.codex/config.tomlGlobal default configuration
Project configuration.codex/config.tomlProject-specific configuration
Project instructionsAGENTS.mdProject behavior guidelines
Log directory~/.codex/log/Run logs
Session directory~/.codex/sessions/Session records

Skills Directory

LocationPath
Project-level.agents/skills/
User-level~/.agents/skills/
System-level/etc/codex/skills/

Keyboard Shortcuts

CLI Shortcuts

ShortcutFunction
EnterSend message
Shift+EnterNew line
Ctrl+CInterrupt operation
Ctrl+C (两次)Exit Codex
Ctrl+DExit (when input is empty)
Ctrl+RSearch history
Up/DownBrowse history
TabAuto-completion
Esc EscEdit previous message
Ctrl+OCopy last reply

App Shortcuts

ShortcutFunction
Cmd/Ctrl+NNew session
Cmd/Ctrl+Shift+NNew window
Cmd/Ctrl+WClose 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

VersionDateUpdate Content
v1.5.02026-04Added support for GPT-5.4 series models
v1.4.02026-03Improved Worktree functionality
v1.3.02026-02Added Review Mode
v1.2.02026-01Optimized MCP Server support
v1.1.02025-12Added GitHub integration
v1.0.02025-11Codex officially released

Updating CLI

Update Commands

# npm update
npm install -g @openai/codex@latest

# Homebrew update
brew upgrade codex

# View current version
codex --version

Related Resources

Official Resources

ResourceAddress
Official Documentationhttps://developers.openai.com/codex
GitHubhttps://github.com/openai/codex
Codex Webhttps://chatgpt.com/codex
Discordhttps://discord.gg/openai

Tutorial Series

ChapterTitleContent
01Codex Getting StartedCore capabilities, plan comparison
02Core ConceptsPrompt、Thread、Context、Sandbox
03Desktop ApplicationApp features, Review mode
04IDE ExtensionVS Code、Cursor、Windsurf
05Command Line ToolCLI installation, TUI, Approval
06Cloud VersionWeb interface, Environments
07Integration & ConnectivityGitHub、Slack、Linear、MCP
08Configuration & CustomizationConfig、Rules、Skills
09Automation & CI/CDexec、SDK、GitHub Action
10Workflow ModesDevelopment workflow, refactoring, bug fixes
11Prompt Best PracticesPrompt structure, task decomposition
12Security & Enterprise ManagementSandbox, permissions, audit logs
13Model SelectionGPT-5.4 series, reasoning strength
14AppendixCommand quick reference, FAQ

Glossary

TermDescription
AgentCodex's core execution unit, capable of understanding tasks and executing operations
PromptTask instructions sent by the user to Codex
ThreadSession sequence, containing complete conversation history
ContextScope of information available to Codex, including files, conversations, and configuration
SandboxIsolated execution environment, restricting the scope of Codex's operations
ApprovalApproval policies, controlling confirmation behavior before executing operations
AGENTS.mdProject instruction files, defining Codex's behavior guidelines
SkillReusable custom capability modules
SubagentSub-agents, used for parallel processing of complex tasks
RulesRules engine, defining command execution permissions
MCPModel Context Protocol, a protocol for connecting external tools
WorktreeGit 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

Codex is continuously updated and iterated; follow official channels for the latest information.

Other Extensions