Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Using Claude Code  ›  Lesson

Slash Commands, Bang and Backslash

Slash Commands (/) 12 minIn the prompt box a leading slash runs a Claude Code command, a leading exclamation mark runs a shell command whose output joins the conversation, and a backslash before Enter starts a new line.

Slash Commands, Bang and Backslash

The prompt box takes more than requests for Claude. A slash talks to Claude Code itself, an exclamation mark talks to your shell, and a backslash lets you keep typing on a new line. Knowing which one you need saves turns and tokens.

The rule

Slash talks to the tool, bang talks to the shell, words talk to Claude.

Slash commands control the session instead of asking the model anything. Type / to see the full list. Everyday ones:

Command Use it to
/help See the commands and help
/clear Start a fresh conversation
/compact Summarise the conversation to free space
/context See what is filling the context window
/model Switch model
/status Check version, account, model and settings
/cost or /usage Check spending or plan usage
/export Save the conversation to a file or the clipboard
/doctor Check the installation for problems
/exit Leave the session

The same menu also lists custom commands added by your project, your skills or your plugins.

Bang runs a shell command directly. ! pytest -q runs the tests in your shell straight away, without asking Claude to do anything, and the output lands in the conversation so Claude can see it too. It is the fastest way to show Claude real output. Because you typed the command yourself, you own it; Claude is not the one running it.

A backslash, then Enter, starts a new line without sending, for multi-line prompts. Pasting multi-line text works too, and some terminals support other key combinations.

> ! git status
> ! pytest -q
> The failing test above is in the pause feature.\
  Fix it in orders.py only, then run pytest again.
> /context
> /clear

The shortcut

The first character decides who hears you. / goes to Claude Code, the app. ! goes to your shell. Anything else goes to Claude, the model.

A short, efficient sessionStep 1 of 5
  1. ! git status

    Confirms the tree is clean. You and Claude both see the result, and no model turn was spent.

The trap is asking Claude "please run the tests" when ! pytest -q would do. The request costs a model turn and a permission prompt; the bang costs neither.

Drills

Answer fast — trust the rule.

quick drill

What does ! pytest -q do?

quick drill

Which prefix speaks to Claude Code itself, for its settings and session?

quick drill

How do you continue a prompt on a new line without sending it?

quick drill

You want to save the whole session so you can share it with a teammate. Which command?

Remember

  • / talks to Claude Code, ! to your shell, plain words to Claude.
  • Shortcut: the first character decides who hears you.
  • Trap: spending a model turn on "run the tests" when ! pytest -q is instant.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWho hears each line?

Write a short sequence of prompt-box entries that checks the tiffin tests, asks Claude to fix a failure in a two-line prompt, checks the context, and then resets for a new task. For each line, say who 'hears' it: Claude Code, your shell, or Claude.