Slash commands are the in-session controls that change how Claude Code behaves without you having to type a full instruction. They work instantly, they do not consume extra tokens explaining what you want, and they give you direct control over context, memory, and execution flow.
This guide covers every slash command available in Claude Code, when to use each one, and the two decisions that trip up most users: when to use /compact versus /clear, and when to run /plan before a task.
What Slash Commands Are
Slash commands are not prompts. They are directives that go directly to the Claude Code application layer rather than to the language model.
When you type /clear, Claude Code clears the session context immediately. The model does not need to interpret what you mean.
This distinction matters because slash commands are reliable and deterministic. A command either runs or it does not.
You do not need to phrase them carefully or worry about interpretation.
Slash commands control the session. Prompts control the work. Knowing which to reach for keeps you in command of both.
All Slash Commands
| Command | Description | When to Use |
|---|---|---|
/help | Show all available commands and brief descriptions | First session, or when you forget a command name |
/clear | Clear all session context and start completely fresh | When context is corrupted or you are switching to an unrelated task |
/compact | Compress session history into a summary to save tokens | When sessions run long and responses feel less precise |
/plan | Show Claude Code’s proposed plan for the current task without executing | Before any change with more than 2 files or significant risk |
/memory | View and edit persistent memory (CLAUDE.md) | When you want to update project conventions without leaving the session |
/review | Request a code review of recent changes | After completing a feature or fix, before committing |
/init | Generate a CLAUDE.md file for the current project | When starting on a new or existing repo without a CLAUDE.md |
/status | Show current session status, model, and token usage | When you want a quick overview of the current session state |
/cost | Show token usage and estimated cost for the current session | Before long sessions or when tracking API spend |
/exit or /quit | End the current session | When you are done and want to close cleanly |
Command Reference
/help
Displays all available slash commands with brief descriptions. You do not need to memorize every command. /help is always available as a reference.
Run /help in your first few sessions until the commands feel natural. After that, you will rarely need it.
/clear
Clears everything from the current session: the conversation history, the file context Claude Code has built up, and any in-session instructions you have given. The next prompt starts as if you just opened Claude Code fresh.
CLAUDE.md is not cleared by /clear. It is a file on disk. Claude Code will re-read it at the start of the next interaction after you clear.
Use /clear when:
- Switching tasks entirely. Moving to an unrelated task with no relevant shared context.
- Context is corrupted. Claude Code is ignoring instructions or making strange decisions.
- Clean slate needed. You want no residual context from earlier in the session.
/compact
Compresses the session history into a concise summary and replaces the full history with that summary. The key difference from /clear is that you keep the important context. You just reduce how many tokens it occupies.
Claude Code summarizes what has been discussed and accomplished, then continues the session with that summary as the starting point. You can keep working without re-explaining what you were doing.
Use /compact when:
- Responses feel less precise. Claude Code seems to be losing track of earlier context.
- Long session. You have been in the same session for 45 minutes or more.
- High token usage.
/costis getting high and you want to continue the task.
/plan
Triggers Claude Code to show its proposed plan for the current task without executing any part of it. No files are written, no commands are run. You see the full proposal, then decide whether to approve or modify.
/plan is most valuable before risky changes. Risky means: the change touches more than two files, modifies a configuration file, involves a database migration, or affects shared utilities that many other parts of the codebase import.
/plan
Refactor the authentication middleware to support OAuth2 in addition to API keys
Review the plan output and look for files Claude Code intends to touch that you did not expect. Ask follow-up questions before approving.
Running /plan costs you 30 seconds. Not running it before a risky change can cost you an hour of recovery. The math is simple.
/memory
Opens the persistent memory interface where you can view and edit your CLAUDE.md file without leaving the session. Changes you make through /memory are saved immediately to disk and will apply to future sessions.
This is useful when you are mid-session and realize that a convention or constraint should be added to CLAUDE.md. Instead of opening a separate editor, you update the memory in place and continue working.
Use /memory when:
- Recurring mistakes. Claude Code keeps making the same mistake that a
CLAUDE.mdrule would prevent. - Recording decisions. You want a decision made during the session to apply to all future sessions.
- Refining conventions. You are updating
CLAUDE.mdbased on real working patterns.
/review
Asks Claude Code to review the most recent set of changes as a code review. It checks for correctness, security issues, missing error handling, style violations relative to your CLAUDE.md conventions, and anything else relevant to code quality.
Run /review after completing a feature or fix, before running git commit. This catches issues before they enter your git history.
The quality of /review output is directly proportional to how specific your CLAUDE.md is. If your CLAUDE.md describes your coding conventions, /review checks against them.
If it is generic or missing, the review will be generic too.
/init
Generates a CLAUDE.md file for your current project. Claude Code reads your repository structure, package.json, configuration files, and existing code to produce a starting CLAUDE.md.
The generated CLAUDE.md is a starting point, not a finished product. Review every section and edit it to match your actual conventions.
The /init output tends to be accurate about what your stack is but conservative about constraints, it will not know what you want to protect or what conventions you have not yet encoded.
Run /init once per project. After that, maintain CLAUDE.md manually or use /memory to update it during sessions.
/status
Shows a summary of the current session: which model is active, how many turns have occurred, current token usage, and which directory Claude Code is working in. It is a quick health check for the session.
Use /status when you are returning to a session after stepping away and want to know where things stand before sending a new prompt.
/cost
Shows the token usage and estimated cost for the current session. This is useful for teams that track API spend or individuals who want to understand what different task types cost.
Run /cost at the end of a session to build intuition for how much different tasks consume.
Over time, you will be able to estimate session cost before starting and decide whether to use a more efficient model for simpler tasks.
/exit and /quit
Both commands end the current Claude Code session cleanly. There is no difference between them. /quit is just an alias for /exit.
/compact vs /clear: When to Use Each
This is the decision that most new Claude Code users get wrong. The short version: use /compact first. Only use /clear when /compact is not enough.
| /compact | /clear | |
|---|---|---|
| Preserves context summary | Yes | No |
| Preserves CLAUDE.md | Yes (it is a file) | Yes (it is a file) |
| Preserves session instructions | Summarized | Lost |
| Token reduction | High | Complete |
| Best for | Long sessions, same task | Task switches, corrupt context |
If you are 45 minutes into debugging a complex issue and responses are getting fuzzy, use /compact. Claude Code will summarize what you have figured out so far and continue from there.
If you just finished a task and want to start something completely unrelated, use /clear. You do not need any of the previous context, and starting clean is faster than compressing context you will not use.
Think of /compact as condensing a meeting’s notes and /clear as ending the meeting and starting a new one.
Using /plan Before Risky Changes
The pattern for risky changes is: state the task, run /plan, review the output, then approve. Do not skip the review step because the plan looks right at a glance.
When reviewing a plan, look specifically for:
- Unrelated files being modified. Files not connected to the task scope.
- Config or environment file changes. Changes to
package.json,.env, or similar files. - New dependencies added without asking. Unexpected additions to your dependency tree.
- Deletions of any kind. Always confirm before accepting any file or code removal.
Any of these warrants a follow-up question before approving. Claude Code is generally accurate, but generally is not the same as always, and the cost of a missed deletion is high.
Build Workflows Around Slash Commands
The most effective Claude Code users have a consistent pattern for every session:
/status, check the state before starting./plan, review before any risky change./compact, compress when sessions run long./review, catch issues before committing./memory, record decisions so they persist.
That pattern, applied consistently, is what separates productive Claude Code use from chaotic use. The Claude Code course teaches this exact workflow and the principles behind each command.
If your team is adopting Claude Code and wants to build these practices into your engineering workflow from the start, Phos can help. We are a CCA-F certified Claude partner with 400+ engagements.
Talk to the Phos team to learn how we help teams build effective AI-assisted development practices.
FAQ
Do slash commands work in headless mode?
No. Slash commands are interactive session controls.
In headless mode (--headless), there is no interactive session, so slash commands have no effect. Use CLI flags instead to control Claude Code behavior in headless mode.
Can I create custom slash commands?
Not directly. Claude Code does not support user-defined slash commands.
However, you can create shell scripts that call claude with specific flags and prompts, and alias those scripts for quick access.
Does /review check for security vulnerabilities?
It can identify common security issues: hardcoded credentials, SQL injection patterns, missing input validation, and unsafe use of eval. However, it is not a substitute for a dedicated security scanner.
Use /review as one layer in a broader security practice, not as your only security check.
What is the difference between /plan in a session and the —plan CLI flag?
They do the same thing: show Claude Code’s proposed actions before execution. The --plan CLI flag applies to the entire session from the start.
The in-session /plan command applies to the next task you describe. Use the CLI flag when you always want to review plans. Use the in-session command when you want to review plans selectively.