skip to content

Session Workflow

Resuming and branching saved conversations, the built-in slash commands, and the prompt line's input modes and shortcuts. Asked because fluent steering inside a session saves whole reruns.

part ofClaude Coderead it →
on this pageshow

explore

questions

15

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, what does starting a prompt with `!` do, and how does it differ from asking Claude to run that command?

level: juniorimportance: must knowfreq 28%

basics

~20 s

A leading ! puts Claude Code in shell mode: the command runs directly with no approval prompt, its command and output are added to the conversation, and since v2.1.186 Claude replies to that output automatically.

open as a page

In Claude Code, when do you use `claude -c`, `claude -r <name>` and `claude -r` with no argument to return to earlier work?

level: juniorimportance: must knowfreq 30%

basics

~20 s

claude -c reopens the most recent conversation in the current directory; claude -r with a name or session ID resumes that one session directly; claude -r alone opens the interactive session picker to search, preview and choose.

open as a page

While Claude Code is mid-turn and heading the wrong way, what do typing a message plus Enter, Esc, Ctrl+C and Ctrl+Enter each do?

level: middleimportance: must knowfreq 24%

basics

~20 s

Enter mid-turn queues a message that reaches Claude after the current tool calls; Esc stops the turn but keeps work done and sends the queue; Ctrl+C interrupts, or clears then exits when idle; Ctrl+Enter sends the queue at once.

open as a page

You resume yesterday's Claude Code session with `claude -r flaky-test` and its MCP servers and extra directory are missing — what does a resume restore, and what must you pass again?

level: seniorimportance: must knowfreq 12%

basics

~20 s

A resume restores what the transcript saved: the full history, the model, the agent and, on terminal routes, the permission mode, with exceptions. Launch flags such as --mcp-config, --settings, --plugin-dir, --fallback-model and --add-dir are not saved, so pass them again.

open as a page

In Claude Code, what happens when a prompt says `@src/utils/auth.js` or `@src/components` instead of describing where the code lives?

level: juniorimportance: should knowfreq 21%

basics

~20 s

An @ file mention puts the file's full content into the conversation with no Read call needed; a directory mention adds a file listing only, and a mention also loads CLAUDE.md files from that directory and its parents.

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

In Claude Code, Claude started a dev server that holds the turn open: what does Ctrl+B do, and what happens to that process afterwards?

level: middleimportance: should knowfreq 11%

basics

~20 s

Ctrl+B moves the running Bash command or agent to the background: it keeps running with a task ID, output goes to a file Claude can read, /tasks lists it, and it stops when Claude Code exits.

open as a page

In Claude Code, how do `/branch` and `--fork-session` let you try a second approach without losing the first, and what does each carry over?

level: middleimportance: should knowfreq 14%

basics

~20 s

/branch copies the conversation so far into a new session and switches the running process into it; --fork-session does the same at launch with -c or -r. The original stays intact. Only /branch keeps Allow for this session grants, and neither copies your files.

open as a page

Where does Claude Code store session transcripts, how long does it keep them, and when do you use `/export` instead of reading the JSONL?

level: middleimportance: should knowfreq 9%

basics

~10 s

Transcripts are JSONL files at ~/.claude/projects/<project>/<session-id>.jsonl, kept 30 days by default (cleanupPeriodDays). Their format is internal, so use /export for a readable plain-text copy and documented interfaces for scripts.

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

In Claude Code, Shift+Enter sends a half-written prompt instead of adding a line break: why, and which inputs always insert a newline?

level: middleimportance: nice to knowfreq 13%

basics

~20 s

Many terminals send Shift+Enter as a plain Enter, so Claude Code submits. Ctrl+J and a backslash followed by Enter insert a newline in every terminal; /terminal-setup or tmux extended keys make Shift+Enter work where supported.

open as a page

A Claude Code `~/.claude/keybindings.json` maps `ctl+e` to `chat:externalEditor` and sets `ctrl+c` to null in the Chat context: what actually happens?

level: seniorimportance: nice to knowfreq 7%

basics

~20 s

The misspelled ctl is dropped, so plain e is bound and typing e at the prompt opens the editor; ctrl+c is reserved and cannot be unbound, so it keeps interrupting. Both problems appear only as debug-log warnings.

open as a page