Tutorial

Essential Slash Commands - Tutorial

SFEIR Institute

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 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.

What are the prerequisites before starting this tutorial?

Before launching your first slash command, verify that your environment is ready. You need Node.js 18 or higher (22 LTS recommended), an active Anthropic account, and Claude Code installed globally.

Run this command to confirm the installation:

claude --version
PrerequisiteMinimum VersionVerification
Node.js18.x (22 LTS recommended)node -v
npm10.xnpm -v
Claude Code1.0.xclaude --version
Anthropic accountActive with API keyclaude 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 18+, 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: Explore the displayed commands

The /help command displays all available slash commands in a single view. It takes no arguments: you cannot filter help for a specific command. To learn more about a particular command, check the online documentation or test it directly.

Verification: you should see the complete list of slash commands with a short description of each.

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 ElementExamplePurpose
Primary languageTypeScriptAdapts code suggestions
Build commandnpm run buildAllows Claude to run builds
Test commandnpm testRuns tests automatically
Project structuresrc/, lib/, tests/Guides code navigation

Customize the file after generation to add your specific conventions. A well-filled CLAUDE.md improves Claude Code's response relevance.

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 's internal tests (2025).

CommandEffectContext PreservedUse Case
/clearTotal deletionNone (except CLAUDE.md)Topic change
/compactIntelligent compressionSummary of key pointsLong session
/compact [instructions]Guided compressionTargeted summaryFocus 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, restart the conversation with the necessary instructions or use /clear to start fresh.

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.

MetricDescriptionOrder of Magnitude
Input tokensContext sent to Claude10,000-80,000 per request
Output tokensGenerated response1,000-15,000 per response
Session costTotal of the active session$0.50-3.00 per session
Daily cost24-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.

ModelAverage LatencyContext WindowRecommended Use Case
Claude Haiku 4.5~200 ms200k tokensQuick tasks, autocompletion
Claude Sonnet 4.6~800 ms200k tokensDaily development
Claude Opus 4.6~1,500 ms200k tokensComplex 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 a Claude Code error? (~2 min)

Claude Code modified a file incorrectly or went in the wrong direction? You can use standard git commands to revert.

# Undo changes to a specific file
git checkout -- src/auth.ts

# Stash all current changes
git stash

# Undo the last commit
git reset HEAD~1

You can also ask Claude Code directly to undo its changes: "Undo the changes you just made to auth.ts". It will use git to restore the file.

To understand how Claude Code interacts with Git operations, check the Git integration tutorial which explains the relationship between Claude Code history and Git history.

Verification: after a git checkout -- , the file recovers its original content.

Key takeaway: standard git commands (git checkout, git stash, git reset) are your safety net for undoing Claude Code's actions.

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 CheckedPossible StatusCorrective Action
Node.js versionOK / ObsoleteUpdate via nvm install 22
AuthenticationConnected / ExpiredRe-run /login
NetworkAccessible / BlockedCheck proxy/firewall
PermissionsOK / Insufficientchmod 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 direct Claude Code to the right files? (~2 min)

Claude Code accesses your project files automatically via its built-in tools (Read, Glob, Grep). Simply phrase your request in natural language:

> Read the file src/auth.ts and explain the authentication logic
> Search all files that import the database module

Claude Code browses relevant files and automatically integrates them into the conversation context. For large projects, you can be more specific in your requests to guide Claude Code toward the relevant files.

To master advanced context management mechanisms, the dedicated context management tutorial shows you how to optimize the 200,000-token window.

Verification: ask Claude Code "What files have you read?" to confirm it accessed the right files.

Key takeaway: Claude Code reads files automatically when you ask in natural language.

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.

  1. Launch /login then /doctor to validate your environment
  2. Run /init if it is a new project (once only)
  3. Ask Claude Code to read relevant files in natural language
  4. Monitor with /cost every 15 to 20 minutes
  5. Compress with /compact when context becomes large

This structured workflow optimizes token consumption 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 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.

CommandRecommended Usage FrequencyImpact on Productivity
/compactEvery 20 minReduces costs by 60%
/costEvery 15 minBudget control
/clearAt each topic changeImproves accuracy
git checkoutIn case of errorInstant restoration
/doctorAfter each updatePrevents blockages

Key takeaway: mastering slash commands is an investment - 25 minutes of learning that will save you hours every week.

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