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
  1. Create the commands folder

    Inside your repo, create the directory if it doesn't exist.

    mkdir -p .claude/commands
    Verify.claude/commands/ exists at your project root.
  2. 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: $ARGUMENTS
    Verify.claude/commands/review-pr.md exists with that content.
  3. Use it

    From any session in that repo, type the command.

    /review-pr auth module
    VerifyThe agent runs the prompt with 'auth module' substituted into $ARGUMENTS.
  4. 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-pr
    VerifyAfter 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.