TL;DR
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.
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 (version 1.0.x, running on the Claude Sonnet 4.5 model) exposes 13 native slash commands covering configuration, context management, debugging, and persistent memory.
these commands reduce the number of keystrokes needed to drive an agentic session by 40% 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 the 13 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.
| Command | Primary Role | Usage Frequency |
|---|---|---|
/help | Display help | Occasional |
/init | Initialize a project | Once per project |
/clear | Clear the conversation | Frequent |
/compact | Compress the context | Frequent |
/cost | Display costs | Regular |
/config | Modify configuration | Occasional |
/model | Switch model | Occasional |
/memory | Edit memory | Regular |
/doctor | Diagnose installation | As 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.
a well-configured CLAUDE.md file improves response relevance by 25% on refactoring tasks. 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.5. 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 context | Yes, completely | No, summarizes |
Preserves CLAUDE.md | Yes | Yes |
| Information loss | Total | Minimal |
| Use case | Task switch | Long session |
| Tokens freed | 100% | 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.5 rate is $3 per million input tokens and $15 per million output tokens.
Here is how to interpret a typical output:
| Metric | Example Value |
|---|---|
| Input tokens | 45,200 |
| Output tokens | 12,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.
Which context files to load with /context?
The /context command allows you to manually add files or directories to the conversation context. Claude Code then reads the specified content and integrates it into its understanding of the project.
> /context src/utils/auth.ts
> /context docs/
This command is useful when you are working on a file that Claude Code has not yet browsed. You can load up to 10 files simultaneously by separating them with spaces.
Specifically, a 500-line TypeScript file consumes about 2,000 context tokens. Plan your loads to stay under the 200,000 token limit. You can combine /context with /compact to load new files after compressing the history.
The what is agentic coding page explains how Claude Code automatically explores relevant files, which reduces the need for manual loading.
Key takeaway: /context injects specific files into the conversation - load only what is relevant to the current task.
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-5-20250514
> /model claude-opus-4-5-20250514
| Model | Max Tokens | Input Cost (1M tokens) | Use Case |
|---|---|---|---|
| Claude Sonnet 4.5 | 200,000 | $3 | Everyday tasks |
| Claude Opus 4.5 | 200,000 | $15 | Advanced reasoning |
| Claude Haiku 3.5 | 200,000 | $0.80 | Quick 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 and /rewind to manage memory?
Memory is a central concept in Claude Code. Two commands allow 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. projects with an actively maintained CLAUDE.md get 30% more consistent suggestions over long sessions.
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.
/rewind: go back
Use /rewind to undo the last exchange (your message and Claude's response). This command is useful when a response goes in the wrong direction and you want to rephrase your request.
> /rewind
In practice, /rewind also undoes file changes made during the last turn. You recover the exact state of the code before Claude Code's intervention.
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 and /rewind corrects errors instantly - combine both for total control.
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.
| Check | Average Time | Common Failure Cause |
|---|---|---|
| Node.js version | < 1 s | Version < 18 |
| API connectivity | 2-3 s | Proxy or firewall |
| Valid token | 1 s | Expired token |
| Config files | < 1 s | Malformed JSON |
| Extensions | 1-2 s | Version 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.
Claude Code Training
Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.
View program