Cheatsheet

Essential Slash Commands - Cheatsheet

SFEIR Institute

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 embeds dozens of native slash commands covering configuration, contextual navigation, diagnostics, and memory management. These commands significantly accelerate session management 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.

CommandDescriptionUsage Example
/helpDisplays general help and the list of available commands/help in the Claude Code prompt
/initInitializes a CLAUDE.md file at the project root/init in a new repository
/clearErases conversation history and frees the context/clear after a topic change
/compactCompresses the conversation to save tokens/compact "summarize the refactoring"
/costDisplays cumulative session cost in tokens and dollars/cost at any time
/configOpens or modifies Claude Code configuration/config to list settings
/modelChanges the LLM model used during the session/model claude-sonnet-4-6
/memoryOpens the CLAUDE.md file for quick editing/memory to add a convention
/doctorDiagnoses the installation/doctor
/loginAuthenticates your session/login
/logoutDisconnects your session/logout
/statusDisplays session status/status
/diffShows current modifications/diff
/permissionsManages tool permissions/permissions
/bugReports a bug to Anthropic/bug
/feedbackSends feedback to Anthropic/feedback
/resumeResumes a previous session/resume
/contextVisualizes loaded context/context
/planCreates a structured action plan/plan
/add-dirAdds a directory to context/add-dir ./lib
/mcpManages MCP servers/mcp
/hooksManages Claude Code hooks/hooks

This table covers the most common commands. 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.

The /help command takes no arguments. It displays the complete list of slash commands, keyboard shortcuts, and documentation links. For details on a specific command, check the online documentation or test it directly.

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 ElementTypical Content
Tech stackNode.js 22, TypeScript 5.4, Next.js 15
ConventionscamelCase for variables, PascalCase for components
Project commandsnpm run dev, npm test, npm run build
Commit rulesConventional 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"
CommandTokens BeforeTokens After (approx.)Info Loss
/clear150,0000Total
/compact150,00015,000-30,000Minimal
/compact "focus X"150,00010,000-20,000Targeted

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?

/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 practice, the cost of a development session varies depending on the model chosen and exchange intensity. When the session becomes long and responses slow down, it is a sign that the context is filling up. Launch /compact to compress the conversation.

You will find tips for optimizing your conversations in the first conversations guide.

Key takeaway: check /cost regularly to track your consumption and know when to use /compact.

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
ModelTokens/s (output)Relative CostRecommended Usage
Claude Haiku 4.5~1501xSimple tasks, quick questions
Claude Sonnet 4.6~905xStandard development
Claude Opus 4.6~4025xComplex 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 undo actions daily?

/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

Document your recurring patterns: naming style, test structure, commit conventions. A well-written CLAUDE.md improves response relevance from the first exchange.

To get the most from this feature, the CLAUDE.md memory system guide details best practices for writing.

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:

git checkout -- <file> # Undo changes to a file
git stash # Stash current changes
git reset HEAD~1 # Undo the last commit
ActionCommandEffect
Undo a modified filegit checkout -- Restores the file
Stash changesgit stashTemporary save
Erase everything (conversation)/clearResets context 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. To undo modifications, use standard git commands.

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:

  1. API key validity
  2. Network connectivity to Anthropic servers
  3. Installed Node.js version (minimum required: Node.js 18+)
  4. Configuration file integrity ~/.claude/settings.json
  5. File system access permissions
  6. Installed Claude Code version compatibility
CheckOK StatusKO Status - Action
API KeyOK ValidRe-run /login
NetworkOK ConnectedCheck proxy/VPN
Node.jsOK v22.xUpdate Node.js
ConfigOK Valid JSONDelete and recreate with /config
PermissionsOK Read/WriteFix permissions with chmod
VersionOK LatestRun 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.

ShortcutActionSlash Equivalent
Ctrl+CCancel the current generation-
Ctrl+LRefresh the screen display (does not reset context)-
EscapeExit multi-line mode-
Up arrowRecall the last sent message-
TabAutocomplete 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.


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