Walkthrough
Writing Your Own Slash Command
A markdown file in .claude/commands/ becomes a callable workflow.
Custom slash commands are how you turn a repeated prompt into a one-keystroke action. Write the prompt as markdown, save it under .claude/commands/, type /your-command, done.
The use cases are endless: /review-pr, /write-tests, /draft-changelog, /find-todos. Each one is a small specialized agent run you've made repeatable.
Steps · 0 / 4 done
Create the commands folder
Inside your repo, create the directory if it doesn't exist.
mkdir -p .claude/commandsVerify.claude/commands/ exists at your project root.Author the command
Write a markdown file with the prompt you want fired. Use $ARGUMENTS for inline arguments.
# .claude/commands/review-pr.md Act as a senior reviewer. Look at the diff for the current branch. Flag: missing tests, unsafe SQL, leaky abstractions, dead code. If I named a focus area: $ARGUMENTSVerify.claude/commands/review-pr.md exists with that content.Use it
From any session in that repo, type the command.
/review-pr auth moduleVerifyThe agent runs the prompt with 'auth module' substituted into $ARGUMENTS.Iterate
Run the command. If the output is too long, too short, or wrong — edit the markdown and re-run. Slash commands evolve like any other prompt.
/review-prVerifyAfter edits, the new behavior is live on the next invocation. No reload needed.
Check your understanding
Q1. Where do custom slash commands live?
· Tick off the 4 step(s) above.
· Score 100% on the quiz.