Claude Code Slash Commands Reference

Complete list of Claude Code slash commands (/help, /clear, /compact, /review, /init, /memory) with usage examples, keyboard shortcuts, and when to use each command.

💥 50p impulse-buy: Power Prompts PDF (first 10 buyers) 30 battle-tested Claude Code prompts · 8-page PDF · paste into CLAUDE.md and never re-type a prompt again · 50p impulse-buy, no commitment

Claude Code's slash commands control session state, memory, and context. This is the complete reference with usage examples.

Built-in slash commands

CommandWhat it doesWhen to use
/helpShow all available commands and keyboard shortcutsFirst time or when you forget a command
/clearReset conversation context (fresh session)Starting a new unrelated task
/compactCompress conversation history into a summaryLong sessions approaching context limit
/initAnalyze project and generate CLAUDE.mdFirst run on a new codebase
/memoryOpen CLAUDE.md for editingAdding/updating persistent project context
/reviewCode review current changes (git diff)Before committing — quick quality check
/configOpen Claude Code settings editorChanging model, theme, permissions
/costShow token usage and cost for current sessionMonitoring spend mid-session
/doctorDiagnose Claude Code setup issuesTroubleshooting auth or tool problems
/quit or /exitExit Claude Code interactive modeEnding session (also Ctrl+C)

Keyboard shortcuts

ShortcutAction
Ctrl+CInterrupt current operation / exit
Ctrl+RSearch command history (bash-style)
↑ / ↓Navigate input history
Ctrl+LClear terminal screen (context preserved)
Shift+EnterInsert newline without submitting
EscCancel current prompt input

/compact — manage long sessions

# When Claude Code says context is getting long, run:
/compact

# Claude summarizes all prior conversation turns into a dense summary,
# then continues with full context window available again.
# Useful for: debugging sessions that span hours,
# large refactors where you've asked many follow-up questions.

# Compact with a custom focus:
/compact Focus on the API changes we made and ignore the test fixes.

/init — generate CLAUDE.md for your project

# In your project root:
/init

# Claude Code reads your directory structure, package.json / pyproject.toml,
# git history, and existing docs to produce a CLAUDE.md with:
# - Project purpose (1 paragraph)
# - Tech stack (languages, frameworks, key packages)
# - Build/test/lint commands
# - Architecture overview (key dirs, entry points)
# - Conventions (naming, import style, test patterns)
# - Off-limits files / sensitive areas

# Review and edit the generated file — it becomes Claude Code's
# persistent memory across all future sessions in this project.

/review — pre-commit code review

# Review all uncommitted changes:
/review

# Review a specific file:
/review src/auth/middleware.py

# Review staged changes only:
/review --staged

# Claude Code runs git diff, reads the changed files in context,
# and produces: bug risks, logic errors, style issues, test coverage gaps.
# Typical output: 5–15 line bullet list, actionable items only.

Custom slash commands

# Create .claude/commands/deploy-check.md:

Verify this branch is safe to deploy:
1. Run the test suite and report any failures
2. Check for TODO/FIXME comments added since main
3. Verify no hardcoded secrets (API keys, passwords) in changed files
4. Confirm migrations are included if schema changed
5. Summarize the changes in 3 bullet points for the deployment log

# Now /deploy-check runs that full checklist in one command.
# Create .claude/commands/explain.md:
# (accepts $ARGUMENTS — text after the command name)

Explain $ARGUMENTS to a developer who is new to this codebase.
Include: what it does, where it's called from, and what would break if it were removed.
Keep the explanation under 200 words.

# Usage: /explain UserAuthMiddleware

CLI flags (non-interactive mode)

# Print output without interactive mode (useful in scripts):
claude --print "Summarize the last 3 commits"

# Specify allowed tools (security: limit what Claude can do):
claude --print "Review auth changes" --allowedTools "Read,Grep"

# Pipe input:
git diff HEAD~1 | claude --print "Summarize these changes for a changelog"

# Specify model:
claude --model claude-opus-4-7 "Perform a deep security audit of src/auth/"

Frequently asked questions

How do I see all Claude Code slash commands?
Type /help in Claude Code's interactive mode to see the full command list, or run claude --help in your terminal for CLI flags.
What does /compact do in Claude Code?
/compact compresses the current conversation context by summarizing earlier turns. This lets you continue a long session without hitting the context window limit. Claude generates a summary of prior work and replaces the full history with it.
What is /init in Claude Code?
/init analyzes your project directory and generates a CLAUDE.md file with project context, tech stack, build commands, and key conventions. Run it once when starting on a new codebase.
How do I clear Claude Code's context?
/clear resets the entire conversation context (equivalent to starting a fresh session). Use it when you want to start a new task without earlier context bleeding in.
Can I create custom slash commands in Claude Code?
Yes. Add them to .claude/commands/ as markdown files. The filename becomes the command name: .claude/commands/review-pr.md creates a /review-pr command. The markdown body is the prompt template.

Free tools

Cost Calculator → API Cookbook → Diff Summarizer → Skills Browser →

More examples

Claude API Python QuickstartClaude API Node.js / TypeScript QuickstartClaude API Streaming in PythonClaude API Streaming in Node.js / TypeScriptClaude API Tool Use in PythonClaude API Tool Use in Node.js / TypeScript