Complete list of Claude Code slash commands (/help, /clear, /compact, /review, /init, /memory) with usage examples, keyboard shortcuts, and when to use each command.
Claude Code's slash commands control session state, memory, and context. This is the complete reference with usage examples.
| Command | What it does | When to use |
|---|---|---|
| /help | Show all available commands and keyboard shortcuts | First time or when you forget a command |
| /clear | Reset conversation context (fresh session) | Starting a new unrelated task |
| /compact | Compress conversation history into a summary | Long sessions approaching context limit |
| /init | Analyze project and generate CLAUDE.md | First run on a new codebase |
| /memory | Open CLAUDE.md for editing | Adding/updating persistent project context |
| /review | Code review current changes (git diff) | Before committing — quick quality check |
| /config | Open Claude Code settings editor | Changing model, theme, permissions |
| /cost | Show token usage and cost for current session | Monitoring spend mid-session |
| /doctor | Diagnose Claude Code setup issues | Troubleshooting auth or tool problems |
| /quit or /exit | Exit Claude Code interactive mode | Ending session (also Ctrl+C) |
| Shortcut | Action |
|---|---|
| Ctrl+C | Interrupt current operation / exit |
| Ctrl+R | Search command history (bash-style) |
| ↑ / ↓ | Navigate input history |
| Ctrl+L | Clear terminal screen (context preserved) |
| Shift+Enter | Insert newline without submitting |
| Esc | Cancel current prompt input |
# 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.
# 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 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.
# 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
# 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/"