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
- All slash commands in detail
- Command-line parameters
- Quick reference
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
- Slash commands: Session management / File operations / Mode switching / Information viewing
- Launch parameters:
--model/--sandbox/--approval-policy - Task templates: Fix Bug / Add Feature / Refactor / Test / Review
- Use
/statusand/compactto manage context effectively
📝 Exercises
- Basic (⭐): Use at least 5 slash commands and record each command's effect.
- Intermediate (⭐⭐): Use task templates to complete a full feature development cycle — from adding features to writing tests to code review.
- Advanced (⭐⭐⭐): Create your own Codex quick reference card with your most-used commands and task templates.