Claude Lessons / Guides
Claude Code Slash Commands: Every Command Explained
Slash commands are the fastest way to control a Claude Code session without writing a full sentence of instructions. Some ship with the CLI and cover housekeeping like clearing context or checking cost; others you write yourself to turn a multi-step ritual — "run the review checklist," "open a PR the way we always do it" — into three characters. This guide covers the built-in commands worth memorizing, then walks through writing your own with arguments and frontmatter.
What a slash command actually is
Type a regular message and Claude treats it as a task to reason about. Type a message that starts with
/ and Claude Code intercepts it as a control instruction — clear the conversation, switch a
setting, run a specific fixed prompt — before any model call happens for most built-ins. That distinction
matters: slash commands are fast and predictable because many of them don't depend on the model
interpreting your intent correctly.
Type / alone in a session to see the full menu with autocomplete, including any custom
commands you or your team have defined. You don't need to memorize spelling — the typeahead does that
part.
Session and context commands
These are the ones you'll reach for constantly once a session has been running a while:
| Command | What it does |
|---|---|
/clear | Wipes the conversation and starts a fresh context window — use between unrelated tasks |
/compact | Summarizes the conversation so far to free up context space while keeping the gist |
/context | Shows what's currently consuming your context window, broken down by category |
/cost | Reports token usage and estimated cost for the current session |
/resume | Reopens a previous session by name or picks from a list of recent ones |
/rewind | Jumps the conversation and/or your files back to an earlier checkpoint |
/export | Exports the current conversation to a file |
If context management feels like the actual skill here, it is — this is the same discipline behind keeping a session sharp, covered from the delegation angle in our subagents guide.
Configuration and setup commands
| Command | What it does |
|---|---|
/init | Generates a starter CLAUDE.md by scanning your project |
/model | Switches the model for the session (e.g. Sonnet vs. Opus) |
/permissions | Views and edits what tools Claude can use without asking |
/mcp | Manages MCP server connections and authentication — see our MCP guide |
/agents | Lists and manages available subagents |
/hooks | Views configured hooks — see our hooks examples guide |
/output-style | Changes how Claude formats its responses (e.g. more concise, explanatory) |
/statusline | Configures a custom terminal status line |
/memory | Opens CLAUDE.md files for editing directly |
/add-dir | Grants the session access to an additional directory outside the project root |
/doctor | Diagnoses installation and configuration problems |
Commands are muscle memory — build it hands-on
Claude Lessons has 38 free interactive lessons that simulate a real Claude Code workspace, including lessons on context management and session hygiene — practice the workflow, not just the command list.
Start the free interactive lessonsWorkflow commands
| Command | What it does |
|---|---|
/review | Runs a structured code review of your current changes |
/pr-comments | Pulls review comments from an open pull request into the conversation |
/todos | Shows the task list Claude is tracking for the current work |
/bug | Reports a Claude Code bug directly from the session |
/vim | Toggles vim key bindings for the input prompt |
/ide | Connects to a supported IDE for inline diffs and diagnostics |
/login / /logout | Switches or clears the authenticated account |
/help | Lists every available command, including custom ones |
You don't need all of these on day one. /clear, /compact, /review,
/model, and /help cover most daily use; the rest earn their place as your
workflow gets more specific.
Write your own custom command
A custom command is a Markdown file whose filename becomes the command name and whose body becomes the prompt Claude runs. No code, no plugin system to learn — just a file:
mkdir -p .claude/commands
cat > .claude/commands/security-check.md << 'EOF'
---
description: Review the current diff for common security issues
allowed-tools: Read, Grep, Glob
---
Review the current git diff for SQL injection, hardcoded secrets,
missing input validation, and unsafe deserialization. Report each
finding with the file, line, and a suggested fix. If nothing is
found, say so explicitly — don't invent issues.
EOF
Save that, restart the session if .claude/commands/ didn't already exist, and
/security-check shows up in the menu. Typing it runs the body above as if you'd pasted it in
yourself — same context, same tools, same session.
Arguments: making a command reusable
A command that only ever runs the exact same prompt is limited. Accept input the way a shell script
would, with $ARGUMENTS for the whole string after the command name, or $1,
$2 for individual positional values:
---
description: Investigate and summarize a GitHub issue by number
argument-hint: [issue-number]
allowed-tools: Bash(gh issue view:*), Read, Grep
---
Fetch issue #$1 with `gh issue view $1`, then search the codebase
for the relevant code and summarize the likely cause in under
150 words.
Call it with /investigate-issue 482 and $1 resolves to 482. The
argument-hint field shows placeholder text in the autocomplete menu so teammates know what to
type without opening the file.
Frontmatter fields worth knowing
None of these are required — a bare Markdown file with no frontmatter works fine as a command — but each solves a real problem once you hit it:
description— shows in the/menu and autocomplete so you can tell commands apart at a glance.argument-hint— placeholder text describing expected arguments, e.g.[pr-number] [priority].allowed-tools— restricts what this specific command can use, tighter than your session's general permissions. Useful for a read-only audit command you want safe to run without a second thought.model— pins the command to a specific model regardless of what the session is currently using.
Inside the body, !`command` runs a shell command and inlines its output before Claude sees
the rest of the prompt — handy for pulling in git diff or git log automatically
instead of asking Claude to run it as a separate step.
Personal vs. project vs. namespaced commands
| Location | Scope | Notes |
|---|---|---|
.claude/commands/ | Project, shared | Commit to git so your whole team gets the same commands |
~/.claude/commands/ | Personal, all projects | Your own shortcuts, not shared |
Subdirectories create a namespace: a file at .claude/commands/frontend/component.md becomes
/frontend:component. Use this once you have enough commands that a flat list gets confusing —
grouping by area (frontend, release, review) keeps the autocomplete menu scannable.
Slash commands vs. subagents vs. skills vs. hooks
All four customize Claude Code's behavior, but they answer different questions:
- Slash commands — "run this exact prompt, right here, in my current context." Fast, explicit, no isolation.
- Subagents — "run this in a separate context and just tell me the result." See our subagents guide for when isolation is worth the startup cost.
- Skills — "load this knowledge or workflow into my current context automatically when it's relevant," without you having to invoke anything by name.
- Hooks — "always run this deterministic check at a specific lifecycle point," no invocation needed at all. See our hooks examples guide.
A rough rule: if you have to remember to type something, it's a command. If you want it to happen automatically, it's a hook. If you want isolation from your main context, it's a subagent. Commands and subagents combine well — a custom command's body can explicitly tell Claude to delegate to a named subagent.
FAQ
What is a slash command in Claude Code?
A slash command is a control you type at the start of a message, like /clear or
/review, that tells Claude Code to perform an action on the session itself rather than
treating the text as a task. Some are built in; you can also write your own custom ones.
How do I create a custom slash command?
Create a Markdown file in .claude/commands/ (shared with your team via git) or
~/.claude/commands/ (personal, every project). The filename becomes the command name,
optional YAML frontmatter can set a description, argument-hint,
allowed-tools, and model, and the file body is the prompt Claude runs, with
$ARGUMENTS or $1, $2 standing in for whatever you type after the
command.
What's the difference between a slash command and a subagent?
A slash command runs in your current context, using whatever the session already has loaded. A subagent spawns a separate, isolated context window and returns only a summary. Use a slash command for a quick, repeatable action in the current conversation; use a subagent when you want verbose work kept out of your main context.
Can slash commands take arguments?
Yes. Anything you type after the command name is available in the command's body as
$ARGUMENTS (the whole string) or as $1, $2, $3 for
individual positional arguments, the same way a shell script reads its parameters.
Why isn't my custom slash command showing up?
Most often the .claude/commands/ or ~/.claude/commands/ directory didn't exist
when the session started, and a running session only watches directories that existed at launch. Restart
the session. Also check the file has a .md extension and that YAML frontmatter, if present,
is valid.
Reading the command list ≠ having the workflow
The fastest way to make commands, context management, and delegation second nature is reps. Practice them in a simulated Claude Code workspace — free, in your browser, with instant feedback.
Practice hands-on in the free interactive lessons