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

How they work

A command is just a Markdown file. Drop it in your commands directory and its filename becomes the command:

  • .claude/commands/changelog.md/changelog (project command, shareable)
  • ~/.claude/commands/changelog.md/changelog (personal, all projects)

The file's body is the prompt Claude runs when you invoke it.

A minimal example

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

Now /changelog… er, /commit (name it whatever the file is) does that every time.

The useful building blocks

  • $ARGUMENTS — inject 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.
  • 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

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

Next