Last updated: June 2026
Claude Code Slash CommandsBuilt-In and Custom Commands
Claude Code slash commands are shortcuts you type at the start of a message, beginning with a forward slash, to control the tool or trigger a saved workflow. There are built-in commands like /clear, /compact, and /init coded into the CLI, and custom commands you create yourself as reusable prompt templates. You make a custom command by saving a markdown file in a .claude/commands/ folder (or a SKILL.md in .claude/skills/): the file becomes the command, and its contents become the prompt Claude runs.
The fastest win in Claude Code is turning a prompt you keep retyping into a one-word command. This guide shows the built-in commands worth knowing and gives you copy-paste templates for your own.
What Are Slash Commands in Claude Code?
A slash command is a shortcut you type at the start of a message in Claude Code. Type / on its own to see every command available in your session, or type / followed by letters to filter. A command is only recognized at the start of your message; anything you type after the command name is handed to it as an argument.
There are two kinds. Built-in commands like /clear and /compact have their behavior coded into the CLI. Custom commands are reusable prompt templates you write yourself, so a prompt you keep retyping becomes a single word.
One change matters in 2026: custom commands have been merged into skills. A file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and work the same way. Your existing command files keep working, so there is nothing to migrate. The skill form just adds extras: a folder for supporting files, richer frontmatter, and the option for Claude to run the command automatically when your request matches it.
The Built-In Slash Commands Worth Knowing
Claude Code ships with dozens of built-in commands. You do not need to memorize them all. These are the ones that earn their place in a daily workflow. Type /help to see the full list in your session.
/clearStart a new conversation with empty context (project memory is kept). Use it when you switch to an unrelated task.
/compactSummarize the conversation so far to free up context when the window is filling up. Optionally pass focus instructions.
/initGenerate a starter CLAUDE.md for the current repo so Claude has persistent project context.
/planEnter plan mode before a large change. Pass a description to start immediately, e.g. /plan fix the auth bug.
/modelSwitch the active model and save it as your default. With no argument, opens a picker.
/contextVisualize where your context window is being spent, with optimization suggestions.
/agentsOpen the manager for subagents Claude can delegate side tasks to.
/mcpManage Model Context Protocol server connections and OAuth.
/permissionsManage allow, ask, and deny rules for tool permissions.
/reviewReview a pull request locally in your current session.
/security-reviewAnalyze pending changes on the branch for security vulnerabilities like injection or data exposure.
/skillsList the skills available in this session and hide ones you do not want Claude to use.
/resumeResume an earlier conversation by ID or name, or open the session picker.
/doctorDiagnose and verify your Claude Code installation and settings.
/helpShow help and every command available to you.
The two you will reach for most: /clear when you move to an unrelated task so old context stops confusing Claude, and /compact when a long session is eating your context window but you still need the thread.
How to Create a Custom Slash Command
A custom command is just a markdown file. The file name becomes the command, and the file body becomes the prompt Claude runs. Here is the whole process in three steps.
Create the commands folder
Use .claude/commands/ inside your project for team-shared commands, or ~/.claude/commands/ in your home directory for personal commands that follow you everywhere.
mkdir -p .claude/commandsWrite a markdown file named after the command
A file at .claude/commands/review.md becomes the command /review. Put the prompt you want Claude to run inside the file. That is the minimum: a file with a name and a prompt is a working command.
Invoke it by typing the slash
Type /review and Claude runs the file as a prompt. New files are picked up at the start of a session, or you can run /reload-skills to pick up a command you just added without restarting.
The before/after that makes this worth it: the weak version is opening every session and pasting "review my uncommitted changes, flag bugs first, then missing tests, then style, and quote the file and line for each issue." The strong version is typing /review. Same prompt, zero retyping, identical every time, shared with your whole team through git.
Copy-Paste Custom Command Templates
Four commands that pull their weight. Copy one, drop it in your .claude/commands/ or .claude/skills/ folder, and adapt the prompt to your project.
--- description: Review the current diff for bugs, missing tests, and style issues argument-hint: [optional focus area] allowed-tools: Bash(git diff *) Read Grep --- ## Current changes !`git diff HEAD` ## Your task Review the changes above. Focus on $ARGUMENTS if provided. Flag correctness bugs first, then missing tests, then style. Quote the file and line for each issue. Do not edit anything.
--- description: Stage and commit the current changes with a clear message disable-model-invocation: true allowed-tools: Bash(git add *) Bash(git commit *) Bash(git status *) --- ## Current status !`git status --short` ## Your task Stage the relevant changes and write a commit message that describes what changed and why. Use the format: <type>: <description>. Do not push.
--- description: Fix a GitHub issue by number, following our coding standards argument-hint: [issue-number] --- Fix GitHub issue $ARGUMENTS following our coding standards. 1. Read the issue with: gh issue view $ARGUMENTS 2. Find the relevant files and understand the requirements 3. Implement the fix 4. Add or update tests 5. Stop before committing so I can review
--- description: Scaffold a new Next.js page from our template argument-hint: [slug] [title] --- Create a new page at pages/$1.js titled "$2". Match the structure and Tailwind classes of pages/claude-code-guide.js: Head with title and meta description, a Layout wrapper, a hero section, and an FAQ block. Use the brand colors #1A1A1A, #FFDE59, and #F9F9F9.
Common failure mode: putting a destructive workflow like deploy or commit in a normal command and letting Claude run it on its own. Add disable-model-invocation: true to the frontmatter (as in the commit template above) so only you can trigger it by typing the command. You never want Claude deciding to deploy because the code "looks ready."
How Arguments Work
Arguments turn a static command into a flexible one. Anything you type after the command name is passed in, and you control where it lands using placeholders.
$ARGUMENTSThe full string of everything you typed after the command. Running /fix-issue 123 on a file containing "Fix issue $ARGUMENTS" sends "Fix issue 123."
$1, $2 (or $ARGUMENTS[0], $ARGUMENTS[1])Individual positional arguments. Running /migrate SearchBar React Vue maps to $1 = SearchBar, $2 = React, $3 = Vue. Wrap multi-word values in quotes to keep them as one argument.
Named argumentsDeclare an arguments list in the frontmatter, then reference them by name like $issue and $branch instead of by position.
If you invoke a command with arguments but the file has no placeholder, Claude Code appends ARGUMENTS: your input to the end so your text is still seen.
Frontmatter Fields That Control a Command
The YAML block at the top of a command file (between --- markers) configures how the command behaves. All fields are optional, but description is the one to always include so Claude knows what the command is for.
descriptionWhat the command does and when to use it. Claude reads this to decide when to load a skill automatically. Recommended on every command.
argument-hintA hint shown in autocomplete for the arguments the command expects, e.g. [issue-number] or [filename] [format].
allowed-toolsTools Claude may use without asking for permission while this command is active, e.g. Bash(git diff *) Read Grep.
disable-model-invocationSet to true so only you can trigger the command by typing /name. Use it for workflows with side effects like deploy or commit.
argumentsDeclare named positional arguments so you can use $name placeholders instead of $1 and $2 in the command body.
modelForce a specific model while the command runs, then return to your session model on the next prompt.
When to Use a Slash Command (and When Not To)
Make it a command when
- You keep pasting the same prompt or checklist.
- A workflow has fixed, ordered steps (review, commit, scaffold a file).
- You want your team to do the same thing the same way every time.
- The prompt should pull in live data, like the current git diff.
Skip the command when
- It is a one-off request you will not repeat.
- The task is exploratory and changes shape every time.
- A built-in command already does it (do not rebuild
/compact). - It is standing project context โ that belongs in CLAUDE.md, not a command.
Rule of thumb: if you have typed roughly the same instruction three times, turn it into a command. The whole point of a custom slash command is repeatability, so the payoff scales with how often you run it.
Write Commands That Actually Work
A slash command is only as good as the prompt inside it. Vague instructions produce vague results no matter how you trigger them. PromptWritingStudio teaches the prompt-writing fundamentals โ specificity, context, and structure โ that make every command, skill, and AI workflow you build pull its weight.
Grade Your Prompt FreeFrequently Asked Questions
Common questions about Claude Code slash commands
What are slash commands in Claude Code?+
Slash commands are shortcuts you type at the start of a message, beginning with a forward slash, to control Claude Code or trigger a saved workflow. Type / in the prompt to see every command available to you. There are two kinds: built-in commands like /clear, /compact, and /init that are coded into the CLI, and custom commands you create yourself as reusable prompt templates. A command is only recognized at the start of your message; any text after the command name is passed to it as an argument.
How do I create a custom slash command in Claude Code?+
Create a markdown file in a .claude/commands/ folder (for example .claude/commands/review.md) and the file becomes the command /review. The file's contents are the prompt Claude runs when you invoke it. As of the 2026 docs, custom commands have been merged into skills, so the recommended modern path is .claude/skills/review/SKILL.md instead, which produces the same /review command but adds support for a directory of supporting files and richer frontmatter. Both forms still work and you do not have to migrate existing command files.
Where do project commands versus personal commands live?+
Project commands live in .claude/commands/ or .claude/skills/ inside the repository, so they are committed to version control and shared with everyone on the team. Personal commands live in ~/.claude/commands/ or ~/.claude/skills/ in your home directory, so they follow you across every project on your machine. When a skill and a command share the same name, the skill takes precedence. When the same name exists at multiple scopes, personal overrides project.
How do I pass arguments to a custom slash command?+
Put the placeholder $ARGUMENTS in your command file and it gets replaced with whatever you type after the command name. For example, if /fix-issue contains 'Fix GitHub issue $ARGUMENTS', then running /fix-issue 123 sends 'Fix GitHub issue 123' to Claude. For individual positional arguments use $1, $2 (or $ARGUMENTS[0], $ARGUMENTS[1]), and wrap multi-word values in quotes. You can also declare named arguments in the frontmatter using the arguments field.
What is the difference between a slash command and a skill?+
They overlap. A custom slash command is a markdown file you invoke by typing /name. A skill is a SKILL.md file in its own directory that you can also invoke with /name, but Claude can additionally load it automatically when your request matches its description. In the current Claude Code, custom commands have been folded into skills: a file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and behave the same way when you type the command. Skills add optional features like supporting files, invocation control, and subagent execution.
Can Claude run a slash command automatically without me typing it?+
Yes, for skills with a clear description. When a skill's description matches what you are asking for, Claude can load and run it on its own. If you want a command to be manual-only, for example a deploy or commit workflow where timing matters, add disable-model-invocation: true to the frontmatter so only you can trigger it by typing /name.
How do I run a shell command inside a custom slash command?+
Use the inline syntax with an exclamation mark and backticks, such as !`git diff HEAD`, on its own line in the command file. Claude Code runs that shell command before the prompt is sent and replaces the placeholder with the command's output, so the prompt arrives with live data already inlined. This is preprocessing, not something Claude decides to do. It is how you ground a command in your actual working tree, like injecting the current diff into a commit-message command.
What built-in slash commands should I learn first?+
Start with /clear to begin a fresh task while keeping project memory, /compact to shrink a long conversation that is filling the context window, /init to generate a starter CLAUDE.md, /plan to enter plan mode before a large change, /model to switch models, and /review or /security-review for a read-only pass before you ship. /context shows where your context window is going, and /agents and /mcp set up subagents and MCP servers. Type /help to see the full list available in your session.
More Claude Code Resources
Slash commands are one piece. Here is the rest of the toolkit for working with Claude Code day to day.
Claude Code Guide
The full hub โ install, features, workflows, pricing, and daily-use tips.
Claude Code Sub-Agents
The isolated agents your custom commands can hand work off to.
Skills vs MCP vs Hooks
When a command should be a skill, an MCP server, or a hook instead.
Claude Code Hooks Recipes
Working hooks for the rules you never want Claude to "decide" about.
CLAUDE.md Playbook
Where standing project context belongs, instead of in a command.
Minimum Viable MCP Stack
Five MCP servers worth wiring into Claude Code, with copy-paste config.
Claude Plan Picker
Find the cheapest Claude plan that fits how much you actually use.