Complete Guide to Codex Commands (2026 Edition)
This article provides a detailed walkthrough of Codex's command-line interface, covering each command's purpose, usage examples, applicable scenarios, and output, helping developers leverage the AI coding assistant effectively.
Codex is a popular AI programming assistant. Below is a comprehensive reference of its command-line interface, showing how to start interactive sessions, run one‑off prompts, view help, manage configuration, and more.
1. codex – Start interactive mode
Launches the Codex chat interface, allowing continuous development conversations. codex After starting, you can directly chat, for example:
帮我分析这个项目 解释 UserService 帮我修复 Bug 生成测试代码Typical scenarios
Daily development
Reading project code
Writing code
Debugging
2. codex "Prompt" – One‑off prompt
Executes a single prompt and exits immediately. codex "解释这个项目" Example: codex "帮我写Redis缓存" Output example:
public class RedisService {
...
}Suitable for
Quick Q&A
Automatic script generation
Shell invocation
3. codex --help – List all commands
codex --helpDisplays sections such as Commands, Options, and Examples. This is the best entry point for learning Codex.
4. codex --version – Show version
codex --versionExample output:
1.3.0Applicable when
Checking installed version
Diagnosing environment issues
5. codex login – Log in
codex loginAfter a successful login you can invoke the model.
6. codex logout – Log out
codex logoutSwitch accounts
Clear authentication
7. codex doctor – Environment check
codex doctorChecks API, network, permissions, configuration, and environment variables.
8. codex config – View configuration
codex configShows current settings such as Model, Sandbox, Approval, Workspace, allowing a quick overview of the runtime configuration.
9. codex update – Upgrade Codex
codex updateUpdates to the latest version.
10. /help – Show interactive commands
After entering Codex, typing /help displays chat commands, shortcuts, and configuration explanations.
11. /clear – Clear context
/clearStarts a new task and prevents context contamination.
12. /model – Switch model
/modelLists available models and lets you switch, useful for testing capabilities, controlling cost, or changing inference power.
13. /status – Show current status
/statusTypically includes Model, Workspace, Approval, Sandbox, helping confirm the development environment.
14. /diff – Show AI modifications
/diffOutputs added or removed code sections, e.g., + 新增缓存 or - 删除旧逻辑. Ideal for code review.
15. /undo – Undo last change
/undoIf the AI made an incorrect edit, you can quickly revert.
16. /exit or Ctrl+D – Exit Codex
/exitEnds the current development session.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architect Chen
Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
