Slash Commands Mastery
You are three hours into a debugging session. Claude has been reading files, running tests, and narrowing down a race condition in your websocket handler. Then you accidentally close the terminal tab. Without knowing about /resume, that entire session — the context, the debugging thread, the file reads — is gone. You start over from scratch.
Most developers use maybe five slash commands. This guide covers all of them, because the ones you do not know are often the ones that save the most time.
What You Will Walk Away With
Section titled “What You Will Walk Away With”- A complete reference for every slash command with real usage patterns
- Keyboard shortcuts that eliminate mouse usage entirely
- Session management workflows for multi-day debugging and feature work
- Techniques for controlling context, costs, and model behavior mid-session
The Essential Commands
Section titled “The Essential Commands”Session Control
Section titled “Session Control”These commands manage the lifecycle of your conversations with Claude.
| Command | What It Does | When to Use It |
|---|---|---|
/clear | Wipes current context, starts fresh | Switching to unrelated work |
/compact | Summarizes conversation to free context | Long sessions approaching token limits |
/resume | Opens session picker to resume old sessions | Returning to yesterday’s debugging thread |
/rename | Names the current session | Before /clear so you can find it later |
/cost | Shows token usage for current session | Checking spend before a big operation |
/stats | Shows usage patterns (subscribers) | Reviewing your weekly usage trends |
Context and Memory
Section titled “Context and Memory”| Command | What It Does | When to Use It |
|---|---|---|
/memory | Opens your auto-memory file in an editor | Reviewing what Claude has learned |
/context | Shows what is consuming your context window | Debugging why context is full |
/model | Switches the model mid-session | Downgrading to Sonnet for simple tasks |
/config | Opens the settings interface | Adjusting permissions, themes, notifications |
Tool and Integration Commands
Section titled “Tool and Integration Commands”| Command | What It Does | When to Use It |
|---|---|---|
/mcp | Shows MCP server status and management | Checking which servers are connected |
/hooks | Displays configured hooks | Debugging hook behavior |
/agents | Creates or manages subagents | Setting up specialized workers |
/install-github-app | Sets up Claude Code GitHub Actions | First-time CI/CD integration |
Keyboard Shortcuts
Section titled “Keyboard Shortcuts”These shortcuts work inside the interactive REPL and eliminate context switches to your mouse.
| Shortcut | Action |
|---|---|
Tab | Accept Claude’s suggestion |
Shift+Tab | Toggle plan mode (think before acting) |
Ctrl+C | Cancel current generation |
Ctrl+D | Exit Claude Code |
Esc | Cancel current input / back out of multi-line |
Up/Down | Navigate input history |
Session Management Patterns
Section titled “Session Management Patterns”The Multi-Day Feature Branch
Section titled “The Multi-Day Feature Branch”When you are building a feature over several days, session management becomes critical.
-
Start a named session on day one
Terminal window claude -r "payments-v2"If the session does not exist, this creates it. If it does, it resumes it.
-
Work normally throughout the day Claude builds context about your codebase, test patterns, and the specific feature you are implementing.
-
Before ending your day, rename and clear if context is full
/rename payments-v2-day1/clear -
Resume the next morning
Terminal window claude -cThis continues the most recent session in the current directory. Or use
/resumeto pick a specific session. -
Fork when you need to explore a tangent
Terminal window claude --resume payments-v2 --fork-sessionThis creates a new session with the same context, leaving the original intact.
The Debugging Session
Section titled “The Debugging Session”Debugging sessions deserve special handling because you need to preserve the diagnostic context.
# Start with the error context piped incat error-log.txt | claude -p "What is causing this TypeError in the payment processor?"
# If you need to go interactive for deeper investigationclaude -cNon-Interactive Mode
Section titled “Non-Interactive Mode”The -p flag (print mode) is how you script Claude Code into pipelines, cron jobs, and one-off commands.
# One-shot question, returns answer and exitsclaude -p "What does the processPayment function in src/payments.ts do?"
# Pipe file contents for analysisgit diff HEAD~5 | claude -p "Summarize these changes for a changelog entry"
# JSON output for script consumptionclaude -p "List all API endpoints in this project" --output-format json
# Budget-limited operationclaude -p "Refactor src/utils/helpers.ts to use modern ES6 patterns" --max-turns 5 --max-budget-usd 2.00Advanced Flags for Power Users
Section titled “Advanced Flags for Power Users”These flags unlock patterns that most developers never discover.
System Prompt Control
Section titled “System Prompt Control”# Add instructions without replacing defaultsclaude --append-system-prompt "Always use TypeScript strict mode. Prefer functional patterns."
# Complete prompt replacement for specialized tasksclaude --system-prompt "You are a security auditor. Only analyze code for vulnerabilities."Tool Restrictions
Section titled “Tool Restrictions”# Read-only analysis mode -- Claude cannot modify filesclaude --tools "Read,Grep,Glob,Bash"claude --disallowedTools "Edit,Write"
# Allow specific bash commands without promptingclaude --allowedTools "Bash(npm run test *)" "Bash(npm run lint)"Dynamic Subagents from the CLI
Section titled “Dynamic Subagents from the CLI”claude --agents '{ "reviewer": { "description": "Reviews code changes for quality and security issues", "prompt": "You are a senior code reviewer. Focus on correctness, security, and maintainability.", "tools": ["Read", "Grep", "Glob", "Bash"], "model": "sonnet" }}'When This Breaks
Section titled “When This Breaks”Session resume shows “session not found”: Sessions are stored per-directory. If you moved your project or are in a different working directory, Claude Code cannot find the session. Use claude --resume without arguments to see all available sessions.
/compact loses important context: Compaction is lossy by design. Always give it guidance about what to preserve. If you compacted and lost critical debugging context, check whether the original session is still available via /resume.
Non-interactive mode hangs on permission prompts: In -p mode, Claude Code will stop if it needs permission for a dangerous operation. Use --dangerously-skip-permissions for trusted CI environments, or pre-allow specific tools with --allowedTools.
Model switch mid-session resets behavior: When you /model to a different model, the conversation history stays but the model’s interpretation of that history may shift. For critical work, start a new session with the target model instead.
What is Next
Section titled “What is Next”- Hooks and Automation — Build deterministic guardrails around the commands you have just learned
- Memory System — Control what Claude remembers between sessions
- Prompt Engineering — Write prompts that get better results from every command