skip to content

Slash Commands

Built-in slash commands such as /init, /clear, /compact, /model, /permissions, /doctor and /usage, and which are bundled skills. Asked because choosing /clear, /compact or /rewind is daily craft.

part ofClaude Coderead it →
on this pageshow

explore

questions

5

In Claude Code, why does a slash command typed partway through a prompt not run, and what becomes of text after a command's name?

level: juniorimportance: must knowfreq 18%

answer

  1. where in the message it sits
  2. what the message starts with
  3. the rest is argument text
  4. mid-prompt completion only inserts
  5. Unknown command versus plain prompt

basics

~20 s

Claude Code recognises a slash command only at the start of a message, and text after the command name becomes its arguments. A /name typed mid-sentence goes to Claude as ordinary prompt text; Claude Code runs nothing.

solid answer

~40 s

Claude Code parses a command only from the start of the message. `/compact keep the schema decisions` runs `/compact` with `keep the schema decisions` as its argument, while `run the linter, then /compact` is one prompt that Claude receives as text: Claude Code itself executes nothing. Typing `/` after a space still offers completion, but that only inserts the name into your draft. A second built-in name on the same line is argument text for the first command, not a second command, so two commands mean two messages; the one exception is skills, which since v2.1.199 can be chained at the start (`/skill-a /skill-b do XYZ`, up to six). In an interactive terminal session, an unmatched name such as `/hepl` is refused with `Unknown command` rather than sent to Claude.

go deeper

for a junior

Remember the one rule: a command runs only when it starts the message, and whatever follows its name is its argument text. Send each command as its own message.

for a middle

Explain why the same trailing text means focus instructions to /compact, a label to /clear and a path to /add-dir, and why mid-prompt completion inserts a name without running it.

for a senior

Show you can read the failure modes: Unknown command in the terminal against a prompt silently sent to Claude on other surfaces, and the skills-only chaining exception at the start of a message.

for a principal

Weigh what a predictable command layer buys a team: when you script prompts or teach others, a command that runs only at the start keeps intent unambiguous, and that is the habit to standardise.

## The rule: a command is the first thing in the message Claude Code's **command layer** sits in front of the model. When you press Enter, the CLI looks at the start of your message: if it begins with `/` followed by the name of a command available in this session, Claude Code handles that command itself. If it does not, the whole message goes to Claude as a prompt. The commands reference states it in one line: *a command is only recognized at the start of your message*. That has three everyday consequences: - `run the tests, then /compact` is **one prompt**. Claude reads the words `/compact` as text; Claude Code does not compact anything. - You cannot stack built-in commands on one line. In `/clear /compact`, the second name is just text that follows `/clear`. - A prompt that starts with a path, such as `/var/log/syslog is filling up`, or with `/` followed by punctuation, is sent to Claude as a normal message rather than treated as a command. ## Arguments: everything after the name **Text that follows the command name becomes its arguments.** What a command does with them depends on the command: | You type | What Claude Code does | | :- | :- | | `/compact keep the schema decisions` | Summarises the conversation, using the text as focus instructions | | `/clear auth-spike` | Starts an empty conversation and labels the previous one `auth-spike` in the `/resume` picker | | `/add-dir ../shared-lib` | Adds that directory as a working directory | | `/config theme=dark` | Sets the setting directly instead of opening the Settings panel | | `/btw what was that config file called?` | Asks a side question that is not added to the conversation | The table shows why "the arguments are ignored" is a weak answer: the same trailing text means focus instructions to one command, a session label to another and a path to a third. ## Mid-prompt `/`: completion, not execution Command **completion** works partway through a prompt: type `/` after a space and the first letters of a name, and the menu (or ghost text, outside fullscreen) offers matching commands. Accepting a match only **inserts the name into your draft**. Only commands whose names start with the typed letters match, so typing a file path such as `/tmp/notes.md` does not keep a list open. When you send the message, the rule above still applies: the inserted name runs only if it is at the start. ## The skills exception Skills are the one place where more than one `/name` at the start counts. As of **v2.1.199**, `/skill-a /skill-b do XYZ` loads every skill named at the start of the message (up to six) and passes the trailing text to each as arguments. This applies to skills, including bundled ones; it does not turn a line of built-in commands into a script. How skills read their arguments is the skills material's subject, not this one. ## When the name does not match anything In an **interactive terminal session**, a `/` name that matches no command available in this session is refused rather than sent to Claude, with a message such as `Unknown command: /hepl. Did you mean /help?` naming the closest command when one is close. The usual causes are a typo, a command whose requirement is not met (platform, plan, sign-in method), or a command from a plugin or MCP server that is not installed or connected. Since **v2.1.236**, pressing Enter after a typo submits exactly what you typed; earlier releases ran the nearest menu match instead, so `/hepl` ran `/help`. In other surfaces (`-p` runs, Agent SDK apps, the Desktop Code tab, the VS Code chat panel, cloud sessions) an unmatched name goes to Claude as a normal message with a note that no command ran. A few available commands, such as `/heapdump`, are **hidden from the menu** by design: a partial name never surfaces them, but typing the full name runs them. ## Why the rule matters Because only the start of a message is parsed, prose that **mentions** a command is safe to send. You can write "explain what /compact keeps" or paste a log line that contains `/usr/bin/env` without triggering anything: Claude reads the text and answers. The flip side is that a command buried in a long instruction is silently just words, which is the most common reason people think a command "did nothing". The `/` menu is a reliable guide here, since it lists only what this session can run and highlights a suggestion only when the letters you typed match a name or alias. ## Practical habits 1. Put the command first, alone or with its own argument text, and send it as its own message. 2. When you want work done and then a command, send the work, wait for the turn to finish, then send the command. 3. Read `Unknown command` as "this session does not have that name", not as "Claude did not understand". 4. Use the `/` menu to check spelling before you press Enter; it lists only what this session can run.

  • You send `/clear /compact` in Claude Code. What happens?
    Only `/clear` is recognised, because a command must start the message. `/compact` is just text after the command name, so it is passed to `/clear` as argument text (its optional label for the previous conversation) rather than run. Claude Code starts an empty conversation and nothing is compacted. Two built-in commands need two messages.
  • Why does `/heapdump` never appear in the `/` menu even though it runs?
    Claude Code keeps a few available commands out of the menu by design, and `/heapdump` is one of them. A partial name never brings a hidden command into the list, so filtering shows the same no-match message as for a name that does not exist. Once you type the full name, the menu lists it and submitting it runs it.
  • Does an unmatched `/name` always produce `Unknown command`?
    Only in an interactive terminal session. In `-p` runs, Agent SDK applications, the Desktop Code tab, the VS Code chat panel and cloud sessions, Claude Code sends the prompt to Claude as a normal message with a note that the command did not run. A built-in that cannot run on such a surface still answers that it is unavailable.

  • Any /name anywhere in a prompt is executed by Claude Code.
  • Text after a built-in command's name is simply ignored.
  • Two built-in commands on one line run one after the other.
  • Accepting a mid-prompt completion makes that command run on send.
  • A mistyped command in the terminal is quietly sent to Claude as a prompt.

Assumes Claude Code 2.1.286; skills chain at the start of a message since 2.1.199, and since 2.1.236 Enter after a typo submits the text as typed instead of running the nearest match.

open as a page

In Claude Code, when do you run `/add-dir` and when `/cd`, and what project configuration does each one load?

level: middleimportance: should knowfreq 9%

basics

~20 s

/add-dir adds a directory Claude may read and edit but loads little of its configuration; /cd moves the session's primary working directory, keeps the conversation, and applies the new directory's CLAUDE.md, settings, hooks, MCP servers, skills and subagents.

open as a page

In Claude Code, how does a bundled skill like `/doctor` differ from a built-in command like `/init`, and what does `disableBundledSkills` change?

level: middleimportance: should knowfreq 10%

basics

~20 s

A built-in command runs fixed CLI logic; a bundled skill is a prompt Claude carries out with its tools. disableBundledSkills removes bundled skills and workflows, while built-ins like /init stay typable but are hidden from the model.

open as a page

A Claude Code session is misbehaving: how do you choose between `/status`, `/doctor`, `/debug` and `/usage` to find out why?

level: seniorimportance: should knowfreq 11%

basics

~20 s

/status shows version, model, account and connectivity; /doctor runs a setup checkup of installation, settings and extensions and can fix them after asking; /debug starts debug logging and reads it; /usage shows session cost, plan limits and activity.

open as a page

In Claude Code, when is `/btw` the right way to ask a quick question, and what can a `/btw` side question not do?

level: middleimportance: nice to knowfreq 7%

basics

~20 s

/btw asks a side question about the current session without adding it to the conversation history. Claude answers once, from what is already in context, with no tool access, so it suits recall questions, not new investigation.

open as a page