Custom Slash Commands
A custom slash command packages a prompt you keep retyping into a single /word. Define it once; reuse it forever (and share it with your team).
- Custom commands have 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 .claude/commands/ files keep working. Skills add a directory for supporting files, invocation-control frontmatter, and automatic loading when relevant. For anything beyond a one-file prompt, prefer a Skill.
- Explain what a custom slash command is and why it beats retyping a prompt
- Create a command by dropping a Markdown file in the right directory
- Tell project commands apart from personal ones by their location
- Use the building blocks: $ARGUMENTS, embedded bash output, file references, and frontmatter
- Choose between a slash command, a skill, and a subagent for a given task
How they work
A command is just a Markdown file. Drop it in your commands directory and its filename becomes the command. The file's body is the prompt Claude runs when you invoke it.
The location of the file decides its scope:
- Save it under .claude/commands/changelog.md → /changelog. It lives in the repo, so the whole team gets it.
- Save it under ~/.claude/commands/changelog.md → /changelog. It follows you across every project on your machine.
- Type the /word in Claude Code. The file's body becomes the prompt Claude runs.
- The filename — not the frontmatter — becomes the command name. changelog.md is always /changelog.
A minimal example
Here is a complete command file. The frontmatter holds the description; everything below it is the prompt.
commit.md — draft a Conventional Commit
--- description: Draft a Conventional Commit message from the staged diff --- Look at the staged changes with `git diff --cached` and write a single Conventional Commit message (feat/fix/docs/refactor/chore). Output only the message, no preamble.
Save that as commit.md and /commit does it every time. (Name it whatever the file is — the same body saved as changelog.md would be /changelog.)
The useful building blocks
Four ingredients turn a static prompt into a flexible command:
| Building block | What it does |
|---|---|
$ARGUMENTS | Injects what the user typed after the command. /review src/auth.ts → the path lands in your prompt. |
| Run bash and embed output | Commands can include shell output (e.g. the current diff) so Claude acts on live state. |
| Reference files | Point at files to include their contents. |
| Frontmatter | description (shown in the menu) and other options. |
See the official docs for the exact syntax of arguments, bash, and file references.
Commands worth stealing
A starter set lives in our Slash Command Library: commit message, PR description, code review, changelog, scaffold-a-component.
Command vs skill vs subagent
Three ways to package work — the difference is who triggers it and how isolated it runs:
- Slash command — you trigger a known workflow on demand.
- Skill — Claude loads expertise automatically when relevant.
- Subagent — delegate a chunk of work to an isolated agent.