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.

Architect Chen
Architect Chen
Architect Chen
Complete Guide to Codex Commands (2026 Edition)

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 --help

Displays sections such as Commands, Options, and Examples. This is the best entry point for learning Codex.

4. codex --version – Show version

codex --version

Example output:

1.3.0

Applicable when

Checking installed version

Diagnosing environment issues

5. codex login – Log in

codex login

After a successful login you can invoke the model.

6. codex logout – Log out

codex logout

Switch accounts

Clear authentication

7. codex doctor – Environment check

codex doctor

Checks API, network, permissions, configuration, and environment variables.

8. codex config – View configuration

codex config

Shows current settings such as Model, Sandbox, Approval, Workspace, allowing a quick overview of the runtime configuration.

9. codex update – Upgrade Codex

codex update

Updates 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

/clear

Starts a new task and prevents context contamination.

12. /model – Switch model

/model

Lists available models and lets you switch, useful for testing capabilities, controlling cost, or changing inference power.

13. /status – Show current status

/status

Typically includes Model, Workspace, Approval, Sandbox, helping confirm the development environment.

14. /diff – Show AI modifications

/diff

Outputs added or removed code sections, e.g., + 新增缓存 or - 删除旧逻辑. Ideal for code review.

15. /undo – Undo last change

/undo

If the AI made an incorrect edit, you can quickly revert.

16. /exit or Ctrl+D – Exit Codex

/exit

Ends the current development session.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

developmentCommand-LineAI programmingCodexPromptusage guide
Architect Chen
Written by

Architect Chen

Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.