Skip to main content

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

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
Use /help early and often

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 /compact instead (see below).
/clear is permanent

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:

  1. Claude reads the entire conversation.
  2. Claude writes a concise summary of what was discussed, decided, and done.
  3. The full conversation is replaced by this summary.
  4. You continue the session with more room in the context window.
Compact before you hit the wall

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

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.
/init is a starting point

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

CommandWhat It DoesWhen to Use It
/helpShows available commandsWhen you need guidance
/clearErases the entire conversationSwitching to a completely different task
/compactSummarizes the conversationLong sessions, before context gets full
/costShows token usage and costMonitoring spending, checking usage
/exitEnds the sessionWhen you are done working
/memoryViews/edits CLAUDE.mdAdding or reviewing project instructions
/initInitializes project memoryFirst time using Claude Code in a project

Try It Yourself

Work through these commands in order:

  1. Open Claude Code in your practice project folder.
  2. Run /help and read through the list of commands.
  3. Ask Claude a question about your project (for example, "What files are in this folder?").
  4. Run /cost to see how many tokens that exchange used.
  5. Ask Claude a few more questions to build up some conversation history.
  6. Run /compact and notice how the conversation is summarized.
  7. Run /cost again — compare the token count before and after compacting.
  8. Run /memory and review your project's CLAUDE.md. If you do not have one yet, try /init first.
  9. Run /clear to wipe the conversation.
  10. Ask Claude "What were we just talking about?" — it will not remember, because you cleared the history.
  11. Run /exit to end your session.

What You Learned

  • /help is your go-to reference for discovering commands and features.
  • /clear erases everything — use it when switching tasks entirely.
  • /compact summarizes the conversation to free up context space — use it proactively.
  • /cost lets you monitor token usage and spending.
  • /exit cleanly ends your Claude Code session.
  • /memory lets you view and edit your project's CLAUDE.md.
  • /init generates an initial CLAUDE.md based on your project structure.

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Advanced Slash Commands