Claude CodeBeginner

How to Create a Custom Slash Command in Claude Code

Turn a repeated prompt into a one-word slash command by saving a Markdown file in .claude/commands.

6 minBeginner

If you keep typing the same long instruction, turn it into a slash command. A slash command is just a Markdown file whose body becomes the prompt when you type /name. This guide creates a /changelog command that drafts a release note from recent commits.

  • Claude Code installed and a project open
  • A prompt you find yourself repeating
  • A text editor

Step 1: Create the command file

Project commands live in .claude/commands. The file name without the extension becomes the command name, so changelog.md gives you /changelog. Make the folder and the file.

zsh - my-project
$mkdir -p .claude/commands
$touch .claude/commands/changelog.md
$

Step 2: Write the prompt body

The body is the instruction Claude runs. Optional frontmatter sets a description shown in the menu and can declare allowed tools. Here we let the command run git so it can read the log itself.

.claude/commands/changelog.md
---
description: Draft a release note from recent commits
allowed-tools: Bash(git log:*)
---

Look at the commits since the last tag using git log.
Group them into Added, Changed, and Fixed.
Write a short, human changelog. No marketing language.
.claude/commands/changelog.md
Explorer
commands
changelog.md
settings.json
.claude/commands/changelog.md
1---
2description: Draft a release note from recent commits
3allowed-tools: Bash(git log:*)
4---
5
6Look at the commits since the last tag...
The filename becomes the command name, so this file creates /changelog.

Step 3: Run it

Type the slash command in a session. It appears in the command menu as you type, with the description you set. Selecting it runs the body as your message.

Claude Code
You
/changelog
Agent
Here is the draft: Added: bulk export. Changed: faster search index. Fixed: crash on empty upload. Want me to commit it as CHANGELOG.md?
User commands work everywhere
Put a command in ~/.claude/commands instead of .claude/commands to make it available across every project on your machine. Project commands are best for repo-specific workflows you want to share with the team.

Result: a reusable /changelog command that turns a paragraph of instructions into a single word, saved as committable text your whole team can use.

Watch related tutorials

Tags
#slash-commands#commands#prompt#workflow