Skip to main content

Slash Commands: Managing Context, Agents, and Configuration

15/76
Chapter 4 Getting Started — A Tour of Essential Commands

Slash Commands: Managing Context, Agents, and Configuration

5 min read Lesson 15 / 76 Preview

The Complete Guide to Claude Code Slash Commands

Slash commands are your direct control interface for Claude Code. Type / at any point in the terminal to see the command palette. This lesson covers every built-in command and how to use them effectively.

Essential Session Commands

/clear — Reset Context Window

The most important command for productivity. Clears the entire conversation history.

/clear

When to use:

  • When you finish one task and start another (prevents context pollution)
  • When Claude is confused and giving inconsistent answers
  • When the context window is getting large and slowing down responses

/compact — Summarize and Compress

Compresses the conversation history into a summary, reducing token usage while preserving key decisions.

/compact

When to use:

  • Long sessions where you want to continue without losing key decisions
  • When approaching context limits but still mid-task

/memory — View CLAUDE.md Files

Shows all active CLAUDE.md files and their contents.

/memory

Useful for verifying your context engineering is loaded correctly.

Context Management Commands

/add-dir [path] — Add Directory to Context

Adds a directory to Claude's working context.

/add-dir src/payment-module

/remove-dir [path] — Remove Directory

Removes a directory from context.

/files — View Active Files

Shows which files are currently in Claude's context window.

Agent Control Commands

/plan — Enter Plan Mode

Switches Claude into read-only planning mode. Claude can read files and make plans but cannot take any actions (no file writes, no bash commands). Use this to review what Claude intends to do before granting execution permission.

/plan
> How would you approach refactoring the authentication module?

Claude presents a full plan. If it looks right:

/exit-plan-mode
> Proceed with the refactoring plan you just described

/exit-plan-mode — Leave Plan Mode

Returns to normal execution mode.

/auto — Autonomous Mode

Reduces approval prompts for routine operations. Claude executes more autonomously.

/auto

/verbose — Detailed Output Mode

Shows more detail about what Claude is thinking and doing.

Configuration Commands

/model [model-name] — Switch Model

Change the active Claude model mid-session.

/model claude-opus-4-6        # Most capable, highest cost
/model claude-sonnet-4-6      # Balanced (default)
/model claude-haiku-4-5-20251001  # Fastest, lowest cost

Smart usage: Use Haiku for quick questions and file lookups, Sonnet for most development work, Opus for complex architectural decisions.

/config — View/Edit Configuration

Opens the configuration interface.

/settings — Application Settings

Access Claude Code settings including UI preferences, API configuration, and more.

Git Commands

/commit — Create a Git Commit

Analyzes staged/unstaged changes and creates an appropriate commit.

/commit

Claude will:

  1. Run git diff to see changes
  2. Draft a conventional commit message
  3. Show you the message for approval
  4. Execute the commit

/pr — Create a Pull Request

Creates a GitHub pull request from the current branch.

/review — Code Review

Performs a code review on recent changes.

Utility Commands

/help — Show Help

Shows available commands.

/status — Session Status

Shows current session information: token count, active files, model.

/exit — End Session

Cleanly exits the Claude Code session.

Custom Slash Commands

Beyond built-in commands, you can create custom slash commands (covered in a dedicated lesson). These are stored in your CLAUDE.md or as separate files and invoke predefined workflows:

/deploy-to-staging    # Your custom deployment workflow
/run-quality-checks   # Your custom code quality pipeline
/create-feature       # Your custom feature scaffolding script

Command Combinations in Practice

Real-world usage combines commands fluidly:

# Review what Claude plans to do before it does it
/plan
> Refactor the UserService class to use dependency injection

# Review the plan, then execute
/exit-plan-mode
> Execute the refactoring plan

# Commit the clean changes
/commit

# Clear context for the next task
/clear

Master these commands and you'll navigate Claude Code sessions with precision and efficiency.