What a custom slash command actually is
If you use Claude Code every day, you have a handful of prompts you type over and over: “review these changes for security issues”, “write a commit message from this diff”, “check this is safe to deploy”. A custom slash command turns one of those prompts into a single word. Type /review, and Claude Code runs the full instruction you saved — no retyping, no forgotten checklist items, no drift between Monday’s review and Friday’s.
Under the hood, a custom slash command is just a Markdown file. There is no plugin system to learn and no config syntax to memorise. You write the prompt you would have typed, save it in the right folder, and the filename becomes the command. That simplicity is the whole point: commands are prompts you can version, review in pull requests, and share with your team like any other file in the repo.
One framing note before we start: Anthropic has merged custom commands into skills. Your existing .claude/commands/ files keep working, and a command file and a skill create the same /name — but the official docs now say to prefer a skill for new work, because skills also support supporting files and can load automatically when relevant. This guide teaches the command-file form first (it is the fastest way to understand the mechanics) and flags where the skill form takes over.
This guide covers the complete setup: your first command in five minutes, project versus personal scope, arguments, frontmatter, live shell data, and the five commands worth building first. It also covers where commands stop and subagents and skills take over, because using the wrong one is the most common way to overcomplicate this.
Your first custom command in five minutes
Create the commands directory in your project root, then write one Markdown file:
mkdir -p .claude/commands
Save this as .claude/commands/review.md:
Review the current changes for:
1. Security issues (injection, auth bypass, exposed secrets)
2. Logic errors and missed edge cases
3. Performance problems (N+1 queries, unnecessary loops)
4. Missing error handling
5. Test coverage gaps
Be concise. No praise. Only actionable feedback, with file and line numbers.
Start Claude Code in the project and type /review. The command appears in autocomplete and runs your saved prompt. The skill equivalent — .claude/skills/review/SKILL.md with the same content — creates the same /review, and is the form to prefer for new work. If a command does not appear, check two things: the file must be inside .claude/commands/ (plural, not command) and it must end in .md.
Where commands live: project versus personal
There are two scopes, and the choice matters more than any other decision on this page:
| Scope | Directory | Who gets it | Invoke as |
|---|---|---|---|
| Project | .claude/commands/ or .claude/skills/<name>/SKILL.md |
Everyone who clones the repo | /review |
| Personal | ~/.claude/skills/<name>/SKILL.md |
Only you, in every project on this machine | /review |
Project commands are team knowledge: the deploy checklist, the review rubric, the migration template. Commit them and review them like code. Personal commands are your own habits: a standup generator, a commit-message style you use everywhere, a security scan you run on unfamiliar repos. Keep personal commands out of repos, and keep repo-specific commands out of your home directory.
When the same name exists at both scopes, personal wins over project — so your own /review shadows the team’s, which is usually what you want. Commands are invoked by their bare name; the current docs do not use project: or user: prefixes. Colon namespaces appear only where a name needs disambiguating: subdirectories, plugins, and added directories.
Subdirectories become namespaces. A file at .claude/commands/frontend/component.md becomes /frontend:component, so a large team can organise dozens of commands without name collisions. The same rule covers skills: a nested skill at apps/web/.claude/skills/deploy/SKILL.md runs as /apps/web:deploy when it clashes with the repo-root skill, and a plugin skill runs as /plugin-name:skill-name.
Arguments: $ARGUMENTS and named arguments
A command without arguments is a fixed script. A command with arguments is a reusable tool. Everything you type after the command name is available inside the file as $ARGUMENTS:
Explain the file $ARGUMENTS in detail.
List its functions, what each one does, and its dependencies.
Run /explain src/auth/session.ts and $ARGUMENTS becomes src/auth/session.ts. The same command now explains any file, which is the difference between a saved prompt and a tool.
Individual arguments are 0-based: $0 is the first argument, $1 the second, and $ARGUMENTS[N] is the long form of $N. Quoting follows shell rules, so /my-skill "hello world" second makes $0 expand to hello world and $1 to second. Two edge behaviours are worth knowing: an indexed placeholder with no matching argument stays in the content unchanged, and if you invoke a command with arguments but no placeholder receives them, Claude Code appends the arguments to the end of the content.
For commands that take several distinct inputs, declare named arguments in the frontmatter and reference them by name:
---
description: Migrate a component between frameworks
arguments: [component, source, target]
---
Migrate the $component component from $source to $target.
Follow the existing component conventions in this repo.
Run /migrate-component SearchBar React Vue and each name fills in. Named arguments are worth the extra line whenever a command takes more than one input, because positional guessing is how a command silently migrates the wrong component. Note the asymmetry if an argument is missing: a named placeholder with no matching argument expands to an empty string, while an indexed placeholder like $2 stays in the content unchanged.
Frontmatter: the six fields that matter
Everything above the prompt, between two --- lines, controls how the command behaves:
| Field | What it does |
|---|---|
description |
The one-line summary shown in the / menu — and what Claude uses to decide whether the command is relevant. Front-load the use case. |
argument-hint |
The placeholder shown during autocomplete, e.g. [environment]. It teaches the syntax at the moment of typing. |
allowed-tools |
Tools pre-approved for the turn that runs the command, e.g. Bash(git:*). The grant clears on your next message, so it is narrow, not standing. |
model |
Overrides which model runs this command, so a cheap review command does not burn your most expensive model. |
disable-model-invocation |
Set to true and only you can trigger the command — Claude will never decide on its own that now is a good time to deploy. |
context: fork |
Runs the command in an isolated subagent, keeping your main conversation clean for long-running work. |
Two of these deserve emphasis. allowed-tools is the difference between a command that flows and one that stalls on permission prompts: a deploy-check command that may run git and npm should say so, and nothing else. And disable-model-invocation: true is mandatory for anything with side effects — commits, deploys, messages, database writes. A command Claude can invoke by itself should never be able to ship something.
Live data with the bang syntax
A plain prompt tells Claude what to do. The bang syntax gives it the facts before it starts. A line beginning with !` runs a shell command when the slash command is invoked, and its output is pasted into the prompt:
## Current state
- Branch: !`git branch --show-current`
- Status: !`git status --short`
- Recent commits: !`git log --oneline -5`
## Your task
Write a commit message from the state above: a summary line under
72 characters in the imperative mood, a blank line, then 1-3 lines
on why. Stage the changed files and commit. Do not push.
This is what makes commands genuinely useful instead of saved text. Claude gets the real diff, the real branch, the real failing test output — not an instruction to go and fetch them. Three rules keep the bang syntax predictable: the ! must sit at the start of a line or immediately after whitespace (after another character it stays literal text); a failed shell command aborts the entire invocation, not just its own placeholder; and for multi-line shell commands, use a fenced block opened with ```! instead of the inline form. Keep these shell commands read-only and fast: a command that runs a slow test suite before Claude sees anything will feel broken even when it works.
Five commands worth building first
Do not build twenty commands on day one. Build five, use them for a week, and let the sixth suggest itself.
1. /review — the code review rubric
---
description: Review current changes against the team rubric
argument-hint: [path]
---
Review the changes in $ARGUMENTS (or the working tree if empty) for:
1. Security issues, 2. Logic errors, 3. Performance problems,
4. Missing error handling, 5. Test coverage gaps.
Output a table with severity (must fix / recommended / suggestion)
and file:line numbers. No praise, only actionable feedback.
2. /deploy-check — the pre-flight checklist
---
description: Pre-deploy checklist, no side effects
disable-model-invocation: true
allowed-tools: Bash(npm test *) Bash(npm run lint *) Bash(npm run build *)
---
Before deployment, verify:
- [ ] `npm test` — all tests pass
- [ ] `npm run lint` — zero lint errors
- [ ] `npm run build` — build succeeds
- [ ] `.env.example` documents every variable the app reads
- [ ] CHANGELOG.md is updated
If anything fails, stop and report. If all pass, output "Deploy ready".
3. /standup — the personal daily update
Put this one in ~/.claude/skills/standup/SKILL.md so it follows you across repos:
---
description: Draft a standup update from recent work
---
Generate my standup update from:
- Recent git commits (last 24 hours)
- Modified files
- Any TODO comments added
Format as Yesterday / Today / Blockers. Keep it under 100 words.
4. /release-notes — notes from real commits
---
description: Draft release notes from commits since the last tag
argument-hint: [version]
arguments: version
allowed-tools: Bash(git log *) Bash(git tag *) Bash(git diff *)
disable-model-invocation: true
---
## Context
- Last tag: !`git describe --tags --abbrev=0`
- Commits: !`git log $(git describe --tags --abbrev=0)..HEAD --oneline`
## Your task
Draft release notes for version $version.
Group under Added, Fixed, Changed. Drop any heading with nothing
under it. One line per change, written for a user, not a developer.
Never invent a change that is not in the commit list above.
5. /explain — the onboarding shortcut
---
description: Explain a file or module for a new team member
argument-hint: [path]
---
Explain $ARGUMENTS in detail: what it does, its public functions
and what each returns, its dependencies, and the one gotcha a new
reader would miss. Assume the reader knows the language, not this repo.
Commands versus subagents versus skills
Claude Code has three ways to package reusable work, and they overlap just enough to confuse:
- Slash commands are prompts you invoke. You type the word, Claude runs the instruction. Use them for repeatable workflows you trigger deliberately: reviews, deploy checks, release notes.
- Subagents are workers Claude delegates to — built-in Explore and Plan agents, or custom agents you define. Use them when the work should run in parallel or in isolation, not when you just want a saved prompt.
- Skills are packaged workflows (a
SKILL.mdplus supporting files) that Claude itself can decide to load when relevant. Use them for knowledge Claude should apply without being asked — a framework’s conventions, a review rubric that should always apply.
The practical rule: if you always type it yourself, make it a command. If Claude should notice when to use it, make it a skill. If the work is long, parallel, or risky, hand it to a subagent. A command with context: fork sits in the middle — a prompt you trigger that runs isolated — and it is the right choice for long research commands that would otherwise flood your main conversation.
One precedence rule matters when both exist: a skill and a command file with the same name resolve in favour of the skill — the command file is ignored. More broadly, personal beats project and enterprise beats personal. So do not create a /review command and a review skill and expect both to be reachable — pick one home for each workflow, and for new work the docs say to pick the skill.
Seven mistakes that make commands useless
- Vague descriptions. The description is what you see in the menu and what Claude uses to judge relevance. “Helps with code” helps nobody; “Review current changes against the team rubric” does.
- Side effects without disable-model-invocation. Any command that commits, deploys, or messages must be manual-only. If Claude can trigger it, one day it will, at the wrong moment.
- Over-broad allowed-tools. Granting
Bash(*)to a review command defeats the point. Scope to the exact tools the command needs. - Slow bang commands. A
!`line that runs a full test suite makes every invocation feel hung. Keep inline shell commands read-only and instant. - Commands that duplicate a skill. Same name in both places means the skill wins and the command file is ignored. Decide which home each workflow lives in — for new work, the skill.
- Secrets in command files. Project commands get committed. Never put tokens, internal URLs, or customer data in them — reference them through the environment instead.
- Twenty commands on day one. Commands earn their keep through use. Five sharp ones beat a menu nobody remembers, and the sixth will suggest itself within a week.
Further Reading & References
- Extend Claude with skills — Claude Code docs — the official page: command files merged into skills, frontmatter reference, argument substitution, and name-resolution rules
- Claude Code Slash Commands: Build Ones You Actually Use — the release-notes command pattern and the frontmatter weight of each field
- Claude Code Custom Slash Commands: 8 Examples to Copy — file locations, namespacing, and the skill-beats-command precedence rule
- Claude Code Slash Command Flags: 4 Working Patterns — the complete frontmatter reference for v2.1.x commands
- Claude Code custom commands: build your own /deploy, /review, and /standup — the original project-versus-personal walkthrough
- Claude Code slash commands: the complete 2026 reference with custom commands — built-in command table and the global-commands pattern
- Custom commands and skills — Tutorial — step-by-step first command plus the project/personal scope table
- Claude Code Subagents: The Complete Guide to Parallel AI Workers (2026) — HowToShipIt guide to the delegation side of this system
- How to Write a CLAUDE.md File That Makes Claude Code 10x Better — the persistent-context companion to commands
Facts verified 25 October 2026 against the official Claude Code documentation (code.claude.com/docs/en/slash-commands) and multiple independent guides; frontmatter fields and syntax reflect Claude Code v2.1.x, including the merge of custom commands into skills.



