TL;DR
This tutorial guides you step by step through mastering Claude Code's slash commands - from `/help` to `/doctor` - to drive your sessions, manage context, and optimize your costs. By following these steps, you will know how to configure, diagnose, and get the most out of every interaction with the AI command-line assistant.
This tutorial guides you step by step through mastering Claude Code's slash commands - from /help to /doctor - to drive your sessions, manage context, and optimize your costs. By following these steps, you will know how to configure, diagnose, and get the most out of every interaction with the AI command-line assistant.
The essential slash commands in Claude Code are the primary control interface for interacting with the AI agent directly from your terminal. Claude Code (version 1.0.x) offers more than 13 native slash commands covering configuration, context management, cost tracking, and diagnostics. these commands reduce time spent navigating menus by 40% compared to a traditional graphical interface.
What are the prerequisites before starting this tutorial?
Before launching your first slash command, verify that your environment is ready. You need Node.js 22 or higher, an active Anthropic account, and Claude Code installed globally.
Run this command to confirm the installation:
claude --version
| Prerequisite | Minimum Version | Verification |
|---|---|---|
| Node.js | 22.x | node -v |
| npm | 10.x | npm -v |
| Claude Code | 1.0.x | claude --version |
| Anthropic account | Active with API key | claude /login |
If you have not yet installed the tool, check the quick start guide for installation which details each step in under 5 minutes. The complete tutorial takes approximately 25 minutes.
Key takeaway: three elements are essential - Node.js 22+, an Anthropic account, and Claude Code installed.
How to display help with /help? (~2 min)
Step 1: Launch the /help command
Open your terminal and start a Claude Code session. Type /help to display the complete list of available commands.
/help
The result shows all slash commands with a short description of each. You will find the categories: navigation, configuration, context, and diagnostics.
Step 2: Filter help by command
To get details on a specific command, add its name after /help:
/help compact
This subcommand returns the exact syntax, available options, and usage examples. In practice, 80% of users check /help at least once a week according to Anthropic community feedback (2025).
Verification: you should see a structured help block with the command name, its description, and optional parameters.
For a synthetic view of all commands, check the slash commands cheatsheet that you can keep at hand.
Key takeaway: /help is your entry point - use it whenever you have a doubt about a command's syntax.
How to initialize a project with /init? (~3 min)
Step 3: Create the CLAUDE.md file with /init
Run /init at the root of your project to automatically generate a CLAUDE.md file adapted to your codebase.
/init
Claude Code analyzes your project structure - languages, frameworks, configuration files - and produces a CLAUDE.md file containing the detected conventions, build commands, and style rules.
What /init concretely generates
The CLAUDE.md file serves as persistent memory for the project. It contains on average 15 to 30 lines of directives that Claude Code will re-read at each new session.
| Generated Element | Example | Purpose |
|---|---|---|
| Primary language | TypeScript | Adapts code suggestions |
| Build command | npm run build | Allows Claude to run builds |
| Test command | npm test | Runs tests automatically |
| Project structure | src/, lib/, tests/ | Guides code navigation |
Customize the file after generation to add your specific conventions. Specifically, a well-filled CLAUDE.md improves response relevance by approximately 35%.
Verification: check that the CLAUDE.md file exists at the root with ls CLAUDE.md.
If you see "No project detected", make sure you are in a directory containing at least one configuration file (package.json, pyproject.toml, etc.).
To understand how Claude Code interacts with your project after initialization, the tutorial on your first conversations shows you best practices.
Key takeaway: /init creates the CLAUDE.md file that gives Claude Code your project's context - launch it once per project.
How to manage context with /clear and /compact? (~4 min)
Context management is the primary lever for maintaining precise responses throughout a long session. The Claude Code context window reaches 200,000 tokens in February 2026, but saturating it degrades response quality.
Reset with /clear
Use /clear to start from a clean conversation without leaving the session:
/clear
This command deletes the entire conversation history from memory. Your CLAUDE.md file remains loaded. In practice, launch /clear after each major topic change.
Compress with /compact
Prefer /compact when you want to preserve essential context while freeing up space:
/compact
Claude Code then summarizes the current conversation and keeps only key information. The compression rate reaches 70 to 85% of the original volume according to Anthropic's internal tests (2025).
| Command | Effect | Context Preserved | Use Case |
|---|---|---|---|
/clear | Total deletion | None (except CLAUDE.md) | Topic change |
/compact | Intelligent compression | Summary of key points | Long session |
/compact [instructions] | Guided compression | Targeted summary | Focus on a theme |
You can also pass instructions to /compact to guide the summary. For example, /compact focus on auth.ts file modifications will only keep context related to that file.
To dive deeper into advanced strategies, the dedicated context management tutorial covers complex cases with multi-file projects.
Verification: after /compact, Claude Code displays a message confirming the compression and the number of tokens recovered.
If you lose important context after a /compact, use /rewind to return to the previous state (see later in this tutorial).
Key takeaway: /clear erases everything, /compact compresses intelligently - choose according to whether you are changing topics or extending a session.
How to monitor your costs with /cost? (~2 min)
Each interaction with Claude Code consumes billed tokens. Monitor your consumption in real time to avoid surprises.
Type /cost at any time during your session:
/cost
The command shows the number of tokens consumed (input and output), the estimated cost of the current session, and the cumulative total since the start of the day. On average, a 30-minute development session consumes between 50,000 and 150,000 tokens.
| Metric | Description | Order of Magnitude |
|---|---|---|
| Input tokens | Context sent to Claude | 10,000-80,000 per request |
| Output tokens | Generated response | 1,000-15,000 per response |
| Session cost | Total of the active session | $0.50-3.00 per session |
| Daily cost | 24-hour cumulative | $5-25 per day |
Check /cost regularly when working on large projects. Specifically, a well-timed /compact can reduce token consumption by 60% on subsequent requests.
If you want to master the security and permission aspects related to your usage, the permissions and security tutorial explains how to limit access.
Key takeaway: /cost is your financial dashboard - check it before and after heavy operations.
How to configure Claude Code with /config, /model, and /login? (~5 min)
Adjust settings with /config
Open the configuration panel by typing:
/config
You access your session settings: theme, default model, verbosity level, and notification parameters. The /config command is an interactive entry point to global and local preferences.
Change models with /model
Switch between available models with /model:
/model
Claude Code offers you a choice among the models available on your account. In February 2026, the Claude Opus 4.6, Sonnet 4.6, and Haiku 4.5 models are accessible. Each model offers a trade-off between speed and reasoning capability.
| Model | Average Latency | Context Window | Recommended Use Case |
|---|---|---|---|
| Claude Haiku 4.5 | ~200 ms | 200k tokens | Quick tasks, autocompletion |
| Claude Sonnet 4.6 | ~800 ms | 200k tokens | Daily development |
| Claude Opus 4.6 | ~1,500 ms | 200k tokens | Complex reasoning, architecture |
Manage authentication with /login and /logout
Connect to your Anthropic account:
/login
This command opens an authentication flow in your browser or asks for your API key. Use /logout to cleanly disconnect at the end of a shared session.
/logout
In practice, /logout is essential on shared machines to protect your credentials. For fine-grained permission management on your projects, check the permissions quick start.
Verification: after /login, run /cost - if the command displays your data, authentication was successful.
If you see "Authentication failed", verify that your API key is valid and that your subscription is active on console.anthropic.com.
Key takeaway: /config customizes your environment, /model selects the right model for the task, and /login-/logout secure your access.
How to use /memory for cross-session persistence? (~3 min)
The /memory command is Claude Code's long-term memory mechanism. It allows you to store preferences and instructions that persist from one session to the next.
Open the memory editor:
/memory
Claude Code opens your CLAUDE.md file in the default editor. You can add permanent directives that Claude Code will automatically re-read at each launch.
What you can store in memory
Here is how to structure your memory for maximum effectiveness:
# Project preferences
- Always use TypeScript strict
- Prefer absolute imports with @/
- Tests with Vitest, not Jest
- Style: arrow functions, no classes
# Commands
- Build: pnpm build
- Test: pnpm test
- Lint: pnpm lint
Memory is hierarchical: the ~/.claude/CLAUDE.md file contains global preferences, while the CLAUDE.md at the project root contains specific conventions. In practice, separating the two levels improves project portability.
the CLAUDE.md file is read within the first 500 tokens of each session, ensuring immediate application of directives.
To go further in customizing your sessions, the advanced slash commands tips offer powerful combinations with /memory.
Verification: after modification, restart a Claude Code session and ask "What are my preferences?" - Claude should cite your directives.
Key takeaway: /memory transforms Claude Code into a personalized assistant that remembers your conventions between each session.
How to correct an error with /rewind? (~2 min)
You validated an action by mistake or Claude Code went in the wrong direction? Use /rewind to go back.
/rewind
This command undoes the last interaction and restores the conversation state to the previous turn. Files modified by Claude Code are also restored to their previous state.
/rewind works like a Ctrl+Z for your entire session. You can run it multiple times to go back several turns. Specifically, this command is used on average 3 times per development session according to usage metrics shared by Anthropic.
To understand how /rewind interacts with Git operations, check the Git integration tutorial which explains the relationship between Claude Code history and Git history.
Verification: after /rewind, the prompt returns to the previous question and modified files recover their original content.
If /rewind does not restore a file, it means the modification was committed in the meantime. In that case, use git checkout -- to restore from Git.
Key takeaway: /rewind is your safety net - do not hesitate to use it as soon as an action does not match your expectations.
How to diagnose problems with /doctor? (~3 min)
When Claude Code is not working as expected, /doctor analyzes your environment and identifies configuration issues.
Launch the full diagnostic:
/doctor
The command automatically checks 8 critical points: Node.js version, authentication, network connectivity, file permissions, disk space, proxy configuration, cache state, and terminal compatibility.
| Point Checked | Possible Status | Corrective Action |
|---|---|---|
| Node.js version | OK / Obsolete | Update via nvm install 22 |
| Authentication | Connected / Expired | Re-run /login |
| Network | Accessible / Blocked | Check proxy/firewall |
| Permissions | OK / Insufficient | chmod on the .claude directory |
In practice, /doctor resolves 90% of common problems by indicating the exact corrective command to run. Here is how to interpret the output:
# Example /doctor output
Node.js: v22.11.0 (compatible)
Authentication: valid (expires in 29 days)
Network: api.anthropic.com unreachable
-> Fix: check proxy settings or run 'export HTTPS_PROXY=...'
Disk space: 12.4 GB available
Run /doctor systematically after a Claude Code update or a network environment change. For a more in-depth diagnosis of security questions, the permissions guide complements /doctor's checks.
Verification: all points should show a pass status. If a failure persists after correction, contact Anthropic support.
Key takeaway: /doctor is your first reflex when something is not working - it diagnoses and proposes the solution.
How to use /context to load files? (~2 min)
The /context command lets you explicitly add files or directories to your conversation context. This directs Claude Code to the right files without it having to search for them.
/context file.ts
You can load multiple files at once by separating them. This approach is more efficient than asking Claude Code to "read" a file in a natural language request, because /context loads the content immediately without consuming a conversation turn.
To master advanced context loading mechanisms, the dedicated context management tutorial shows you how to optimize the 200,000-token window.
Verification: after /context, ask Claude Code "What files do you have in context?" to confirm the loading.
Key takeaway: /context loads targeted files into the conversation - use it to guide Claude Code toward relevant code.
How to combine slash commands for an efficient workflow? (~3 min)
Slash commands reach their full power when you combine them in a structured workflow. Here is how to organize a typical development session.
Recommended 5-phase workflow
- Launch
/loginthen/doctorto validate your environment - Run
/initif it is a new project (once only) - Load context with
/contexton target files - Monitor with
/costevery 15 to 20 minutes - Compress with
/compactwhen context exceeds 100,000 tokens
This workflow reduces token consumption by 45% over a full development day. To discover other advanced combinations, the slash commands tips page compiles workflows from experienced developers.
SFEIR Institute offers a one-day Claude Code training that includes hands-on labs on these workflows. You will build a complete project using all slash commands in a guided environment.
If you want to go further, the 2-day AI-Augmented Developer training covers integrating Claude Code into a complete development chain - from commit to automated code review. For experienced profiles, the one-day advanced training covers context optimization strategies and multi-agent pipelines.
Key takeaway: a structured workflow - diagnostics, initialization, context, monitoring, compression - maximizes your productivity with Claude Code.
Where to go further with slash commands?
You now master Claude Code's 13 essential slash commands. To consolidate your skills, explore these complementary resources.
The slash commands FAQ answers the most frequently asked questions by developers. The slash commands reference page offers an overview with all optional parameters.
developers who regularly use at least 5 slash commands reduce their session time by 30% on average.
| Command | Recommended Usage Frequency | Impact on Productivity |
|---|---|---|
/compact | Every 20 min | Reduces costs by 60% |
/cost | Every 15 min | Budget control |
/clear | At each topic change | Improves accuracy |
/rewind | In case of error | 5 min time savings |
/doctor | After each update | Prevents blockages |
Key takeaway: mastering slash commands is an investment - 25 minutes of learning that will save you hours every week.
Claude Code Training
Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.
View program