Claude CodeIntermediate

How to Add a Custom Slash Command in Claude Code

Save a reusable prompt as a Markdown file so a single slash command runs your repeatable workflow on demand.

7 minIntermediate

If you find yourself typing the same long instruction again and again, turn it into a custom slash command. Claude Code reads command definitions from Markdown files, so /review or /changelog can run a saved prompt in one keystroke. This guide creates one and parameterizes it.

What you need

  • Claude Code installed in a project
  • A prompt or workflow you repeat often
  • About 8 minutes

Step 1: Create the commands folder

Project commands live in .claude/commands. Each Markdown file becomes a command named after the file. Create the folder.

zsh - commands dir
$mkdir -p .claude/commands
$

Step 2: Write the command file

Put your prompt in a file. The body is sent to the agent when you invoke the command. Save this as review.md to create /review.

.claude/commands/review.md
Review the staged changes for bugs, missing tests, and style issues.
Group findings by severity. Suggest a concrete fix for each.
Do not change any files; only report.
Editor - commands folder
Explorer
review.md
changelog.md
test-gen.md
.claude/commands/review.md
1Review the staged changes for bugs, missing tests,
2and style issues. Group findings by severity.
3Suggest a concrete fix for each. Do not edit files.
Each Markdown file becomes a slash command.

Step 3: Accept arguments

Use the $ARGUMENTS placeholder to pass input. Anything typed after the command name is substituted in. This file makes /changelog accept a version tag.

.claude/commands/changelog.md
Write a CHANGELOG entry for version $ARGUMENTS.
Summarize merged changes since the last tag under
Added, Changed, and Fixed headings. Keep it terse.

Step 4: Run it

Inside a session, type the slash and the command name. Pass arguments after it where defined.

Claude Code - custom command
You
/changelog 1.4.0
Agent
## 1.4.0 ### Added - CSV export ### Fixed - Rounding error on totals
Invoking the saved command with an argument.
Share team commands, keep personal ones global
Commit .claude/commands so teammates get them too. For commands only you use, put the files in ~/.claude/commands instead and they follow you across projects.

Result: your repeatable workflows are one slash away, consistent every time, and shareable with anyone who clones the repo.

Watch related tutorials

Tags
#slash-commands#automation#prompts#workflow#config