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.
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.
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.
---
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.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.
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
16:30
19:27
50:25
1:42:18
28:14
41:09