Essential Slash Commands
Module: Navigation & Shortcuts | Lesson: 3 of 4 | Time: ~10 minutes
What You Will Learn
- How to use /clear to reset the conversation
- How to use /compact to summarize and save context
- How to check costs with /cost
- How to use /exit, /help, and /memory
Prerequisites
- Completed Slash Commands Overview
The Core Commands
In this lesson, you will learn the seven slash commands you will use most often. These are the everyday tools that keep your Claude Code sessions running smoothly.
/help — Your Built-In Reference
When you forget what a command does or want to discover new ones, /help is your starting point.
/help
This displays a list of all available slash commands with short descriptions. You can also get help on a specific topic:
/help compact
Whenever you think "I wonder if Claude Code can do that...", try /help first. It is faster than searching the internet.
/clear — Start a Fresh Conversation
The /clear command erases the entire conversation history from the current session. Claude will no longer remember anything you discussed.
/clear
When to use /clear:
- You finished one task and want to start a completely different one.
- The conversation has gotten confusing and you want a clean slate.
- Claude seems "stuck" or confused by earlier context.
When NOT to use /clear:
- If you are in the middle of a multi-step task — Claude will forget the earlier steps.
- If you want to keep some context — use
/compactinstead (see below).
There is no undo for /clear. Once the conversation is erased, it is gone. If you are unsure, use /compact instead, which keeps a summary.
/compact — Summarize and Save Space
The /compact command is one of the most powerful tools in Claude Code. It takes your entire conversation so far, summarizes it into a concise form, and replaces the full history with that summary. This frees up space in the context window while keeping the essential information.
/compact
You can also guide what the summary focuses on:
/compact Focus on the database schema changes we discussed
When to use /compact:
- Your conversation is getting long and you notice Claude starting to lose track of earlier details.
- You have been working on several things and want to keep the important parts.
- Claude Code warns you that the context window is getting full.
- Before starting a new subtask within the same session.
How it works behind the scenes:
- Claude reads the entire conversation.
- Claude writes a concise summary of what was discussed, decided, and done.
- The full conversation is replaced by this summary.
- You continue the session with more room in the context window.
Do not wait until Claude Code warns you about context limits. If you have been working for 15-20 minutes on multiple things, a quick /compact keeps everything running smoothly.
/cost — Monitor Your Token Usage
The /cost command shows you how many tokens you have used in the current session and how much that costs.
/cost
The output will look something like this:
Session cost: $0.12
Input tokens: 15,234
Output tokens: 8,456
When to use /cost:
- To check how much your current session is costing.
- Before deciding whether to use
/compact(high token usage is a signal). - At the end of a session to see total usage.
- To build an intuition for how much different types of tasks cost.
Tokens are the unit Claude uses to measure text. A token is roughly 3/4 of a word in English. Both your prompts (input) and Claude's responses (output) consume tokens. Larger conversations use more tokens, which is why /compact is useful.
/exit — Leave Claude Code
The /exit command closes your Claude Code session and returns you to your normal terminal prompt.
/exit
This is the cleanest way to end a session. You can also press Ctrl+D or simply close the terminal window, but /exit ensures everything shuts down properly.
/memory — View and Edit Your Memory Files
The /memory command lets you quickly view and modify your memory files (CLAUDE.md) without leaving the conversation.
/memory
When you run this command, Claude opens your project's CLAUDE.md file for editing. You can review what is there, add new instructions, or remove outdated ones.
When to use /memory:
- At the start of a session, to check what instructions Claude is working with.
- After finishing a task, to save important decisions or conventions you established.
- When Claude does something you keep having to correct — add a rule to prevent it.
You: /memory
[Claude shows you the current CLAUDE.md contents]
You: Add a note that all API endpoints should use kebab-case URLs
[Claude updates the file]
/init — Initialize a New Project
The /init command sets up a new project with Claude Code. It creates a CLAUDE.md file with sensible defaults based on the project structure Claude detects.
/init
Claude will look at the files in your current directory and generate an initial CLAUDE.md that describes:
- What the project appears to be
- The technologies and frameworks detected
- The directory structure
- Suggested conventions
When to use /init:
- The very first time you use Claude Code in an existing project.
- When you clone someone else's repository and want Claude to understand it quickly.
- When starting a brand new project and wanting a head start on documentation.
The CLAUDE.md that /init generates is a first draft. Always review it and adjust it to match your actual preferences and project conventions. You can edit it directly or ask Claude to refine it.
Quick Reference
| Command | What It Does | When to Use It |
|---|---|---|
/help | Shows available commands | When you need guidance |
/clear | Erases the entire conversation | Switching to a completely different task |
/compact | Summarizes the conversation | Long sessions, before context gets full |
/cost | Shows token usage and cost | Monitoring spending, checking usage |
/exit | Ends the session | When you are done working |
/memory | Views/edits CLAUDE.md | Adding or reviewing project instructions |
/init | Initializes project memory | First time using Claude Code in a project |
Try It Yourself
Work through these commands in order:
- Open Claude Code in your practice project folder.
- Run
/helpand read through the list of commands. - Ask Claude a question about your project (for example, "What files are in this folder?").
- Run
/costto see how many tokens that exchange used. - Ask Claude a few more questions to build up some conversation history.
- Run
/compactand notice how the conversation is summarized. - Run
/costagain — compare the token count before and after compacting. - Run
/memoryand review your project's CLAUDE.md. If you do not have one yet, try/initfirst. - Run
/clearto wipe the conversation. - Ask Claude "What were we just talking about?" — it will not remember, because you cleared the history.
- Run
/exitto end your session.
What You Learned
/helpis your go-to reference for discovering commands and features./clearerases everything — use it when switching tasks entirely./compactsummarizes the conversation to free up context space — use it proactively./costlets you monitor token usage and spending./exitcleanly ends your Claude Code session./memorylets you view and edit your project's CLAUDE.md./initgenerates an initial CLAUDE.md based on your project structure.
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.