Skip to main content

Custom Slash Commands

Intermediate

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).

What you'll learn
  • 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.
What you'll learn
  • 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:

Guided walkthrough1 of 3
  1. Save it under .claude/commands/changelog.md → /changelog. It lives in the repo, so the whole team gets it.
Pro tip
  • 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 blockWhat it does
$ARGUMENTSInjects what the user typed after the command. /review src/auth.ts → the path lands in your prompt.
Run bash and embed outputCommands can include shell output (e.g. the current diff) so Claude acts on live state.
Reference filesPoint at files to include their contents.
Frontmatterdescription (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 commandyou trigger a known workflow on demand.
  • Skill — Claude loads expertise automatically when relevant.
  • Subagent — delegate a chunk of work to an isolated agent.
Press Enter or Space to flip the card. Use the left and right arrow keys to move between cards.Term shown.
1 / 6

Check yourself

0/4
  1. Where do you save a slash command so your whole team gets it in the repo?
  2. What determines the name of a slash command?
  3. What does $ARGUMENTS do in a command?
  4. Which packaging option does Claude load automatically when it's relevant, rather than you triggering it?

Next