Codex: Codex Slash Commands & Quick Reference

Last updated: 2026-08-31

Codex provides rich slash commands for quickly executing common operations without leaving the conversation.

📋 Prerequisites: Codex basic usage completed (see Lesson 3)

1. What You Will Learn


2. Slash Commands Overview

(1) Session Management

Command Description
/new Start a new session
/clear Clear current conversation history
/status View session status, context usage
/compact Manually compact context
/quit Exit Codex

(2) File Operations

Command Description
/read <file> Read file contents
/add <file> Add file to context
/remove <file> Remove file from context
/diff View current uncommitted changes

(3) Mode Switching

Command Description
/mode suggest Switch to Suggest mode
/mode auto-edit Switch to Auto Edit mode
/mode full-auto Switch to Full Auto mode

(4) Information Viewing

Command Description
/help View help information
/version View version number
/config View current configuration
/models View available model list
/history View conversation history

3. Command-Line Parameters

(1) Launch Parameters

BASH
# Basic launch
codex

# Specify model
codex --model gpt-5-codex

# Specify sandbox mode
codex --sandbox workspace-write

# Specify approval policy
codex --approval-policy ask

# Full Auto mode
codex --full-auto

# Auto Edit mode
codex --auto-edit

(2) Common Parameters

Parameter Description Example
--model Specify model --model o3
--sandbox Sandbox mode --sandbox readonly
--approval-policy Approval policy --approval-policy ask
--auto-edit Auto Edit mode
--full-auto Full Auto mode
--quiet Quiet mode
--version View version
--help View help
--upgrade Update Codex

4. Quick Reference

(1) Quick Start

BASH
codex                                    # Launch in default mode
codex "Fix login bug"                    # Submit task directly
codex --model deepseek-coder             # Specify model
codex --full-auto "Run tests"            # Full Auto + task

(2) In-Session Operations

TEXT 📖 Display only
/new                  New session
/status               View status
/compact              Compact context
/mode full-auto       Switch mode
/add src/auth.ts      Add context
/diff                 View changes

(3) Task Templates

TEXT 📖 Display only
# Fix Bug
"Fix <issue> in <file>, ensure tests pass"

# Add Feature
"Add <feature> to <module>, follow the style of <existing-file>"

# Refactor Code
"Refactor <old-impl> to <new-impl>, maintain functionality, ensure tests pass"

# Write Tests
"Write unit tests for <file>, covering normal flows and edge cases"

# Code Review
"Review <file/PR>, focusing on security, performance, and maintainability"

5. Advanced Commands

(1) Context Management

TEXT 📖 Display only
/add src/**/*.ts        Add all TypeScript files
/remove src/test.ts     Remove test file
/status                 View context usage
/compact                Manual compaction

(2) Multi-task Management (App Mode)

TEXT 📖 Display only
/tasks                  List all tasks
/task new              Create new task
/task switch <id>       Switch task
/task cancel <id>       Cancel task

▶ Example 1: Alice's Efficient Workflow

TEXT 📖 Display only
# Alice starts working
/new                                    # New session
/add src/auth.ts src/user.ts           # Add context
"Migrate authentication from Session to JWT"  # Submit task

# After task completes
/diff                                   # View changes
/status                                 # Check context
/compact                                # Compact history

# Continue to next task
"Add refresh token functionality to JWT auth"

❓ FAQ

Q Are slash commands case-sensitive?
A No. /New and /new have the same effect.
Q Can I use slash commands within a task description?
A No. Slash commands must be entered separately, not embedded in task descriptions.
Q How do I view all available commands?
A Enter /help to see the complete list.
Q Does /compact lose information?
A It compresses less important historical details, but core context is preserved. If Codex forgets key information, use /add to re-add it.
Q Can I create custom slash commands?
A Custom slash commands are not currently supported, but similar effects can be achieved through AGENTS.md and Skills.

📖 Summary


📝 Exercises

  1. Basic (⭐): Use at least 5 slash commands and record each command's effect.
  2. Intermediate (⭐⭐): Use task templates to complete a full feature development cycle — from adding features to writing tests to code review.
  3. Advanced (⭐⭐⭐): Create your own Codex quick reference card with your most-used commands and task templates.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏