← All guides

Claude Code Slash Commands: Complete Reference Guide

Every built-in slash command in Claude Code — /clear, /compact, /doctor, /init, /review, /vim, and more — with what each does and when to use it.

Claude Code Slash Commands: Complete Reference Guide

Claude Code's slash commands control session state, context management, and built-in workflows. The most important ones: /clear (reset context), /compact (summarise context to free up space), /init (generate CLAUDE.md for a project), and /review (structured code review). Type / in Claude Code to see the full list. This guide explains each command, what it does internally, and when to use it.


Session management commands

/clear

Clears the current conversation context. Claude starts fresh with no memory of the current session.

When to use:

What it doesn't clear: file system state (files you've written/modified still exist). /clear only resets the conversation history.


/compact

Summarises the current conversation into a compressed context. Frees up context window space for more work.

When to use:

How it works: Claude generates a summary of the conversation so far and replaces the full history with the summary. Subsequent work continues from the summary context. Some detail is lost in compression — the more specific the earlier work, the more important it is to verify after compacting.


/cost

Shows the token usage and estimated cost for the current session.

When to use: monitoring spend during long sessions, especially before starting a potentially expensive operation.


Project setup commands

/init

Reads your project and generates a CLAUDE.md file with project context, directory structure, dev commands, and conventions.

When to use: first time using Claude Code on an existing project. Run this before starting work — it creates the context file that makes all subsequent Claude Code sessions more productive.

What it generates:

Always review and edit the generated CLAUDE.md — Claude's inferences are a starting point, not a final document.


/doctor

Checks your Claude Code installation and configuration for issues.

When to use:

Outputs a diagnostic report: Node version, SDK version, API key status, configuration files found.


Development workflow commands

/review

Runs a structured code review of your recent changes.

When to use: before committing or creating a pull request. Equivalent to asking a senior developer to review your diff.

What it reviews:

Tip: run /review after a focused coding session, not during — it evaluates the complete diff, not individual lines.


/vim

Enables Vim keybindings in the Claude Code input field.

When to use: if you prefer Vim navigation for editing your prompts. Toggle with /vim to enable, /vim again to disable.


Context and memory commands

/memory

Manages Claude Code's persistent memory files. Claude Code can maintain notes across sessions in ~/.claude/memory/.

When to use:


Output and format commands

/output

Changes the output mode. Options include:

When to use: when piping Claude Code output to other tools that expect plain text or JSON.


Custom commands (CLAUDE.md slash commands)

You can define project-specific slash commands in your CLAUDE.md:

## Custom commands

/deploy: Run `vercel --prod --yes` after confirming the build passes
/check: Run typecheck, lint, and tests in sequence. Report any failures.
/ship: Run /check, then create a commit, then /deploy

When you type /deploy in Claude Code, it executes the described workflow. This is the most powerful customisation feature — you define repeatable workflows once, then invoke them with a single command.

Examples of useful custom commands:

## Custom commands

/sync: Pull latest from main, rebase current branch, and report any conflicts

/audit: Check for unused dependencies, deprecated APIs, and TODO comments. 
        Report findings grouped by severity.

/docs: Update the JSDoc comments for any functions modified in the last commit.

/perf: Run the build and report bundle sizes. Flag any that increased by >5%.

/test-coverage: Run tests with coverage. Report any files under 80% coverage.

Keyboard shortcuts (not slash commands but equally important)

Shortcut Action
Ctrl+C Cancel current operation
/ Navigate command history
Ctrl+R Search command history
Tab Autocomplete slash commands
Esc Cancel current input

Frequently asked questions

Does /clear delete any files Claude created? No. /clear only resets the conversation context — the in-memory history of what Claude has said and done. Any files written to disk, any git commits made, any code changes are permanent until you undo them with git.

How often should I use /compact? When Claude Code warns you that context is getting long, or when you notice responses becoming less focused. For very long sessions (2+ hours of active work), compact every 1–2 hours of active work. For quick tasks under 30 minutes, you rarely need it.

Can I create global slash commands that work across all projects? Yes. Add custom commands to ~/.claude/CLAUDE.md (your global Claude Code configuration) and they'll be available in every project session.

What's the difference between /clear and starting a new Claude Code session? Functionally identical for the conversation context. Starting a new session also reloads CLAUDE.md and .claude/settings.json, which can be useful if you've changed those files.

Where are Claude Code's built-in commands documented? Type /help in Claude Code for a list of all available commands. The Anthropic documentation at docs.anthropic.com has the full reference.


Related guides


Take It Further

Power Prompts 300: Claude Code Productivity Patterns — Section 1 includes 15 custom Claude Code slash command templates for audit, deploy, test coverage, performance, and documentation workflows — copy-paste into your CLAUDE.md.

→ Get Power Prompts 300 — $29

30-day money-back guarantee. Instant download.

AI Disclosure: Drafted with Claude Code; all commands verified against Claude Code CLI as of April 2026.

Tools and references