cheat sheet
Claude Code Slash Commands
Complete reference for every built-in Claude Code slash command — session control, context management, configuration, tools, MCP, and authoring custom commands with arguments.
Claude Code Slash Commands
What it is
Slash commands are shorthand triggers typed at the Claude Code interactive prompt as /<name>. They invoke built-in features (session control, context inspection, configuration), call user-defined Markdown commands (.claude/commands/<name>.md), or, when a plugin/skill registers them, hand off to the skill's instructions. They are the primary way to issue meta-instructions to Claude Code without consuming those instructions as part of a task prompt — the harness intercepts the slash, expands the command body, and routes the resulting message into the session.
How slash commands resolve
When you type /foo, Claude Code resolves the name in priority order: built-in first, then project commands in .claude/commands/, then user commands in ~/.claude/commands/, then plugin-registered skills. The first match wins. Tab-completion lists all matches across all sources.
> /<TAB>
/help /exit /clear /compact /config /model /memory
/mcp /cost /status /doctor /review /deploy /pr-review
Output: (none — autocomplete dropdown opens)
Session control
Session-control commands manage the lifecycle of the current REPL — exiting, clearing, compacting, and resetting state.
| Command | What it does |
|---|---|
/help | Show available commands and keyboard shortcuts |
/exit or /quit | End the session |
/clear | Discard all conversation history and start blank |
/compact | Summarize conversation history to free context window space |
/reset | Alias for /clear |
/init | Generate a CLAUDE.md from the current project |
> /clear
Output:
Session cleared. Starting fresh.
> /compact
Output:
Compacted 61,970 tokens of history into a 4,210-token summary.
Context window: 22,550 / 200,000 (11%) used.
Use
/compactinstead of/clearwhen you want Claude to remember what it has done so far but the conversation is getting long./clearwipes everything;/compactkeeps a condensed summary.
Context and memory
These commands operate on Claude's persistent memory (CLAUDE.md files) and on the running context window.
| Command | What it does |
|---|---|
/memory | Open the global ~/.claude/CLAUDE.md file in $EDITOR |
/memory project | Open the project-level CLAUDE.md |
/context | Show a summary of current context window usage |
/add-dir <path> | Extend filesystem access to another directory |
> /context
Output:
Context window: 84,310 / 200,000 tokens used (42%)
System prompt + tools: 18,200
CLAUDE.md (project + global): 4,140
Conversation: 61,970
> /add-dir ~/Code/shared
Output:
Added /home/alice/Code/shared to filesystem scope.
Configuration
Configuration commands inspect or modify settings without leaving the session. /config opens the active settings.json; /model swaps the active model; /permissions lists effective allow and deny rules.
| Command | What it does |
|---|---|
/config | Open or show the active settings (project + user) |
/model | Show the active model |
/model <id> | Switch model for the rest of the session |
/permissions | Show current tool permission rules |
> /model
Output:
Active model: claude-sonnet-4-6
> /model claude-opus-4-7
Output:
Active model is now claude-opus-4-7.
Supported model IDs include claude-opus-4-7, claude-sonnet-4-6, and claude-haiku-4-5. Use the full versioned ID (e.g. claude-haiku-4-5-20251001) to pin a specific snapshot.
Bug reporting and status
These commands surface diagnostic information about the current session and your account.
| Command | What it does |
|---|---|
/bug | Report a bug to Anthropic with session context attached |
/status | Show account status, usage tier, and active model |
/cost | Show estimated cost of the current session |
/version | Show installed claude-code version |
> /cost
Output:
Session cost: $0.23
Input tokens: 48,320
Output tokens: 6,140
Cache hits: 31,200 (saves ~$0.09)
> /status
Output:
Account: alice@example.com
Plan: Pro
Active model: claude-sonnet-4-6
This month: $14.27 of $100 cap
Doctor and diagnostics
/doctor runs an environment health check — API key, Node version, network connectivity, MCP server liveness. Useful when something is failing and you need a quick "is it me or the network" answer.
> /doctor
Output:
✅ API key found (ANTHROPIC_API_KEY)
✅ Node.js 22.2.0
✅ npm 10.7.0
✅ @anthropic-ai/claude-code 1.3.0
✅ API connectivity: OK
✅ MCP servers: 3 connected, 0 disconnected
MCP server management
MCP commands manage Model Context Protocol servers — adding, removing, listing, and inspecting them. The same operations are also available via claude mcp ... on the command line for use in scripts.
| Command | What it does |
|---|---|
/mcp | List connected MCP servers and their status |
/mcp add <name> <command> | Add a new MCP server |
/mcp remove <name> | Remove an MCP server |
/mcp restart <name> | Restart an MCP server |
/mcp tools <name> | List tools exposed by a specific server |
> /mcp
Output:
Connected MCP servers:
github (8 tools) ✅
postgres (3 tools) ✅
memory (2 tools) ✅
See MCP Servers for full configuration details.
Mode switching
| Command | What it does |
|---|---|
/vim | Toggle vim keybindings in the input prompt |
/fast | Toggle Fast mode (lower latency, slightly weaker model) |
/think | Force the next response to use extended thinking |
/no-think | Disable extended thinking for the next response |
> /vim
Output:
Vim mode enabled. Press Escape for normal mode.
Subagent commands
Subagent commands spawn an isolated agent for a specific task — see Subagents for full details on the underlying Task tool.
| Command | What it does |
|---|---|
/agents | List configured subagent definitions |
/agents create <name> | Open an editor to define a new subagent |
/plan | Run the next prompt with a Plan-mode subagent (read-only) |
> /agents
Output:
Configured agents:
general-purpose — generic research and edits
plan — read-only planning
reviewer — security-focused PR review (project)
User-defined slash commands
Claude Code supports custom commands defined as Markdown files in ~/.claude/commands/ (global) or .claude/commands/ (project). Each .md file becomes a /command-name command, with the filename (minus .md) serving as the trigger.
Create a custom command
The command body is the user message that gets injected into the session when the slash is typed. Frontmatter is optional but lets you set description and constrain the tools the command may use.
mkdir -p ~/.claude/commands
Output: (none — exits 0 on success)
---
description: "Security-focused diff review"
---
Review the staged git diff for:
1. Security issues (secrets, injection, XSS)
2. Missing error handling
3. Test coverage gaps
4. Code style inconsistencies
Be concise. Report findings as a bulleted list grouped by severity:
Critical, Warning, Info.
Save the above as ~/.claude/commands/review.md. Now /review is available in every Claude Code session.
> /review
Output:
**Critical**
- None
**Warning**
- auth/login.py:47 — password compared with == instead of hmac.compare_digest (timing attack)
**Info**
- utils/format.py — new function `format_currency` has no test coverage
- README.md — installation instructions not updated for new dependency
Project-level command
Place the file in .claude/commands/ in your project root. The command only appears when you are inside that project.
---
description: "Run the pre-deploy checklist"
---
Run the full pre-deploy checklist for this project:
1. `npm run build` — confirm clean build
2. `npm run test` — confirm all tests pass
3. `python scripts/validate_frontmatter.py` — confirm content is valid
4. Report a summary: pass/fail per step, plus any warnings.
Arguments with $ARGUMENTS
Commands support an $ARGUMENTS substitution. Whatever text follows the slash command is interpolated into $ARGUMENTS before the body is sent.
---
description: "Extract a function into its own helper"
---
Extract the function or block described by "$ARGUMENTS" into its own well-named
helper function. Place the helper just above the call site. Add type hints.
Do not change behavior. Show the diff before applying.
Usage:
> /extract the date-parsing logic in process_invoice()
Output:
Proposed diff:
src/invoices.py
+ def _parse_invoice_date(raw: str) -> date:
+ return datetime.strptime(raw, "%Y-%m-%d").date()
...
Apply? [y/N]
Frontmatter schema
User commands accept the following optional frontmatter keys:
| Key | Type | Effect |
|---|---|---|
description | string | Shown in /help and tab-completion |
allowedTools | list | Restrict tools for this command's execution |
disallowedTools | list | Block tools for this command's execution |
model | string | Run this command with a specific model |
subagent | string | Run via the named subagent (e.g. plan) |
---
description: "Read-only architecture audit"
allowedTools: [Read, Glob, Grep]
model: claude-opus-4-7
---
Audit the project architecture and report findings. Read-only — do not edit any file.
Output: (none — file applies when /architecture-audit is invoked)
Skills and slash commands
Skills also surface as slash commands but resolve differently — they ship with full metadata, a SKILL.md file, and (often) bundled scripts. The harness presents them in the same /help menu, but invoking a skill triggers the Skill tool rather than just injecting a Markdown body. See Skills for details.
Keyboard shortcuts
These shortcuts work in the interactive prompt and complement the slash commands.
| Shortcut | Action |
|---|---|
Ctrl+C | Cancel current input or interrupt running operation |
Ctrl+D | Exit (same as /exit) |
Up / Down | Navigate input history |
Tab | Autocomplete slash commands and file paths |
Shift+Enter | Insert a newline without submitting |
Escape | Clear current input or cancel autocomplete |
Cmd+Esc (macOS) / Ctrl+Esc (Win/Linux) | Open Claude Code from VS Code |
Common pitfalls
- Wrong scope for personal commands — putting personal commands in
.claude/commands/commits them to the repo for every contributor; use~/.claude/commands/for personal scripts. $ARGUMENTStypo — only the exact string$ARGUMENTSis interpolated;$ARGSor${ARGUMENTS}are left literal.- Slash command name collisions — if both project and user commands define
/review, the project version wins; rename to avoid silent override. - Stale
/doctorresults —/doctorchecks the version on disk, not the running process; if you upgrade mid-session, restartclaudebefore re-checking. /clearis destructive — there is no undo; use/compactwhen in doubt.- Custom commands with frontmatter typos — invalid YAML frontmatter is silently ignored; the body still runs but tool restrictions, model overrides, etc., are not applied. Validate with
claude /doctor. - MCP commands without a running server —
/mcp tools <name>fails silently if the server has crashed; check/mcpfirst to confirm the connection.
Real-world recipes
Bootstrap a project with /init
/init reads the current directory and proposes a CLAUDE.md tailored to the project structure.
> /init
Output:
Detected: Astro + Tailwind project. Proposed CLAUDE.md:
# Project: <name>
## Stack
- Astro 4 (static output)
- Tailwind CSS
- Pagefind for search
...
Write to CLAUDE.md? [y/N]
Reusable PR review with /review
Drop a ~/.claude/commands/review.md once and invoke /review everywhere — see "Create a custom command" above.
Pre-deploy gate with /predeploy
Combine a project command with a hook that blocks pushes if /predeploy reports failures.
---
description: "Block-on-fail pre-deploy gate"
allowedTools: [Bash(npm test:npm run lint:python scripts/validate_frontmatter.py)]
---
Run npm test, npm run lint, and python scripts/validate_frontmatter.py.
Exit non-zero if any step fails. Output a one-line summary per step.
Quick refactor with /extract
> /extract the URL-parsing block in handle_request()
Output:
Proposed diff in src/router.py:
- <inline block, 11 lines>
+ url = _parse_request_url(request.path)
+ def _parse_request_url(path: str) -> URL: ...
Apply? [y/N]
Architecture audit at start-of-week
A read-only audit command, run weekly to surface drift.
---
description: "Weekly architecture audit"
allowedTools: [Read, Glob, Grep]
model: claude-opus-4-7
---
Audit the project for these issues and produce a single-page report:
1. Files larger than 500 lines that mix concerns
2. Public functions without docstrings
3. Modules that import from deeper layers (layering violations)
4. Circular imports
5. Dead code — exports with zero imports across the repo
Invoke with /audit and pipe the result into your team chat.
Quick reference card
Session: /help /exit /clear /compact /reset
Context: /memory /context /add-dir
Config: /config /model <id> /permissions
Cost: /cost /status /version
Diagnose: /doctor /bug
MCP: /mcp /mcp add /mcp remove
Mode: /vim /fast /think
Agents: /agents /plan
Custom: /your-command (from .claude/commands/ or ~/.claude/commands/)