Skip to content

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.

  • 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

These commands manage the lifecycle of your conversations with Claude.

CommandWhat It DoesWhen to Use It
/clearWipes current context, starts freshSwitching to unrelated work
/compactSummarizes conversation to free contextLong sessions approaching token limits
/resumeOpens session picker to resume old sessionsReturning to yesterday’s debugging thread
/renameNames the current sessionBefore /clear so you can find it later
/costShows token usage for current sessionChecking spend before a big operation
/statsShows usage patterns (subscribers)Reviewing your weekly usage trends
CommandWhat It DoesWhen to Use It
/memoryOpens your auto-memory file in an editorReviewing what Claude has learned
/contextShows what is consuming your context windowDebugging why context is full
/modelSwitches the model mid-sessionDowngrading to Sonnet for simple tasks
/configOpens the settings interfaceAdjusting permissions, themes, notifications
CommandWhat It DoesWhen to Use It
/mcpShows MCP server status and managementChecking which servers are connected
/hooksDisplays configured hooksDebugging hook behavior
/agentsCreates or manages subagentsSetting up specialized workers
/install-github-appSets up Claude Code GitHub ActionsFirst-time CI/CD integration

These shortcuts work inside the interactive REPL and eliminate context switches to your mouse.

ShortcutAction
TabAccept Claude’s suggestion
Shift+TabToggle plan mode (think before acting)
Ctrl+CCancel current generation
Ctrl+DExit Claude Code
EscCancel current input / back out of multi-line
Up/DownNavigate input history

When you are building a feature over several days, session management becomes critical.

  1. 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.

  2. Work normally throughout the day Claude builds context about your codebase, test patterns, and the specific feature you are implementing.

  3. Before ending your day, rename and clear if context is full

    /rename payments-v2-day1
    /clear
  4. Resume the next morning

    Terminal window
    claude -c

    This continues the most recent session in the current directory. Or use /resume to pick a specific session.

  5. Fork when you need to explore a tangent

    Terminal window
    claude --resume payments-v2 --fork-session

    This creates a new session with the same context, leaving the original intact.

Debugging sessions deserve special handling because you need to preserve the diagnostic context.

Terminal window
# Start with the error context piped in
cat error-log.txt | claude -p "What is causing this TypeError in the payment processor?"
# If you need to go interactive for deeper investigation
claude -c

The -p flag (print mode) is how you script Claude Code into pipelines, cron jobs, and one-off commands.

Terminal window
# One-shot question, returns answer and exits
claude -p "What does the processPayment function in src/payments.ts do?"
# Pipe file contents for analysis
git diff HEAD~5 | claude -p "Summarize these changes for a changelog entry"
# JSON output for script consumption
claude -p "List all API endpoints in this project" --output-format json
# Budget-limited operation
claude -p "Refactor src/utils/helpers.ts to use modern ES6 patterns" --max-turns 5 --max-budget-usd 2.00

These flags unlock patterns that most developers never discover.

Terminal window
# Add instructions without replacing defaults
claude --append-system-prompt "Always use TypeScript strict mode. Prefer functional patterns."
# Complete prompt replacement for specialized tasks
claude --system-prompt "You are a security auditor. Only analyze code for vulnerabilities."
Terminal window
# Read-only analysis mode -- Claude cannot modify files
claude --tools "Read,Grep,Glob,Bash"
claude --disallowedTools "Edit,Write"
# Allow specific bash commands without prompting
claude --allowedTools "Bash(npm run test *)" "Bash(npm run lint)"
Terminal window
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"
}
}'

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.