TL;DR
Claude Code offers over a dozen slash commands to drive your sessions from the terminal - context management, configuration, memory, diagnostics. This cheatsheet groups each command with its syntax, options, and concrete examples so you can master them without leaving your editor.
Claude Code offers over a dozen slash commands to drive your sessions from the terminal - context management, configuration, memory, diagnostics. This cheatsheet groups each command with its syntax, options, and concrete examples so you can master them without leaving your editor.
The essential slash commands in Claude Code are the primary interaction mechanism with the AI agent directly from your terminal. Claude Code (version 1.0+) embeds 13 native slash commands covering configuration, contextual navigation, diagnostics, and memory management. these commands reduce the number of interactions needed to drive a session by 40% compared to using the tool without shortcuts.
What are the most commonly used slash commands in Claude Code?
Before diving into the details of each command, here is the quick reference table you can keep at hand. Each row is self-contained: you can read it independently from the rest.
| Command | Description | Usage Example |
|---|---|---|
/help | Displays general help and the list of available commands | /help in the Claude Code prompt |
/init | Initializes a CLAUDE.md file at the project root | /init in a new repository |
/clear | Erases conversation history and frees the context | /clear after a topic change |
/compact | Compresses the conversation to save tokens | /compact "summarize the refactoring" |
/cost | Displays cumulative session cost in tokens and dollars | /cost at any time |
/config | Opens or modifies Claude Code configuration | /config to list settings |
/model | Changes the LLM model used during the session | /model claude-sonnet-4-6 |
/memory | Opens the CLAUDE.md file for quick editing | /memory to add a convention |
This table covers approximately 80% of common interactions. For advanced usage, check the complete slash commands reference which details each available option.
Key takeaway: these 8 commands cover the majority of daily needs - keep this table accessible.
How to use /help to navigate Claude Code?
The /help command is the universal entry point. Type /help in the prompt to display the complete list of commands, keyboard shortcuts, and available options.
$ claude
> /help
Claude Code then displays a structured summary with each command, its syntax, and a one-line description. In practice, /help consumes 0 context tokens since it sends no request to the model.
| Option | Behavior |
|---|---|
/help | Lists all slash commands |
/help shortcuts | Shows available keyboard shortcuts |
/help models | Lists compatible models |
If you are new to Claude Code, start with the installation and first launch cheatsheet before exploring advanced commands. You will find the prerequisites (Node.js 22+, API key) and the startup procedure there.
Key takeaway: /help costs nothing in tokens and remains the number one reflex when looking for a command.
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: Claude Code reads it at every session start.
$ claude
> /init
Claude Code analyzes the repository structure - detected languages, framework, naming conventions - then proposes a pre-filled CLAUDE.md. the generated file contains on average 15 to 25 lines of directives adapted to the project.
Check the generated content before committing it. You can then refine the instructions with the /memory command covered later. To understand the role of this file in depth, check the CLAUDE.md memory system guide.
| Generated Element | Typical Content |
|---|---|
| Tech stack | Node.js 22, TypeScript 5.4, Next.js 15 |
| Conventions | camelCase for variables, PascalCase for components |
| Project commands | npm run dev, npm test, npm run build |
| Commit rules | Conventional Commits, messages in English |
Specifically, a well-configured CLAUDE.md reduces clarification back-and-forth by 30% during the session.
Key takeaway: run /init on the first use of Claude Code in a project to lay the foundations of persistent memory.
How to manage context with /clear and /compact?
Context management is the number one performance factor in Claude Code. Two complementary commands let you maintain control: /clear and /compact.
/clear - Start from scratch
Use /clear when you switch topics or when the context becomes too loaded. This command erases the entire current conversation.
> /clear
The Claude Opus 4.6 context window is 200,000 tokens. In practice, a development session reaches this limit after 45 to 90 minutes of intensive exchanges. Launch /clear before switching to a new task to maximize response quality.
/compact - Compress without losing essentials
The /compact command asks the model to summarize the current conversation. You can pass an optional instruction to guide the summary.
> /compact
> /compact "keep only the architecture decisions"
| Command | Tokens Before | Tokens After (approx.) | Info Loss |
|---|---|---|---|
/clear | 150,000 | 0 | Total |
/compact | 150,000 | 15,000-30,000 | Minimal |
/compact "focus X" | 150,000 | 10,000-20,000 | Targeted |
To dive deeper into context management strategies, check the dedicated context management guide which covers advanced use cases.
Key takeaway: /compact preserves essential history, /clear starts from scratch - choose according to your need.
How to monitor costs with /cost and /context?
Two commands give you full visibility into your session's consumption.
/cost - Real-time financial tracking
Type /cost to display the cumulative cost of the current session. Claude Code breaks down input tokens, output tokens, and the estimated amount in dollars.
> /cost
Session cost: $0.42
Input tokens: 45,230
Output tokens: 12,890
Cache read: 128,400
Cache write: 45,230
In 2026, the average cost of a 60-minute development session with Claude Opus 4.6 is between $0.30 and $1.50 depending on exchange intensity.
/context - Visualize context usage
The /context command shows the percentage of the context window used. Here is how to interpret it:
| Usage | Recommended Action |
|---|---|
| 0-40% | Continue normally |
| 40-70% | Consider a /compact |
| 70-90% | Run /compact now |
| 90%+ | Launch /clear or /compact immediately |
In practice, beyond 70% usage, response quality starts to degrade. You will find tips for optimizing your conversations in the first conversations guide.
Key takeaway: check /cost regularly to avoid surprises, and /context to anticipate context limits.
How to configure Claude Code with /config, /model, /login, and /logout?
These four commands control the global configuration of your Claude Code environment.
/config - General settings
Open the configuration with /config to access persistent settings.
> /config
You can modify the theme, default permissions, notification mode, and other preferences. Configuration is stored in ~/.claude/settings.json.
/model - Switch models on the fly
Switch between models without leaving your session. Specifically, this allows you to choose a less expensive model for simple tasks.
> /model claude-sonnet-4-6
> /model claude-opus-4-6
> /model claude-haiku-4-5
| Model | Tokens/s (output) | Relative Cost | Recommended Usage |
|---|---|---|---|
| Claude Haiku 4.5 | ~150 | 1x | Simple tasks, quick questions |
| Claude Sonnet 4.6 | ~90 | 5x | Standard development |
| Claude Opus 4.6 | ~40 | 25x | Complex architecture, heavy refactoring |
If you want to dive deeper into model selection based on your tasks, the slash commands examples illustrate concrete scenarios.
/login and /logout - Authentication management
Run /login to authenticate or switch accounts. The /logout command disconnects the current session. Your API tokens and local configurations are not affected by /logout.
> /login
> /logout
For security questions related to authentication and permissions, check the permissions and security guide.
Key takeaway: /model saves you up to 80% by switching to Haiku for simple tasks.
How to use /memory and /rewind daily?
These two commands act on the persistence and temporal navigation of your sessions.
/memory - Edit persistent memory
The /memory command opens the project's CLAUDE.md file in your default editor. Add your conventions, style preferences, or business rules so that Claude Code applies them automatically at each session.
> /memory
# Opens CLAUDE.md in $EDITOR
projects with a well-written CLAUDE.md get 25% more relevant responses from the first exchange. Document your recurring patterns: naming style, test structure, commit conventions.
To get the most from this feature, the CLAUDE.md memory system guide details best practices for writing.
/rewind - Go back
The /rewind command undoes the last exchange (your message + Claude's response). Use it when a response goes in the wrong direction.
> /rewind
You can chain multiple /rewind calls to go back several turns. In practice, /rewind recovers the tokens consumed by the deleted messages, which gives back space in your context window.
| Action | Command | Effect on Context |
|---|---|---|
| Undo last exchange | /rewind | Frees corresponding tokens |
| Undo 3 exchanges | /rewind x 3 | Goes back 3 turns |
| Erase everything | /clear | Resets to zero |
If you are looking to integrate Claude Code into a Git workflow, the Git integration guide covers the associated versioning commands.
Key takeaway: /memory builds lasting project knowledge, /rewind corrects trajectory errors in real time.
How to diagnose problems with /doctor?
The /doctor command runs a series of automated checks on your Claude Code environment. Run it whenever unexpected behavior occurs.
> /doctor
/doctor checks 6 critical points in under 10 seconds:
- API key validity
- Network connectivity to Anthropic servers
- Installed Node.js version (minimum required: Node.js 18+)
- Configuration file integrity
~/.claude/settings.json - File system access permissions
- Installed Claude Code version compatibility
| Check | OK Status | KO Status - Action |
|---|---|---|
| API Key | OK Valid | Re-run /login |
| Network | OK Connected | Check proxy/VPN |
| Node.js | OK v22.x | Update Node.js |
| Config | OK Valid JSON | Delete and recreate with /config |
| Permissions | OK Read/Write | Fix permissions with chmod |
| Version | OK Latest | Run npm update -g @anthropic-ai/claude-code |
Specifically, 90% of problems encountered by developers are resolved by running /doctor then following the displayed recommendations. For additional troubleshooting tips, the first conversations guide covers common startup errors.
Key takeaway: /doctor is your first diagnostic reflex - it identifies the cause in under 10 seconds.
What keyboard shortcuts accelerate your Claude Code workflow?
Beyond slash commands, Claude Code offers keyboard shortcuts that complement your productivity. Here are the most useful combinations.
| Shortcut | Action | Slash Equivalent |
|---|---|---|
Ctrl+C | Cancel the current generation | - |
Ctrl+L | Clear the screen (without clearing context) | - |
Escape | Exit multi-line mode | - |
Up arrow | Recall the last sent message | - |
Tab | Autocomplete slash commands | - |
Press Tab after typing / to see the complete list of available commands with autocomplete. In practice, autocomplete reduces command typing time by 60%.
SFEIR Institute offers a one-day Claude Code training where you practice these commands on real lab projects. You will learn to chain slash commands and shortcuts to achieve a fluid workflow. To go further, the AI-Augmented Developer 2-day training covers integrating Claude Code into a complete CI/CD chain, and the advanced training in one day helps you master complex use cases like multi-agent and automation.
To explore all slash commands in detail with commented use cases, find the practical slash commands examples and the essential slash commands overview.
Key takeaway: combine keyboard shortcuts and slash commands to drive Claude Code without ever touching the mouse.
Claude Code Training
Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.
View program