Mastering Codex Commands: A Complete Beginner‑to‑Pro Guide
This guide explains how to efficiently control the Codex AI programming assistant by distinguishing its command types, presenting a step‑by‑step onboarding workflow, detailing the ten core slash commands, introducing advanced commands, and answering common questions to help developers avoid pitfalls and boost productivity.
Codex is an AI‑driven coding collaborator that operates directly on local project files, unlike pure chat models such as ChatGPT. It requires precise / ‑prefixed commands to perform actions such as reading code, modifying files, executing terminal commands, and conducting code reviews.
Input Types
Two input categories exist: ordinary prompts that describe a specific programming need (e.g., “fix the parameter validation error in the login API”), and slash commands (starting with /) that act as operation switches, such as changing the model or setting permissions.
Key Reminder
Slash commands must appear at the very beginning of the input line; otherwise Codex treats them as normal text and ignores the command. When a task is running, pressing Tab after a slash command queues it for execution after the current task finishes.
Onboarding Workflow
Navigate to the project directory and verify the path with /status.
Run /init to generate an AGENTS.md skeleton and add project‑specific rules (package manager, prohibited directories, coding standards, etc.).
Use /status again to confirm the model, permissions, and directory; start with “Read Only” mode for safety.
Let Codex familiarize itself with the code base, e.g., /mention src/ analyze core logic, without modifying files.
For large tasks, issue /plan to obtain a step‑by‑step execution plan, risk points, and verification methods.
After confirming the plan, enable write permissions with /permissions and let Codex apply changes.
Run /diff to review the exact Git diff and ensure no unintended modifications.
Before committing, invoke /review for a self‑audit of bugs, regressions, missing tests, edge cases, and security risks.
If the conversation becomes sluggish, use /compact to compress the history and free tokens.
Finish the session with /new or /clear for a fresh task, or /quit to exit (remember to save your work).
Core 10 Commands (cover ~90% of daily development)
/init : Generates AGENTS.md so Codex can quickly learn project structure, dependencies, and conventions.
/status : Shows the current model, permission mode, working directory, token usage, and other session details.
/model : Switches the active model and inference intensity; GPT‑5 is the recommended default for complex tasks.
/permissions : Sets the approval mode – “Read Only”, “Auto”, or “Full Access” – controlling whether Codex may write files or run commands.
/plan : Enters planning mode, outputting a detailed execution plan before any code changes.
/mention : Limits Codex’s focus to specific files or directories, improving relevance and speed.
/diff : Displays the Git diff (including untracked files) so developers can verify exact changes.
/review : Performs a comprehensive self‑review for bugs, regressions, missing tests, edge cases, and security issues.
/compact : Summarizes long conversations to release token capacity while preserving key objectives.
/resume : Restores a previously saved session, enabling multi‑day work without losing context.
Advanced Commands
/fast : Enables a faster, lower‑precision mode for lightweight tasks.
/personality : Changes Codex’s response style (friendly, pragmatic, or none).
/copy : Copies the latest output to the clipboard (or via Ctrl+O / Cmd+O).
/agent : Switches to a sub‑agent thread for parallel sub‑tasks within the same overall job.
/fork : Creates an independent session branch, analogous to a Git branch, for experimental solutions.
/apps , /plugins , /mcp : Browse and invoke external applications, plugins, or Model Context Protocol tools.
/ps / /stop : Monitor and abort long‑running background terminal tasks.
/experimental : Turn on experimental features (use with caution).
/debug-config : Prints detailed configuration and permission diagnostics when Codex ignores commands.
/statusline , /title , /keymap : Customize the TUI status bar, window title, and keyboard shortcuts.
/sandbox-add-read-dir : Windows‑only command to grant the sandbox read access to an extra directory.
/logout , /feedback , /quit , /exit , /new , /clear : Basic session management commands.
Common Questions
Command lists vary by Codex version, OS, installed plugins, and experimental flags; use / to view the local list.
Codex may “mis‑edit” code if permissions are too permissive, prompts are vague, or /diff is not checked; start with “Read Only” mode. /compact compresses history but retains the task goal, key steps, and completed results; add a prompt to preserve specific files if needed. /new opens a fresh dialogue while keeping history; /clear resets the current context and clears the terminal.
After modifications, always run /diff, then local tests, and finally /review before committing.
Codex differs from ChatGPT by directly accessing the local filesystem, executing commands, and reading Git history. /fork creates an independent branch; /agent creates a sub‑task that remains linked to the original session.
Use /apps to insert $app‑slug and call external services such as databases.
If an experimental feature bugs out, disable it with /experimental and restart Codex; report serious issues via /feedback.
Update Codex via npm install -g @openai/codex@latest (npm) or brew upgrade codex (Homebrew).
Officially supported OSes are macOS and Linux; Windows support is experimental and recommended through WSL.
References
https://developers.openai.com/codex/cli https://developers.openai.com/codex/cli/slash-commands
https://x.com/dengdry/status/2052026438442725525
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.
AI Architecture Hub
Focused on sharing high-quality AI content and practical implementation, helping people learn with fewer missteps and become stronger through AI.
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.
