Comprehensive guide

Essential Slash Commands

SFEIR Institute

Claude Code offers over a dozen slash commands that drive your session without leaving the terminal. From /init to bootstrap a project to /compact to free up the context window, this guide details each command with concrete examples to master the command-line tool.

The essential slash commands in Claude Code are the primary interaction mechanism between the developer and the AI agent directly from the terminal. Claude Code exposes dozens of native slash commands covering configuration, context management, debugging, and persistent memory.

These commands are the fastest way to drive an agentic session compared to natural language input.

How to list and discover all available slash commands?

Type /help in the Claude Code interactive prompt to display the complete list of available commands and their short descriptions.

$ claude
> /help

This command displays all native commands as well as any custom commands defined in your configuration files. In practice, /help is the entry point you will use from your very first session to explore the tool's capabilities.

You can also check the dedicated slash commands tutorial which covers each command with step-by-step use cases. If you are new to Claude Code, start with the Your first conversations page to understand the general workflow.

CommandPrimary RoleUsage Frequency
/helpDisplay helpOccasional
/initInitialize a projectOnce per project
/clearClear the conversationFrequent
/compactCompress the contextFrequent
/costDisplay costsRegular
/configModify configurationOccasional
/modelSwitch modelOccasional
/memoryEdit memoryRegular
/doctorDiagnose installationAs needed
/statusDisplay session statusOccasional
/permissionsManage tool permissionsOccasional
/diffView current modificationsRegular
/bugReport a bug to AnthropicAs needed
/feedbackSend feedback to AnthropicAs needed

Key takeaway: /help is your compass - run it first to discover all available commands in your version.

How to initialize a project with /init?

The /init command automatically generates a CLAUDE.md file at the root of your project. This file serves as persistent memory that Claude Code reads at the start of every session.

> /init

Claude Code then analyzes the repository structure, detects the primary language, package manager, and naming conventions. Specifically, it produces a pre-filled CLAUDE.md containing the build commands, test commands, and style rules for the project.

You only need to run /init once per repository, then refine the file manually.

To understand the structure and best practices of the generated file, check the guide on the CLAUDE.md memory system. You will find the writing conventions that maximize the agent's understanding.

Key takeaway: /init creates the CLAUDE.md file that anchors project memory - run it once, then iterate on the content.

How to manage context with /clear and /compact?

The Claude Code context window is limited to 200,000 tokens with Claude Sonnet 4. Two commands allow you to actively manage it: /clear and /compact.

/clear: start from scratch

Use /clear to delete the entire current conversation. This command is useful when you switch topics or when the accumulated context is no longer relevant.

> /clear

The context is cleared, but the CLAUDE.md file remains loaded. You start fresh without losing project memory.

/compact: compress without losing

Run /compact to ask Claude Code to summarize the conversation and free up space in the context window. In practice, this command preserves key decisions while reducing the token count by 60 to 70%.

> /compact

You can also provide custom compaction instructions:

> /compact focus on the database migration decisions

In practice, on a project with 50 files and 8,000 modified lines, /compact reduces the context from 120,000 tokens to about 40,000 tokens while preserving critical information.

Action/clear/compact
Clears the contextYes, completelyNo, summarizes
Preserves CLAUDE.mdYesYes
Information lossTotalMinimal
Use caseTask switchLong session
Tokens freed100%60-70%

To go further on context management strategies, check the command reference which details advanced parameters. You will also find practical tips to optimize your long sessions.

Key takeaway: use /clear to switch topics and /compact to extend a session - never let the context saturate.

How to monitor costs with /cost?

Each interaction with Claude Code consumes tokens billed by Anthropic. The /cost command displays a summary of tokens consumed and the estimated cost for the current session.

> /cost

The result shows input tokens, output tokens, and the total cost in dollars. The Claude Sonnet 4 rate is $3 per million input tokens and $15 per million output tokens.

Here is how to interpret a typical output:

MetricExample Value
Input tokens45,200
Output tokens12,800
Input cost$0.14
Output cost$0.19
Session total$0.33

In practice, a 45-minute refactoring session costs between $0.20 and $0.80 depending on project complexity. Check your costs regularly with /cost to avoid surprises at the end of the month.

To find all monitoring commands at a glance, check the slash commands cheatsheet which groups syntaxes in a printable format.

Key takeaway: /cost gives you financial visibility - run it after each significant task to track your consumption.

How does Claude Code access project files?

Claude Code automatically reads your project files when needed, using its built-in tools (Read, Glob, Grep). You do not need to manually load files into the context. Simply ask in natural language:

> Read the file src/utils/auth.ts and explain the authentication logic
> Search for all uses of the validateToken function in the project

Claude Code then browses the relevant files and automatically integrates them into its understanding of the project. If the context becomes too large during the session, use /compact to compress it while preserving essential information.

The what is agentic coding page explains how Claude Code automatically explores relevant files as part of an agentic approach.

Key takeaway: Claude Code reads files automatically when you ask. Use /compact to manage context size during the session.

How to configure Claude Code with /config, /model, /login, and /logout?

Four commands control your Claude Code environment configuration. Master them to adapt the tool to your workflow.

/config: customize behavior

> /config

This command opens an interactive menu that lets you modify global preferences: theme, automatic permissions, notifications, and default paths. Changes are saved in ~/.claude/settings.json.

/model: switch models mid-session

Switch between available models without leaving your session:

> /model claude-sonnet-4-20250514
> /model claude-opus-4-20250514
ModelMax TokensInput Cost (1M tokens)Use Case
Claude Sonnet 4200,000$3Everyday tasks
Claude Opus 4200,000$15Advanced reasoning
Claude Haiku 3.5200,000$0.80Quick tasks

/login and /logout: manage authentication

Run /login to authenticate with Anthropic or your API provider. The /logout command revokes the active session token.

> /login
> /logout

To dive deeper into security permission configuration, check the Permissions and security guide which details the Claude Code authorization model. You can also find common configuration errors in the troubleshooting guide.

Key takeaway: /config and /model give you control over Claude Code's behavior - match the model to the complexity of each task.

How to use /memory for persistent memory management?

Memory is a central concept in Claude Code. The /memory command allows you to manipulate it directly.

/memory: edit CLAUDE.md on the fly

Launch /memory to open your project's CLAUDE.md file in your default editor. Changes take effect immediately in the current session.

> /memory

You can add team conventions, style preferences, or recurring instructions. SFEIR Institute recommends structuring the CLAUDE.md into sections: code conventions, build/test commands, and project-specific business rules. Find best practices in the guide on the CLAUDE.md memory system.

Undoing a Claude Code action

To undo an action performed by Claude Code, ask it to use git to revert, or use git commands directly in your terminal:

# Undo changes to a file
git checkout -- <file>

# Stash current changes
git stash

# Revert the last commit
git reset HEAD~1

To discover concrete examples of using these commands in real-world scenarios, check the slash commands examples page.

Key takeaway: /memory anchors your preferences durably. To undo modifications, use standard git commands.

How to diagnose problems with /doctor?

The /doctor command runs a series of checks on your Claude Code installation. It verifies the Node.js version (>= 18 required, Node.js 22 recommended in 2026), API connectivity, authentication token validity, and configuration file consistency.

> /doctor

The result displays a report with green/red indicators for each check. In practice, 80% of connection problems detected by /doctor stem from an expired token or a misconfigured proxy.

CheckAverage TimeCommon Failure Cause
Node.js version< 1 sVersion < 18
API connectivity2-3 sProxy or firewall
Valid token1 sExpired token
Config files< 1 sMalformed JSON
Extensions1-2 sVersion incompatibility

If /doctor reports a token issue, run /login to re-authenticate. For JSON configuration errors, open the ~/.claude/settings.json file and fix the syntax.

For a complete guide on installation and first launch of Claude Code, including resolving prerequisites detected by /doctor, see the dedicated page.

Key takeaway: /doctor is your diagnostic tool - run it whenever unexpected behavior occurs.

Do you need training to master all the commands?

Claude Code's slash commands are accessible, but combining them effectively in a professional workflow requires practice. SFEIR Institute offers the Claude Code training over one day: you will practice each command in real conditions on code projects, with guided labs covering initialization, context management, and debugging.

If you want to integrate Claude Code into a broader AI-augmented development practice, the AI-Augmented Developer 2-day training covers the entire ecosystem: advanced prompting, CI/CD integration, and multi-agent collaboration. For developers already familiar with the basics, the AI-Augmented Developer - Advanced one-day training deepens complex workflows and automation.

Find the slash commands FAQ for frequently asked questions and the main Claude Code page to navigate the entire content silo.

Key takeaway: guided practice accelerates learning - SFEIR trainings save you weeks of self-guided exploration.

Recent articles about Claude

Claude Code Training

This topic is covered in Module 6 of our Claude Code training

Useful Commands and Tips

1-day training • 60% hands-on labs • Expert instructors

View full program