Skip to content
Lesson 3 of 14

Slash Commands — Your Productivity Shortcuts

7 min read

The Command Palette at Your Fingertips

Claude Code ships with over 55 built-in slash commands that give you quick access to session management, developer tools, context controls, and workflow shortcuts. Instead of typing out full natural language requests for common operations, you type a forward slash and a keyword. These commands run instantly and keep you in flow.

To see the full list at any time, type:

/help

This prints every available command with a short description. As you learn the ones you use most, they become muscle memory -- just like keyboard shortcuts in your code editor.

Essential Session Commands

These are the commands you will use in almost every session:

/clear -- Wipe the current conversation and start fresh. Claude forgets everything from the current session but still loads your CLAUDE.md on the next prompt. Use this when the conversation has drifted off track or when you want to switch tasks completely.

/compact -- Compress the conversation history to free up context window space. Claude summarizes the conversation so far into a condensed form, preserving the most important details while discarding verbose intermediate steps. This is critical for long sessions where you are approaching the context limit.

# Compact with a focus instruction
/compact Focus on the database migration work and discard the earlier discussion about styling

You can pass an optional focus instruction to guide what Claude preserves during compaction. This is extremely useful when you have been working on multiple topics and want to keep only the relevant context.

/cost -- Display the total token usage and estimated cost for the current session. Run this periodically to stay aware of your spending, especially during long agentic sessions.

/status -- Show the current session state including model, permission mode, active tools, and loaded CLAUDE.md files. This is your dashboard for understanding exactly how Claude is configured right now.

/model -- Switch the underlying model mid-session. You can move between Claude Opus, Sonnet, and Haiku depending on the complexity of the current task:

# Switch to a faster model for simple tasks
/model claude-sonnet-4-20250514

# Switch to the most capable model for complex reasoning
/model claude-opus-4-20250514

Session Management

Claude Code sessions are persistent. You can leave and come back to a conversation later, branch off into parallel threads, or export your work.

/resume -- List your recent sessions and pick one to continue. Each session stores the full conversation history, so Claude remembers everything from where you left off.

/branch -- Create a new branch of the current conversation. The original session stays intact while you explore a different direction. This is perfect for trying two approaches to the same problem without losing your work on either.

# Branch the current conversation
/branch

# Now you are in a new session with the same history
# Try a different approach here

/rename -- Give the current session a descriptive name so you can find it later:

/rename auth-refactoring-phase-2

/export -- Export the conversation as markdown. Useful for documentation, sharing with teammates, or creating records of complex debugging sessions.

Developer Tools

These commands support your core development workflow:

/diff -- Show all file changes Claude has made in the current session. This gives you a clear picture of everything that has been modified, added, or deleted. Always run this before committing to verify the full scope of changes.

# See all changes in the session
/diff

/pr-comments -- Fetch and display comments from a GitHub pull request. Claude can then address the review feedback directly:

/pr-comments https://github.com/org/repo/pull/42

/security-review -- Ask Claude to perform a security review of the current codebase or recent changes. This scans for common vulnerabilities like injection risks, exposed secrets, insecure configurations, and authentication gaps.

/permissions -- View and manage the current permission settings. See which tools are allowed, which are blocked, and what the current permission mode is.

/sandbox -- Run Claude in a sandboxed environment where it cannot make changes to your actual files. Useful for experimenting with risky operations.

Quality of Life Commands

These small commands save significant time over a full session:

/copy -- Copy Claude's last response to your clipboard. No need to manually select text.

/context -- Visualize how much of the context window has been consumed. This shows a breakdown of what is taking up space: CLAUDE.md files, conversation history, tool results, and system instructions.

/context

This is invaluable for understanding why Claude might be losing track of earlier instructions -- it might simply be running out of context space.

/stats -- Display session statistics including number of messages, tool calls, files read, files written, and commands executed.

/effort -- Control how much computational effort Claude applies to responses. Lower effort means faster, cheaper responses for simple tasks. Higher effort means more thorough analysis for complex problems:

# Quick mode for simple lookups
/effort low

# Deep analysis mode for complex tasks
/effort high

/plan -- Ask Claude to create a plan before executing. Claude will outline the steps it intends to take and wait for your approval before starting work. Use this for complex, multi-step tasks.

Custom Slash Commands

You can create your own slash commands by adding markdown files to the .claude/commands/ directory in your project. Each file becomes a command named after the filename.

Create a deploy command:

<!-- File: .claude/commands/deploy.md -->
Run the following deployment sequence:
1. Run the full test suite with `npm test`
2. If tests pass, run `npm run build`
3. If build succeeds, run `npm run deploy:staging`
4. Report the deployment URL and any warnings

Now you can run it:

/deploy

Claude reads the markdown instructions and executes them as a multi-step task.

Dynamic Commands with $ARGUMENTS

Custom commands can accept arguments using the $ARGUMENTS placeholder:

<!-- File: .claude/commands/review.md -->
Perform a thorough code review of $ARGUMENTS.

Check for:
- Logic errors and edge cases
- Security vulnerabilities
- Performance issues
- Missing error handling
- Test coverage gaps

Provide a summary with severity ratings for each finding.

Use it like this:

/review src/api/auth.ts

The $ARGUMENTS placeholder gets replaced with everything you type after the command name, making your custom commands flexible and reusable.

Team Commands

Put custom commands in your project's .claude/commands/ directory and commit them to version control. Every team member who pulls the repository gets the same commands. This standardizes common workflows across the team:

.claude/
  commands/
    deploy.md          # Deployment workflow
    review.md          # Code review checklist
    release-notes.md   # Generate release notes
    onboard.md         # Explain project to new developers

Skills: The Evolution of Custom Commands

Custom slash commands remain fully functional, but Anthropic now recommends migrating complex commands to skills (covered in the next lesson). Skills offer auto-invocation, structured frontmatter, and script integration that slash commands do not support. For simple, manually-triggered workflows, slash commands are still the right tool.

Practical Tips

Run /compact proactively, not just when you hit the context limit. A good habit is to compact every 20-30 messages or whenever you shift to a new subtask. You lose some detail but gain a much more focused and responsive Claude.

Use /cost to develop a sense of which operations are expensive. Reading files is cheap. Running long shell commands that produce verbose output is expensive. Complex multi-file refactoring sessions can consume significant tokens -- compacting early keeps costs under control.

Combine /plan with /diff for maximum control: ask Claude to plan first, review the plan, execute it, then diff the results before committing. This three-step workflow -- plan, execute, verify -- catches mistakes early and gives you full visibility.

Try this exercise: create three custom slash commands for your project -- one for deployment, one for code review, and one for generating test files. Use $ARGUMENTS in at least one of them. Run each command several times and refine the instructions until they consistently produce the output you want. Once they are solid, commit them to your repository so your whole team benefits.