TL;DR — Key Takeaways
- Built-in: /help, /clear, /model, /review, /compact, /cost, /doctor
- Custom: create .md files in .claude/commands/ → becomes /your-command
- Project commands (shared) vs user commands (personal)
- Custom commands = reusable prompts you write as Markdown files in
.claude/commands/
What Are Slash Commands?
Slash commands are shortcuts that trigger specific Claude Code behaviors or invoke pre-written prompt templates. You type /command-name in the Claude Code session and the command executes immediately — no need to write out a full instruction.
Claude Code ships with a set of built-in slash commands. You can also create your own by writing Markdown files in your project's .claude/commands/ directory or your personal ~/.claude/commands/ directory.
Don't confuse these with skills, which are a different mechanism: a command is a prompt template you invoke by typing it, while a skill is a folder of instructions the model loads on its own when the task matches. If that's what you're after, read Claude Code Skills explained.
Built-In Slash Commands Reference
Session Management
| Command | What it does |
|---|---|
/clear | Reset conversation history while keeping the session running. Use this between tasks to prevent context accumulation. |
/compact | Compress the conversation history into a summary to save tokens. Loses some detail but reduces cost significantly in long sessions. |
/exit | End the Claude Code session. |
Model and Configuration
| Command | What it does |
|---|---|
/model | Switch between Claude models mid-session. /model sonnet switches to Claude Sonnet; /model opus switches to Claude Opus. |
/allowed-tools | Toggle which tools Claude Code can use without asking for permission. |
/config | View and edit Claude Code configuration settings. |
Information and Debugging
| Command | What it does |
|---|---|
/help | Show available commands and documentation. |
/status | Display session stats: tokens consumed, estimated cost, model in use. |
/doctor | Run a diagnostics check on your Claude Code installation and configuration. |
/cost | Show the token and cost breakdown for the current session. |
Code Review and Quality
| Command | What it does |
|---|---|
/review | Run a structured code review on the current state of the session's changes. |
Using Slash Commands Effectively
/clear — Your Most Important Command
/clear is the single most impactful command for maintaining session quality. Use it whenever you:
- Finish one task and move to a new, unrelated one
- Notice the agent's responses becoming less precise
- Want to start fresh without re-running your
CLAUDE.mdcontext load
/clear
After /clear, Claude Code re-reads CLAUDE.md on the next instruction and starts with clean context. The session's tool configuration, MCP connections, and settings are preserved.
/compact — Managing Long-Session Costs
In a session that has run for 2+ hours, the conversation history can consume 50,000+ tokens. /compact asks Claude Code to summarize the history into a condensed form:
/compact
Claude Code generates a summary of what was accomplished, what decisions were made, and the current state. This replaces the detailed conversation history in the context window. You lose granular detail but retain the key decisions — and significantly reduce ongoing token costs.
Use /compact proactively before a session's costs get too high, not as a last resort when the context is nearly full.
/model — Switching Intelligence Levels
Different tasks benefit from different models. Claude Opus 4.8 is more capable for complex reasoning; Claude Sonnet 4.6 is faster and cheaper for implementation work.
/model sonnet # Switch to Claude Sonnet 4.6 (faster, cheaper)
/model opus # Switch to Claude Opus 4.8 (more capable, more expensive)
/model default # Return to your configured default
A practical pattern: start a session with Opus for architectural planning, then /model sonnet for the implementation work.
Custom Commands: Creating Your Own Slash Commands
Custom commands are slash commands you create by writing Markdown files. The filename becomes the command name; the file content becomes the instruction Claude Code executes.
Creating a Project Command
Create the commands directory:
mkdir -p .claude/commands
Create a command file:
# .claude/commands/review.md
File content:
Run a structured code review on the current changes. Check for:
1. TypeScript type safety — no `any` types, no type assertions without justification
2. Error handling — are all async operations awaited? Are errors caught and handled?
3. Security — is user input validated before use? Are auth checks in place?
4. Test coverage — are new functions tested? Do tests cover edge cases?
5. Pattern consistency — does the code follow the patterns in CLAUDE.md?
Output your findings as a numbered list of issues, sorted by severity (critical → minor).
For each issue: line number, description, and suggested fix.
Now in any Claude Code session in this project, you can run:
/review
Claude Code executes the review prompt automatically. The session context (current files, recent edits) is available to the command.
Creating a Personal Command
Personal commands live in ~/.claude/commands/ and are available across all your projects:
mkdir -p ~/.claude/commands
# ~/.claude/commands/standup.md
Content:
Summarize what was accomplished in this Claude Code session as a standup update:
- What was done (bullet points, past tense)
- What's next (what would be the logical next task)
- Any blockers encountered
Keep it under 100 words. Format for a team Slack message.
Run /standup at the end of any session to get a ready-to-paste team update.
Commands with Arguments
Custom commands can accept arguments using the $ARGUMENTS placeholder:
# .claude/commands/test-feature.md
Run the tests specifically for the "$ARGUMENTS" feature area.
1. Find all test files related to "$ARGUMENTS" in the test directories
2. Run only those tests with verbose output
3. If any fail, diagnose the root cause and suggest a fix
Usage:
/test-feature authentication
/test-feature billing
The string after the command name is passed as $ARGUMENTS into the command's prompt.
Command Scoping: Project vs Personal
| Location | Scope | Version controlled |
|---|---|---|
.claude/commands/ | Current project only | Yes (shared with team) |
~/.claude/commands/ | All your projects | No (personal only) |
Project commands are committed to version control and shared with your team. Everyone on the team gets the same /review, /deploy-check, and /pre-merge commands. Personal commands are yours alone — stored in your home directory and not committed anywhere.
Practical Command Examples
Pre-Merge Safety Check
# .claude/commands/pre-merge.md
Before merging this branch, verify:
1. Run the full test suite: `npm run test`
2. Run TypeScript type checking: `npx tsc --noEmit`
3. Check for console.log statements left in production code
4. Verify no .env files were accidentally modified
5. Confirm CLAUDE.md is up to date with any new patterns established in this session
Report pass/fail for each check. If anything fails, describe what needs to be fixed.
Context Update
# .claude/commands/update-context.md
Review the decisions and patterns established in this session and update CLAUDE.md:
1. Read the current CLAUDE.md
2. Identify any new architectural decisions, patterns, or conventions established in this session
3. Add them to the appropriate sections in CLAUDE.md
4. Remove any entries that are now outdated or contradicted by today's work
Show me the diff before writing.
Explain for New Developer
# .claude/commands/explain.md
Explain the $ARGUMENTS module/feature to a new developer joining the team:
- What it does and why it exists
- Key files and their roles
- How data flows through it
- Common patterns and conventions used
- What to watch out for (gotchas, constraints)
Assume the developer knows TypeScript and Next.js but not this codebase.
Usage: /explain authentication
Key Takeaways
- Built-in commands:
/clear(reset context),/compact(save tokens),/model(switch models),/status(usage stats),/help(docs) /clearis the most impactful command — use it between every unrelated task- Custom commands = Markdown files in
.claude/commands/— filename is the command name - Project commands (
.claude/commands/) are version-controlled and shared with the team - Personal commands (
~/.claude/commands/) are yours across all projects - Custom commands accept arguments via
$ARGUMENTSplaceholder - Practical command ideas: pre-merge check, context update, feature explanation, standup summary
Slash commands and custom commands make Claude Code sessions significantly more consistent and repeatable. Instead of typing the same quality-check prompt in every session, encode it once as a command and run it in one keystroke.
Related: Claude Code Hooks Explained · Claude Code Best Practices for Large Codebases · Claude Code: The Complete Guide