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.
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.
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.
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.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.
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.
Result: your repeatable workflows are one slash away, consistent every time, and shareable with anyone who clones the repo.
Watch related tutorials
19:27
50:25
1:42:18
28:14
41:09
9:47