TL;DR
Claude Code's slash commands are your shortcut arsenal for efficiently driving every AI-assisted development session. Master the 13 essential commands - from `/init` to `/doctor` - to optimize your context, reduce your costs, and accelerate your daily productivity.
Claude Code's slash commands are your shortcut arsenal for efficiently driving every AI-assisted development session. Master the 13 essential commands - from /init to /doctor - to optimize your context, reduce your costs, and accelerate your daily productivity.
The essential slash commands in Claude Code are built-in terminal shortcuts that let you control the AI agent's behavior without leaving your workflow. Claude Code offers 13 native slash commands covering configuration, memory management, diagnostics, and cost tracking. these commands reduce the number of interactions needed to manage an interactive session by 40%.
How to start a Claude Code session with /init and /help?
Launch /init as soon as you open your project to automatically generate a CLAUDE.md file at the root. This command analyzes your repository structure, detects the languages used, and suggests adapted conventions. In practice, /init creates a 15 to 30 line file in under 10 seconds.
$ claude
> /init
Claude Code then scans your configuration files (package.json, tsconfig.json, pyproject.toml) and generates contextual instructions. For a Node.js 22 project, it automatically detects the package manager and available scripts.
Run /help when you have a doubt about a command or feature. This command displays the complete list of slash commands with a concise description of each. You can also check the complete slash commands reference for an exhaustive detail of each option.
| Command | Function | Primary Use Case |
|---|---|---|
/init | Generates the CLAUDE.md file | First launch on a project |
/help | Displays contextual help | Discover available commands |
/doctor | Diagnoses the installation | Resolve a connection issue |
Key takeaway: /init is the first command to run on any new project - it lays the foundations of Claude Code's persistent memory.
Why is /compact essential for context management?
/compact is the conversational context compaction command. It summarizes your session history to free up space in the context window. Claude's context window reaches 200,000 tokens, but an intensive development session can saturate it in 20 to 30 minutes.
> /compact
Specifically, /compact reduces context size by 60 to 80% while preserving key decisions and file modifications. Use this command as soon as you notice slower responses or when Claude Code starts forgetting instructions given at the beginning of the session.
You can also pass an optional argument to guide the compaction:
> /compact focus on the auth module refactoring
This tip directs the summary toward elements relevant to your current task. To dive deeper into conversational management, check the tips for your first conversations which detail other steering techniques.
| Indicator | Before /compact | After /compact |
|---|---|---|
| Tokens used | ~180,000 | ~40,000 |
| Average response time | 8-12 s | 3-5 s |
| Instruction retention | Degraded | Optimized |
Key takeaway: Run /compact every 20-30 minutes during intensive sessions to maintain response quality.
How to track and optimize your costs with /cost?
/cost is the financial tracking command built into Claude Code. It displays in real time the number of tokens consumed and the estimated cost of your current session. In practice, a 45-minute session costs between $0.50 and $3.00 depending on task complexity.
> /cost
The result shows input tokens, output tokens, and the cumulative total cost. Check this counter regularly if you are working with a limited API budget. Each call to /compact also reduces consumption in subsequent turns since the sent context is lighter.
You can combine /cost with /compact for proactive management: check /cost, then launch /compact if the token volume exceeds 150,000. This approach saves you between 15 and 25% over a full workday. The slash commands cheatsheet summarizes these combinations in a printable format.
Key takeaway: /cost turns budget tracking into a reflex - check your spending after each major task.
What context files can you manage with /memory and /context?
/memory is the command for directly editing the CLAUDE.md file. It opens the memory file in your default editor and allows you to add, modify, or delete persistent instructions. Each modification takes effect immediately in the current session.
> /memory
The CLAUDE.md file persists between sessions. You can store your code conventions, naming preferences, and frequently used commands. Claude Code supports three memory levels: project (.claude/CLAUDE.md), user (~/.claude/CLAUDE.md), and repository (CLAUDE.md at the root).
Configure /context to load specific files into the session context. This command saves you from manually asking Claude Code to read each relevant file. For advanced memory management, the CLAUDE.md memory system tips guide details best practices for structuring.
| Memory Level | File | Scope |
|---|---|---|
| Project | CLAUDE.md (root) | Shared with team via git |
| User | ~/.claude/CLAUDE.md | All your local sessions |
| Directory | .claude/CLAUDE.md | Specific subdirectory |
Key takeaway: /memory is your durable customization tool - every instruction added improves all future sessions.
How to configure Claude Code with /config, /model, and /login?
/config is the centralized access point to Claude Code settings. This command opens the configuration panel where you adjust global behavior: theme, verbosity level, default permissions, and editor preferences.
> /config
Use /model to change models mid-session. Claude Code v2.x supports multiple models from the Claude family. In 2026, you can switch between Claude Opus 4.6 for complex tasks and Claude Haiku 4.5 for quick and economical operations.
> /model
> /model claude-sonnet-4-6
| Model | Average Latency | Relative Cost | Recommended Usage |
|---|---|---|---|
| Claude Opus 4.6 | 5-15 s | 1x (reference) | Complex refactoring, architecture |
| Claude Sonnet 4.6 | 2-6 s | 0.2x | Daily development |
| Claude Haiku 4.5 | 1-3 s | 0.05x | Quick fixes, simple questions |
Run /login to authenticate or change accounts. If your API token expires, /login restarts the authentication flow without restarting Claude Code. Conversely, /logout cleanly disconnects your session. Check the installation cheatsheet for authentication prerequisites.
Key takeaway: /model lets you adjust the performance/cost ratio per task - switch to Haiku for simple operations and save up to 95% on those calls.
Can you undo an action with /rewind and /clear?
/rewind is Claude Code's contextual undo command. It allows you to go back in the conversation and undo the latest changes made by the agent. Specifically, /rewind restores the dialog state to the previous turn, including associated file changes.
> /rewind
This command is your safety net. If Claude Code generates an inappropriate refactoring or modifies a file you did not want touched, launch /rewind immediately. Files are restored to their previous state via the built-in backup system.
/clear is the conversational reset command. It empties the entire context of the current session without affecting your project files. Use /clear when you change topics or when the context is polluted by a long off-topic exploration. For other session management techniques, the first conversations cheatsheet offers proven workflows.
| Command | Effect on Context | Effect on Files |
|---|---|---|
/rewind | Returns to previous turn | Restores modified files |
/clear | Erases all context | No effect |
/compact | Summarizes context | No effect |
Key takeaway: /rewind undoes actions, /clear starts from scratch - two complementary commands to maintain total control over your session.
How to diagnose a problem with /doctor?
/doctor is the built-in diagnostic command in Claude Code. It checks the state of your installation, authentication validity, network connectivity, and environment compatibility. In practice, /doctor performs 5 to 8 checks in under 15 seconds.
> /doctor
Run this command whenever you encounter unexpected behavior: truncated responses, authentication errors, or abnormal slowdowns. The /doctor report clearly indicates each verified point with a green (OK) or red (failure) status.
Here are the points checked by /doctor:
- Installed Node.js version (minimum required: Node.js 18)
- API authentication token validity
- Connectivity with Anthropic servers
- Available disk space for local cache
- Installed Claude Code version
- Presence of the
CLAUDE.mdfile in the project
If /doctor detects an authentication issue, launch /login to regenerate your token. For permission issues, check the permissions and security tips which cover common blocking cases.
Key takeaway: /doctor is your first reflex when something malfunctions - it identifies 90% of common problems in seconds.
What are the 15 advanced tips for mastering slash commands?
Here is the complete collection of tips organized by theme. Each tip is directly applicable in your terminal.
Productivity tips
- Combine
/costthen/compactwhen tokens exceed 120,000 - you reduce the cost of the next turn by 30 to 50%. - Add your command aliases in
CLAUDE.mdvia/memoryso that Claude Code recognizes them automatically. - Use
/compactwith a thematic argument to keep only the context relevant to your current task. - Launch
/initon every new repository before any interaction - the quality of your sessions depends on the quality of the initialCLAUDE.mdfile. - Check
/costafter each refactoring task: these operations consume on average 3x more tokens than simple generation.
Context management tips
- Run
/clearwhen switching from one module to another in a monorepo - a clean context produces more precise responses. - Prefer
/compactover/clearwhen staying on the same topic but the session is long - the summary preserves decisions made. - Load your critical files with
/contextat the beginning of the session so that Claude Code immediately has the right scope. - Structure your
CLAUDE.mdinto clear sections via/memory: conventions, frequent commands, restrictions. The memory system guide details optimal structures. - Monitor the signs of context saturation: when Claude Code forgets your instructions, it is time to launch
/compact.
Diagnostic and configuration tips
- Launch
/doctorafter each Claude Code update to verify your environment's compatibility. - Switch to Claude Haiku 4.5 with
/modelfor quick code review tasks - 95% savings on those calls. - Use
/loginto refresh your token without restarting the current session if a 401 error appears. - Use
/rewindimmediately after an unwanted modification - the longer you wait, the further the context drifts from the restore point. - Check
/helpwith a keyword when looking for a specific command - contextual search accelerates discovery. For a visual summary, the main slash commands page centralizes all information.
SFEIR Institute offers a one-day Claude Code training that covers all these commands with hands-on labs on real projects. You will master each slash command in concrete development scenarios.
To go further, the AI-Augmented Developer 2-day training integrates Claude Code into a complete assisted development workflow, including prompting best practices and CI/CD integration. Developers already comfortable can take the AI-Augmented Developer - Advanced level to deepen customization and advanced automation techniques in an intensive one-day session.
Key takeaway: mastering slash commands transforms Claude Code from a simple assistant into a precisely controlled development tool - learn the 5 key commands (/init, /compact, /cost, /memory, /rewind) and you cover 80% of daily needs.
Should you customize the execution order of slash commands?
Yes. The order in which you execute slash commands influences the quality of your sessions. Adopt this optimal sequence for each new project:
/init- Generates theCLAUDE.mdfile with project conventions/memory- Adjusts persistent instructions to your preferences/context- Loads the necessary reference files/model- Selects the model suited to the task's complexity
During a session, alternate between /cost and /compact to maintain an optimal performance/cost ratio. The slash commands cheatsheet offers a visual workflow that you can keep open next to your terminal.
developers who follow this initialization sequence reduce tokens consumed per session by 25% compared to unstructured usage.
To understand each command and its options in detail, the complete commands reference documents every available parameter. You can also check the permissions cheatsheet to configure authorizations before launching your first commands.
Key takeaway: a structured initialization workflow (/init -> /memory -> /context -> /model) guarantees productive sessions from the very first interaction.
Claude Code Training
Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.
View program