Slash Commands, @-Mentions & Images
Driving the composer fluently
- Use @ fuzzy file search and /mention to pull exact files into the conversation
- Give Codex visual context by pasting images or attaching them with -i/--image
- Run a quick local shell command from the composer with the ! prefix
- Reach for the right slash command by purpose: setup, model, permissions, review, context, and session control
- Recall that /approvals is now /permissions and that there is no /undo — rollback is via git
- Treat the slash roster as volatile and consult the live slash-commands page for the current set
The Codex composer is more than a text box — it's a small command surface. This lesson teaches you to drive it fluently: pull files into context with @ fuzzy search and /mention, hand Codex screenshots with -i/--image, drop into the shell with a !-prefixed line, and reach for the right slash command by purpose. The full slash roster is large and changes often, so you'll learn the groups that matter and where to find the live list.
- 1The composer is a command surface, not just a chat box
- 2@ and /mention: hand Codex the exact file
- 3Images: show Codex what you mean
- 4The ! prefix: a shell command without leaving Codex
- 5Slash commands, grouped by purpose
- 6Two things that trip up newcomers: /permissions and no /undo
- 7The roster is volatile — bookmark the live page
The composer is a command surface, not just a chat box
When you run codex in a project, the box at the bottom of the TUI looks like an ordinary chat input. It isn't. It's a small command surface with four distinct modes, and learning the prefixes is the difference between talking at Codex and driving it.
Everything you type is interpreted by its first character:
| Prefix | Mode | What it does |
|---|---|---|
| (plain text) | Prompt | A normal instruction to the agent |
@ | File mention | Fuzzy-search the workspace and insert a file path |
/ | Slash command | Run a built-in command (model, diff, review, …) |
! | Shell | Run one local shell command and feed the output back |
That's the whole mental model. The rest of this lesson is just learning what lives behind @, /, and !, plus how to attach images. Master these and you stop describing your repo to Codex in prose and start handing it the exact files, screenshots, and commands it needs — which is faster and far more accurate.
Two more keys round out the composer and are worth knowing on day one: Ctrl+G opens your external editor ($VISUAL, falling back to $EDITOR) for composing a long prompt comfortably, and Esc Esc on an empty composer edits your previous message so you can refine an instruction instead of piling on a correction.
Key insight
Read the first character
Codex decides what you mean from the first character of the line: nothing = a prompt, @ = a file mention, / = a slash command, ! = a shell command. Internalize those four and the whole composer becomes predictable.
@ and /mention: hand Codex the exact file
The single highest-leverage habit in the composer is pointing Codex at specific files instead of hoping it finds them. Two tools do this.
@ — fuzzy file search. Type @ and a fuzzy file search opens over the workspace root. Start typing part of a filename and the list narrows; press Tab or Enter to drop the highlighted path straight into your message. So instead of "look at the auth middleware, I think it's somewhere in src", you write:
Why does @src/middleware/auth.ts reject valid tokens? Compare it against @tests/auth.test.tsNow Codex has the exact paths, with zero guessing about which file you meant.
/mention — the menu alternative. /mention does the same job from the slash menu: "Attach a file to the conversation." It's the discoverable, menu-driven path to the same outcome — handy when you'd rather browse than type a fuzzy query.
Why this matters: a file path you inserted is unambiguous, whereas a prose description ("the config file") forces Codex to search and possibly pick the wrong one. Mentioning files up front also keeps the agent from burning a turn exploring — it can read exactly what you handed it and get to work.
Tip
Mention before you ask
Lead with the files: Refactor @src/db/pool.ts to use the new @src/config/env.ts loader. Naming the paths up front removes ambiguity and saves Codex a context-gathering round-trip.
Images: show Codex what you mean
Codex is multimodal in the composer — a screenshot of a stack trace, a Figma frame, or a broken-layout snapshot is often worth a paragraph of description. There are two ways to attach one.
Paste directly. With an image on your clipboard (a screenshot, a design spec), paste it straight into the interactive composer. It's attached to your next message.
Attach from the command line with -i / --image. When you launch Codex you can hand it image files:
codex -i screenshot.png "Explain this error"The --image (-i) flag accepts comma-separated or repeated files, so you can attach several at once:
codex --image before.png,after.png "Why did this layout shift between these two screenshots?"Great uses: hand it a failing-test screenshot and the relevant file (@-mention it), paste a design mockup and ask it to build the component, or show a rendering bug it can't see from the code alone. The pattern that pays off most is image + file mention together — the picture tells Codex what's wrong and the mention tells it where to fix it.
Example
Visual bug, precise fix
Paste a screenshot of a misaligned button, then write: This button is misaligned (see image). Fix it in @src/components/Toolbar.tsx. The image supplies the symptom; the mention supplies the location.
The ! prefix: a shell command without leaving Codex
Sometimes you don't want the agent to do anything — you just want to check something and keep its output in the conversation. The ! prefix runs a single local shell command from the composer:
!ls
!git status
!npm testCodex runs the command and treats the output like user-provided context, while still respecting your approval settings — a !-prefixed line is not a license to bypass the sandbox or approval prompts. The result lands in the transcript, so it becomes information Codex can reason about on your next turn.
Think of ! as a quick "let me show you the current state" without breaking your flow: run !git status so the agent sees your working tree, !ls src/ to confirm a path before mentioning it, or pipe a quick check in before asking Codex to act on it. It keeps your hands in one place — you're not Alt-Tabbing to another terminal and then pasting results back.
Note
! still obeys your guardrails
A ! line runs through the same sandbox and approval policy as anything else Codex does. It's a convenience for surfacing state into the conversation, not an escape hatch around your permissions.
Slash commands, grouped by purpose
Type / and a popup of slash commands appears; keep typing to filter. The roster is large and evolving, so don't try to memorize all of it — learn the groups you reach for daily and let the popup remind you of the rest.
Here are the workhorses, organized by what you're trying to do:
| Purpose | Commands | What they're for |
|---|---|---|
| Set up the project | /init | Generate an AGENTS.md scaffold in the current directory |
| Tune the engine | /model, /permissions | Pick the model + reasoning effort; set what Codex can do without asking first |
| Review the work | /diff, /review | Show the Git diff (incl. untracked files); ask Codex to review your working tree |
| Manage context | /compact, /clear, /new, /mention, /mcp | Summarize to free tokens; clear the screen; start a fresh chat; attach a file; list MCP tools |
| Inspect & continue | /status, /resume, /fork, /copy | Show session config + token usage; resume a saved conversation; fork into a new thread; copy the last output |
A few field notes on the ones you'll use most:
/modelchanges both the model and its reasoning effort within the current thread — the in-session counterpart to the-mflag./permissionsis your live posture switch (more on the rename below)./statusis your usage dashboard: it shows session configuration and token usage, so you can see how close you are to compaction./compactsummarizes the visible conversation to free tokens when a long session is filling the window — distinct from/clear(which clears the screen and starts a fresh chat) and/new(a fresh conversation inside the same CLI session)./copy(or Ctrl+O) copies the latest completed Codex output — handy for pasting a result into a PR or a message.
That's a usable core. The full list also includes session, MCP, skills, plugins, and cosmetic commands you'll meet in later lessons.
Tip
Filter, don't memorize
Press /, then type a few letters of what you want (rev → /review, perm → /permissions). The popup filters as you go, so you only need to remember the purpose, not the exact name.
Two things that trip up newcomers: /permissions and no /undo
Codex moves fast, and two details surprise people coming from older guides or other agents. Get them right and you'll avoid the most common composer mistakes.
1. /approvals is now /permissions. The command that sets what Codex can do without asking first was renamed. The official slash-command popup shows /permissions — "Set what Codex can do without asking first" — and /approvals no longer appears as its own entry. If a tutorial tells you to run /approvals, mentally translate it to /permissions.
2. There is no /undo. Codex deliberately has no built-in undo command. Instead, it always surfaces a transcript of every edit and command it makes, and the official guidance is to roll back using your normal git workflow. That means the safety net you actually rely on is good git hygiene:
- Commit (or at least
git stash) before handing Codex a big task, so you have a clean point to return to. - Use
/diffto inspect exactly what changed (including untracked files) before you accept it. - If a change is wrong,
git restore/git checkout/git resetit — the transcript tells you precisely what happened so you know what to undo.
This is a meaningful difference from agents that keep their own checkpoint/undo stack. With Codex, git is your undo button. That's not a limitation so much as a design choice: your version control is the source of truth, and Codex stays out of its way.
Watch out
Commit first — git is your only undo
Because Codex has no /undo, an uncommitted working tree is your only thing at risk. Make a commit or stash before a large agentic task; then /diff to review and git to roll back if needed.
The roster is volatile — bookmark the live page
Everything above is the stable core — the commands and prefixes you'll use every day. But the full slash roster is one of the fastest-moving parts of Codex. Commands get added, renamed (/approvals → /permissions is the obvious example), and reorganized between releases, and new feature commands (skills, plugins, hooks, memories, agents) show up as the product grows.
So treat any printed list — including this one — as a snapshot, not gospel. The authoritative, always-current source is the official slash-commands page:
- Live slash-command roster: https://developers.openai.com/codex/cli/slash-commands
Two habits keep you current without re-reading docs:
- Press
/and read the popup. Your installed version's actual command set is right there, with one-line descriptions. It's the truest source for your Codex. - Check the live page when something's missing or renamed. If a command you expected isn't in the popup, the docs (and the changelog) will tell you what replaced it.
The concepts in this lesson — mention files, attach images, shell with !, reach for slash commands by purpose — don't rot. The exact spelling of any one command might. Anchor to the concept; verify the spelling live.
Key insight
Concept stays, spelling drifts
"Pull a file into context" and "set what Codex can do without asking" are durable skills. Whether the command is @//mention or /permissions this month is verifiable in one keystroke (/) or one link. Learn the job; look up the name.
Try it: Drive the composer: mention, image, shell, slash
Goal: build muscle memory for the four composer modes in one short session, in a small repo of your own.
0) Commit first. Because Codex has no /undo, run git status and make a commit (or git stash) so you have a clean point to return to. This is the habit the whole lesson hinges on.
1) Start a session. Run codex in the repo.
2) Mention a file with @. Type @, fuzzy-search to a real source file, and press Tab to insert the path. Ask something concrete, e.g. "Summarize what @<path> does in three bullets." Notice Codex reads exactly that file instead of guessing.
3) Try /mention. Do the same attach via the slash menu (/mention) to feel the menu-driven alternative.
4) Run a shell command with !. Type !git status (and !ls). Confirm the output appears in the transcript as context — and that it still honored your approval/sandbox settings.
5) Attach an image. Take a screenshot of anything (an error, a diagram), paste it into the composer, and ask Codex to describe it. Optionally relaunch with codex -i shot.png "what is this?" to practice the flag.
6) Tour slash commands by purpose. Open the popup with / and run, in order: /status (read your token usage), /diff (see changes incl. untracked files), and /model (note that it also sets reasoning effort). Then try /permissions and confirm /approvals is not its own entry.
7) Verify live. Open https://developers.openai.com/codex/cli/slash-commands and spot one command in your / popup that the page describes — proof that the roster is the source of truth.
8) Write three sentences: which file did you mention, what did the image add that prose couldn't, and how did you confirm there's no /undo (what would you do instead)?
Key takeaways
- 1The composer is a command surface: plain text is a prompt, `@` mentions a file, `/` runs a slash command, and `!` runs a local shell command.
- 2`@` opens a fuzzy file search over the workspace root (Tab/Enter inserts the path); `/mention` is the menu-driven way to attach a file — mention files instead of describing them.
- 3Give Codex visual context by pasting an image into the composer or attaching with `-i`/`--image` (comma-separated or repeated files); pair an image with a file mention for symptom + location.
- 4A `!`-prefixed line runs one shell command and feeds the output back into the conversation, while still respecting your sandbox and approval settings.
- 5Learn slash commands by purpose — setup (`/init`), engine (`/model`, `/permissions`), review (`/diff`, `/review`), context (`/compact`, `/clear`, `/new`, `/mcp`), and session (`/status`, `/resume`, `/fork`, `/copy`).
- 6`/approvals` was renamed `/permissions`, and there is no `/undo` — roll back via your normal git workflow; the live roster lives at developers.openai.com/codex/cli/slash-commands.
Quiz
Lock in what you learned
Check your understanding
0 / 4 answered
1.You want Codex to debug a specific middleware file. What's the fastest, least-ambiguous way to bring it into the conversation?
2.You have two before/after screenshots of a layout bug and want to attach both when launching Codex. Which is correct?
3.A line typed in the composer that starts with ! (for example, !git status) does what?
4.A colleague's old guide says to run /approvals to change what Codex can do, and to use /undo if an edit goes wrong. What's accurate today?
Go deeper
Hand-picked sources to keep learning
The authoritative, always-current list of slash commands with one-line descriptions. Bookmark this — the roster changes often.
Covers @ fuzzy file search, pasting/attaching images, the ! shell prefix, Ctrl+G external editor, and the recommended model.
Full flag reference, including --image/-i (comma-separated or repeated) and --model/-m.
The agent loop, the transcript, and how rollback works via your normal git workflow.
Where command renames (like /approvals → /permissions) and new feature commands are announced.
Open-source CLI: releases, issues, and the source of truth for version-gated behavior.