Claude Code Slash Commands Guide
Slash commands are how you steer a session — not as prompts, but as direct control signals. Where natural language tells Claude what to build, slash commands control the tool itself: compressing context, switching models, locking down permissions, triggering predefined workflows.
Most people discover them by accident. This guide is the deliberate version.
Type / in any session and you’ll see a filterable list of everything available. Commands are only recognized at the start of a message, and whatever follows the command name gets passed to it as arguments. Since Claude Code ships updates constantly, /help is always the authoritative source for what’s actually installed in your version — don’t trust any list that claims to be complete, including this one.
There are four kinds of commands worth knowing about. Built-in commands like /help, /clear, and /model are hardcoded into the CLI and execute fixed logic. Bundled skills like /debug, /simplify, /batch, and /loop ship with Claude Code but are prompt-based — they hand Claude a detailed playbook and let it orchestrate the work. User skills are ones you define yourself in .claude/skills/ or ~/.claude/skills/. And MCP and plugin commands are exposed by external servers, namespaced like /mcp__github__list_prs.
One terminology note before moving on: custom slash commands have been merged into skills. Files in .claude/commands/ still work, but .claude/skills/<name>/SKILL.md is the recommended approach now. When a skill and a legacy command share the same name, the skill wins.
Session and context management is where most of your command usage will land.
/compact compresses conversation history into a summary, freeing up context window space while preserving the thread. You can pass an instruction: /compact Preserve decisions, final approach, and any TODOs. The right habit is to compact proactively at logical milestones — not when the context is already full, because by then the summaries get messy.
/clear is the hard reset. It wipes conversation history entirely, though file edits from the session stay on disk. The distinction matters: /compact keeps Claude oriented on what happened; /clear starts fresh with no memory of the session at all. Use clear when switching to something completely unrelated.
/context shows where your context window is being spent so you can decide which one to reach for. Pair it with /cost (API users) or /stats (Pro and Max subscribers) for a picture of what the session has consumed.
/rewind rolls code and conversation back to an earlier checkpoint. Esc Esc opens the same menu and lets you choose between rewinding code only, conversation only, or both. Rather than arguing a session back to the right answer, rewind and re-prompt — it’s almost always faster.
/resume (also /continue) picks up an earlier session. Without arguments it opens a session picker; with a name it jumps straight there. From the terminal, claude -c resumes the most recent session and claude -r <id> resumes by ID.
/branch — renamed from /fork in v2.1.77 — forks the current conversation into a new session when you want to try a different approach without losing where you are.
/btw lets you ask a side question while Claude is working without polluting the main conversation context. Use it freely for “wait, how does X work” tangents.
Setup and configuration commands are mostly one-time-per-project, but they compound.
/init scans the repository and generates a starter CLAUDE.md — a markdown file Claude reads at the start of every session in that repo. Run it once, refine the output, and commit it to version control. Your team gets the context automatically.
/memory opens the relevant CLAUDE.md for editing. Two layers worth knowing: the project file at your repo root, and ~/.claude/CLAUDE.md for instructions that apply across every project. The # prefix at the start of any message also persists a quick note to memory without opening the file.
/model switches the active model mid-session. Sonnet for routine work and exploration; Opus for genuinely hard problems. Alt+P does the same thing while preserving whatever you’ve typed. Some teams just pick a model at launch with claude --model opus and leave it — switching mid-session can occasionally create context inconsistencies.
/effort adjusts the reasoning budget per turn: low, medium, high, or max (Opus 4.6 only). Lower effort is faster and cheaper; higher effort thinks longer before answering.
/plan switches into plan mode, where Claude proposes each action and waits for approval before executing. Worth using before any large refactor or anything touching code paths you can’t easily roll back.
/permissions shows what Claude can read, write, and execute, and lets you tune the approval rules. Pre-approve routine operations; keep manual approval for anything that could cause real damage.
/config opens the settings TUI. /doctor diagnoses install and runtime issues — run it first when something seems broken.
Review and quality commands are your checkpoint layer.
/diff opens an interactive diff viewer showing everything that changed during the session. Toggle between a full git diff and per-turn diffs; navigate files with arrow keys. The per-turn view is particularly useful for tracing when a specific change happened. Run it after a series of edits, always before committing.
/review runs a deeper read-only pass — bugs, style issues, performance problems, missing tests. You can scope it: /review Focus on security issues only or /review Check the database query performance.
/security-review is a focused pass for SQL injection, XSS, exposed credentials, insecure configurations. Use it before touching anything user-facing.
/simplify is a bundled skill that cleans up recent files — lighter than /review, more about efficiency than auditing.
/debug helps trace a failing flow when the cause isn’t obvious. Especially useful paired with /diff afterward to see what changed.
Skills, agents, and integrations extend what Claude Code can do beyond the built-in toolkit.
/agents manages subagents — specialized configurations Claude can delegate to. Built-in agents include Explore for read-only codebase work, Plan for planning without execution, and general-purpose. Subagents run with their own context, so delegating verbose work (test runs, log analysis, broad searches) keeps your main session clean.
/mcp manages Model Context Protocol server connections. Connecting a GitHub MCP server gives you /mcp__github__list_prs, /mcp__github__create_pr, and so on. From the terminal, claude mcp add connects servers and claude mcp serve exposes Claude Code itself as an MCP server.
/install-github-app sets up the Claude GitHub App for pull request workflows via GitHub Actions. Separate from the MCP server — the app handles PR-side automation, MCP handles in-session operations.
Custom skills are where the real leverage lives, and most teams are underusing them.
A skill is a SKILL.md file with optional YAML frontmatter and markdown instructions. The filename or name field becomes the slash command; the markdown becomes the prompt Claude sees when you invoke it. Skills live in .claude/skills/<name>/SKILL.md for project-specific use (commit these), ~/.claude/skills/<name>/SKILL.md for personal use across all projects, or managed locations for org-wide distribution.
Here’s a minimal deploy skill:
---
name: deploy
description: Deploy the application to production
disable-model-invocation: true
allowed-tools: Bash(npm run deploy:*) Bash(git status *)
---
Deploy $ARGUMENTS to production:
1. Run the test suite
2. Build the application
3. Push to the deployment target
4. Verify the deployment succeeded
A few things to understand about that frontmatter. The description field is what Claude uses to decide whether to load this skill automatically — front-load the key use case, since it gets truncated at 250 characters. disable-model-invocation: true means only you can trigger it; Claude won’t decide on its own that now is a good time to deploy. allowed-tools grants those bash patterns without per-use approval while the skill is active.
$ARGUMENTS captures whatever follows the command name. /deploy staging substitutes “staging” wherever $ARGUMENTS appears. You can also access positional arguments with $0, $1, $2 — useful for skills like /migrate-component SearchBar React Vue that take multiple distinct inputs.
A couple of more advanced patterns: the !`command` syntax runs a shell command before the skill reaches Claude and substitutes the output inline, which is useful for injecting live data (like a gh pr diff) into a PR summary skill. And context: fork runs the skill in an isolated subagent, keeping your main conversation clean for long-running research.
Treat skills as code. Review them in pull requests, version them, and refine descriptions over time. The value compounds as you tighten them.
A few workflow sequences worth having in your muscle memory:
Starting a new repo — run claude in the project root, then /init, review and refine the generated CLAUDE.md, set up MCP servers, define subagents, tune permissions, and /doctor to verify. Ten minutes of setup that pays back constantly.
Before a large change — switch to /plan, let Claude propose the approach, discuss it, then execute. Use /diff periodically to catch mistakes before they compound.
Mid-session — when you finish one logical chunk of work, /context to see where you stand, then /compact before the next phase. /clear only if you’re switching to something completely unrelated.
Before committing — /diff to inspect everything, /review for quality, /security-review if anything is sensitive. Then commit.
Cost control — check /cost or /stats periodically. If spending climbs, /model sonnet, /effort low, or /compact to shrink context. Delegating verbose work to subagents helps too.
The common mistakes are predictable.
Chaining commands in one prompt — /review then /compact then /continue — looks efficient but produces worse output than running them one at a time. Each command needs room to complete cleanly.
Switching models mid-task. Better to start a session with the model you want, or use /model only at clean boundaries between subtasks.
Waiting until the context window is full before compacting. By then Claude is already degraded, and the summary reflects that. Compact early.
Treating skills as one-shot prompts rather than things you iterate on. The real value is in the refinement: tighter descriptions, narrower allowed-tools, large reference material moved to supporting files so SKILL.md stays focused. Keep it under 500 lines.
/help is always the authoritative source. Commands ship and rename frequently — /fork became /branch recently, there will be more. The official docs at docs.claude.com cover the full command reference, skills, subagents, hooks, and plugins. Once the daily commands feel automatic, skills are the next thing worth putting time into.
More from AI For Developers
This newsletter is part of AI For Developers — a growing directory of AI developer tools, APIs, frameworks, and resources. If you’re evaluating tools for your stack or just want to stay on top of what’s out there, check it out:
🔗 AI For Developers — Browse the directory
📬 AI For Developers newsletter — Subscribe to the newsletter
Every issue covers one topic in depth — no fluff, no hype, just the stuff you need to build with AI. Subscribe if you haven’t already, and I’ll see you in the next one.


