Custom Slash Commands: Your Personal Claude Code Shortcuts
I noticed I was copy-pasting the same prompt every time I wanted Claude to do a security check on my changes. “Look at the diff, focus on SQL injection, check auth flows…” Same thing, every time.
Then I found out you can just save that as a command and type /security-check instead. Should’ve done this months ago.
What They Actually Are
Slash commands are markdown files that expand into prompts. You type /something, Claude reads the corresponding file, and treats its contents as your prompt.
That’s it. No configuration, no special syntax to learn. Drop a markdown file in the right folder and you’ve got a new command.
Where They Live
Two options:
Project-level — .claude/commands/ in your repo. These are specific to that project and can be shared with your team via git.
User-level — ~/.claude/commands/ in your home directory. These follow you across every project.
I keep project-specific stuff (like deployment workflows) in the repo. General utilities (like my security check command) go in my home directory.
The Simplest Possible Command
Create a file at .claude/commands/status.md:
Show me the git status and summarize what I've been working on.
Now /status does exactly that. No frontmatter needed, no special syntax. Just text.
Adding Some Metadata
If you want more control, add frontmatter:
---
description: "Review code changes for security issues"
allowed-tools: Bash(git diff:*), Bash(git log:*)
---
Look at my uncommitted changes and review them for security vulnerabilities.
Focus on SQL injection, XSS, and authentication issues.
The description shows up in /help so you remember what each command does. allowed-tools restricts which bash commands Claude can run—useful for keeping a command focused.
Passing Arguments
This is where it gets interesting. You can pass arguments to commands:
---
description: "Explain a file in plain English"
argument-hint: [file-path]
---
Read $ARGUMENTS and explain what it does. Assume I'm unfamiliar with this part of the codebase.
Now /explain src/auth/tokens.py reads that file and explains it.
You can also use positional arguments if you need multiple inputs:
---
description: "Compare two branches"
argument-hint: [branch1] [branch2]
---
Compare $1 and $2. Show me what's different and summarize the changes.
/compare main feature/oauth does what you’d expect.
Running Commands Before Claude Thinks
Here’s the trick that made these actually useful for me. Prefix a line with ! and it runs before Claude sees the prompt:
---
description: "Summarize recent work"
allowed-tools: Bash(git log:*)
---
Here's what I've committed recently:
!git log --oneline -10
Summarize what I've been working on based on these commits.
The git log runs first, its output gets injected into the prompt, and Claude responds with context it wouldn’t have otherwise. No more “can you run git log first?”
Commands I Actually Use
/security-check — Runs git diff HEAD, looks at all changes, focuses on SQL injection, XSS, and auth issues. Catches stuff I’d miss.
/commit — Looks at staged changes and writes a commit message. I’ve tweaked the prompt to match our team’s conventional commit format.
/explain — Takes a file path, reads it, explains it in plain English. Useful when diving into unfamiliar code.
/init — Sets up a new project with a CLAUDE.md file. Scans the directory structure, identifies the stack, writes initial documentation.
The Frontmatter Options
Quick reference:
description— Shows in/help. Required if you want Claude to invoke it programmatically.argument-hint— Describes expected arguments. Shows in autocomplete.allowed-tools— Whitelist of bash commands. Format:Bash(git status:*).model— Force a specific model. I usehaikufor simple, fast commands.disable-model-invocation— Set totrueif you don’t want Claude invoking this command on its own.
Things That Tripped Me Up
Forgot the description. My commands weren’t showing up in /help. Turns out you need the description field in frontmatter for that.
Too many allowed-tools. I gave one command access to everything and it started doing things I didn’t expect. Be specific about which commands you’re allowing.
Arguments with spaces. If your argument has spaces, quote it: /explain "src/utils/auth helper.py". Took me a few tries to figure out why paths weren’t working.
Getting Started
Pick one thing you type repeatedly. Make a command for it. Put it in ~/.claude/commands/ so it works everywhere.
Mine was the security check prompt. Saved me maybe 30 seconds each time, but I run it before every commit. Adds up.
Once you have one, you’ll think of ten more.