TL;DR
Claude Code's slash commands form a set of essential shortcuts for driving your AI assistant directly from the terminal. This guide offers 12 concrete, copyable examples - from `/help` to `/doctor` - ranked by difficulty level, to master each slash command and optimize your daily workflow.
Claude Code's slash commands form a set of essential shortcuts for driving your AI assistant directly from the terminal. This guide offers 12 concrete, copyable examples (from /help to /doctor) ranked by difficulty level, to master each slash command and optimize your daily workflow.
The essential slash commands in Claude Code are the primary mechanism for quick interaction between the developer and the AI agent in the command line. Claude Code (which requires Node.js 18 or later when installed via npm) offers dozens of native slash commands covering configuration, context management, cost tracking, and diagnostics.
These commands significantly accelerate interaction compared to a traditional graphical interface.
SFEIR Institute trainings
Claude Code Training
1 day · Fundamentals
AI-Augmented Developer
2 days · Intermediate
How to use /help to discover all available commands?
Open your terminal and launch Claude Code. The /help command displays the complete list of slash commands with a short description of each. You do not need any additional arguments.
$ claude
> /help
The expected result shows a summary table of all commands, their syntax, and their description. In practice, /help is the first command to run when you start with Claude Code.
The /help command takes no arguments. It directly displays the complete list of available commands. For a complete onboarding, check the installation and first launch tutorial which guides you step by step.
| Command | Description | Argument Required |
|---|---|---|
/help | Displays all commands | No |
Key takeaway: /help is your entry point. Run it systematically during your first session.
How to initialize a project with /init?
The /init command creates a CLAUDE.md file at the root of your project. This file serves as persistent memory: it contains the conventions, critical paths, and instructions that Claude Code reads at each session.
$ cd my-project
$ claude
> /init
Claude Code analyzes your directory structure, detects configuration files (package.json, tsconfig.json, .eslintrc), and generates a pre-filled CLAUDE.md. A project initialized with /init gets more relevant responses from the first interaction.
Check the generated content and customize it according to your team conventions:
$ cat CLAUDE.md
To dive deeper into customizing this file, check the CLAUDE.md memory system tutorial which details each configurable section.
| Generated Element | Typical Content | Editable |
|---|---|---|
| Tech stack | Node.js, TypeScript, etc. | Yes |
| Code conventions | Linter, formatting | Yes |
| Build commands | npm run build, npm test | Yes |
Key takeaway: run /init once per project, then keep the CLAUDE.md up to date manually.
How to use /clear to reset a conversation?
The /clear command erases the current conversation history without leaving Claude Code. You keep your active session, but the previous context is deleted. This is useful when you change topics or when the context window approaches its limit.
> /clear
In practice, Claude Code frees conversation memory immediately. The Claude Opus 4.8 context window reaches 1,000,000 tokens. A very long conversation can slow responses as context grows.
Use /clear before starting a different task in the same project. To understand the complete slash commands reference, browse the essential slash commands guide.
| Situation | Recommended Action |
|---|---|
| Topic change | /clear |
| Conversation > 100,000 tokens | /compact first, /clear if insufficient |
| Starting a new feature | /clear |
Key takeaway: /clear deletes all context. Prefer /compact if you want to keep a summary.
How to optimize context with /compact?
The /compact command compresses the current conversation into a structured summary, then replaces it. You keep key information while substantially reducing context size. This is the most strategic command for long sessions.
> /compact
You can also specify a focus to guide the compression:
> /compact focus on the refactoring
This variant asks Claude Code to prioritize refactoring-related elements in the summary. The instruction after /compact is free-form natural language text. The effect described in the table below is qualitative: actual compaction results vary from session to session.
For advanced context management strategies, check the context management examples which illustrate real-world cases.
| Metric | Before /compact | After /compact |
|---|---|---|
| Tokens used | High | Substantially reduced |
| Response time | Slower | Faster |
| Key information | Full | Mostly preserved |
Key takeaway: launch /compact when your session grows large. You will gain speed without losing the thread.
How to track your spending with /cost?
The /cost command displays the cumulative cost of your current session. Per-token rates depend on the model you use, so see the official pricing for the current figures. Check your spending regularly to avoid surprises.
> /cost
The result shows the number of tokens consumed (input and output) and the estimated cost in dollars. In practice, the cost of an intensive development session depends on task complexity and the volume of tokens processed.
You can check the slash commands tips to learn how to reduce your costs by optimizing your prompts.
Rates vary by model, with Opus being the most capable and most expensive tier, Sonnet a balanced mid-tier, and Haiku the fastest and cheapest. For the current per-million-token figures, see the official pricing.
Key takeaway: run /cost after each heavy task to keep control of your API budget.
How to configure Claude Code with /config and /model?
The /config command opens the Claude Code configuration panel. You adjust permissions, theme, notifications, and output preferences. The /model command lets you change models mid-session.
> /config
To switch to a faster and cheaper model:
> /model sonnet
To switch back to the most capable model:
> /model opus
Sonnet is faster and cheaper than Opus and handles most routine code tasks well. Reserve Opus for the most complex architectural work.
The quick start guide details the configuration options available from installation.
Key takeaway: switch to Sonnet for simple tasks and reserve Opus for complex architectural problems.
How to manage authentication with /login and /logout?
The /login and /logout commands manage your connection to the Anthropic API. Use /login to authenticate with your API key or via OAuth.
> /login
Running /login opens a browser so you can authenticate via OAuth. If you prefer to use an API key, set ANTHROPIC_API_KEY in your environment and Claude Code authenticates with it automatically.
To cleanly disconnect at the end of a shared session:
> /logout
This command revokes the local session token. It does not delete your global API key. If you are working on a shared workstation, always run /logout before leaving.
For hands-on training on all these commands, SFEIR Institute offers the Claude Code one-day training. You will practice each slash command in guided labs, with progressive exercises on a real project.
The slash commands FAQ answers frequently asked questions about authentication and connection errors.
Key takeaway: run /logout systematically on shared or CI/CD environments.
How to use /memory to drive persistent memory?
The /memory command opens and directly edits your project's CLAUDE.md file from the Claude Code session. You add instructions without leaving the terminal.
> /memory
Claude Code opens the CLAUDE.md in interactive editing mode. You can add rules such as:
# Project conventions
- Use ESM imports (no require)
- Tests with Vitest, not Jest
- Commits in English, conventional format
To verify that your rules are properly loaded, launch a related question:
> What test framework should I use?
# Claude responds "Vitest" if memory is correct
You can also use /memory to record architectural decisions. The CLAUDE.md memory system tutorial explains the memory file hierarchy (project, user, organization).
Key takeaway: populate /memory after each team decision so that Claude Code stays aligned with your conventions.
How to correct a Claude Code error?
To undo an action performed by Claude Code, use standard git commands. This is the most reliable way to restore your files.
# Undo changes to a file
> git checkout -- src/auth.ts
# Or ask Claude Code directly
> Undo the changes you just made to auth.ts
In practice, git commands are essential when Claude Code modifies a file incorrectly. You can also use git stash to set aside all current changes.
Check the common slash command errors section to learn about the most common troubleshooting scenarios.
| Situation | Command | Effect |
|---|---|---|
| Wrong file edit | git checkout -- | Restores the file |
| Incorrect code generated | Rephrase the request | New attempt |
| Multiple files to restore | git stash or git checkout . | Restores everything |
Key takeaway: git commands (git checkout, git stash, git reset) are your safety net for undoing Claude Code's actions.
How to diagnose a problem with /doctor?
The /doctor command runs a series of checks on your Claude Code installation. It tests API connectivity, Node.js version, project configuration, and file system permissions.
> /doctor
The result looks something like the illustrative output below:
Anthropic API connection OK
CLAUDE.md file found
Write permissions OK
Git hooks not configured
Each check returns a status (pass or fail) with actionable details. In practice, /doctor detects many problems in just a few seconds.
If you encounter installation issues, start with the installation tutorial then launch /doctor to validate each step.
Key takeaway: run /doctor whenever unexpected behavior occurs. It is your first diagnostic reflex.
How to combine slash commands for advanced workflows?
For intermediate and advanced developers, combining multiple slash commands creates powerful workflows.
Here is a complete session-start workflow:
$ claude
> /model opus
> /init # First time only
> /memory # Check conventions
> /cost # Spending starting point
For a mid-session workflow when context saturates:
> /cost # Check consumption
> /compact # Compress the context
> /cost # Verify compression effect
Specifically, this 3-command workflow takes only a few seconds and optimizes your token consumption.
To go further, the AI-Augmented Developer 2-day training covers advanced workflows, Git integration, and cost optimization strategies. If you already master the basics, the AI-Augmented Developer - Advanced one-day training dives deeper into automation techniques and CI/CD pipelines.
Check the Git integration examples to see how slash commands integrate with Git operations.
Key takeaway: combine /cost, /compact, and /cost in a 3-command workflow to keep control of your long sessions.
What are the lesser-known shortcuts and variants of slash commands?
Some slash commands accept optional arguments that modify their behavior. Here are the most useful variants you will encounter in practice:
| Command | Variant | Effect |
|---|---|---|
/compact | /compact focus on the tests | Prioritizes test context (free text) |
/model | /model haiku | Ultra-fast model |
/model | /model opus | Most capable model |
Claude Haiku 4.5 is the fastest model, while Opus 4.8 takes longer to respond on complex reasoning. For simple code generation tasks (boilerplate, unit tests), Haiku is substantially cheaper than Opus.
Check the slash commands tips and the complete FAQ to discover other variants.
To dive deeper into your first interactions with Claude Code, the tutorial on your first conversations shows you how to structure your prompts for precise results.
Key takeaway: argument variants turn simple commands into precision tools. Explore them one by one.
How to solve common errors related to slash commands?
You will sometimes encounter errors when using slash commands. Here are the most common cases and their immediate resolution.
"Command not found" error:
> /comapct
# Error: Unknown command "/comapct". Did you mean "/compact"?
Claude Code includes an automatic corrector that suggests the closest command. Check the spelling and try again.
Expired session error:
> /cost
# Error: Session expired. Run /login to re-authenticate.
> /login
If your session has expired, run /login to re-authenticate. The common errors guide documents frequent errors with their solution.
| Error | Cause | Solution |
|---|---|---|
Unknown command | Typo | Fix the spelling |
Session expired | Authentication expired | /login |
Context too large | Context window full | /compact or /clear |
Model unavailable | Unauthorized model | /model to an available model |
Key takeaway: /doctor then /login resolves most session problems. Keep this reflex in mind.
Recent articles about Claude

Claude Managed Agents: Anthropic's Platform for Production Agent Deployment
Anthropic launches Managed Agents: a cloud platform for deploying AI agents in production. Secure sandbox, checkpointing, multi-agent, autonomous sessions lasting hours. Notion, Rakuten, Asana and Sentry already use it.

Claude Code Dream & Auto Dream: Automatic Memory Consolidation
After 20 sessions, Auto Memory notes become a mess. Auto Dream solves this by automatically consolidating Claude Code's memory: deduplication, stale entry removal, relative-to-absolute date conversion.

Claude Code Auto Mode: Autonomy Without the Risk
Auto Mode in Claude Code eliminates permission interruptions while keeping a safety net. A classifier analyzes every action before execution and blocks destructive operations. The sweet spot between approving everything and letting everything through.
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