Problem it solves

Every project has its own conventions. Every team has its own review checklist. And yet, most developers find themselves typing the same prompts over and over: “Write a commit message for these changes”, “Review this function for edge cases”, “Write a test for this component.”

Custom slash commands turn those recurring prompts into one-keystroke shortcuts. You define the prompt once as a Markdown file, and it becomes available as /commit, /review, /test — or whatever name makes sense for your workflow. It’s the closest thing to a macro system for Claude Code, and it costs nothing to set up.

How to use

Create a .claude/commands/ directory in your project root (or ~/.claude/commands/ for global commands available in all projects):

Terminal window
mkdir -p .claude/commands

Then create a .md file for each command. The filename becomes the command name:

.claude/commands/commit.md

Write a conventional commit message for the staged changes.
Use the format: type(scope): description
Types: feat, fix, docs, style, refactor, test, chore
Keep the subject line under 72 characters.
Summarize what changed and why, not how.

.claude/commands/review.md

Review this code for:
- Logic errors and edge cases
- Missing error handling
- Security issues (injection, auth, data exposure)
- Performance problems
- Naming clarity and readability
Be direct. List issues by severity: Critical, High, Medium, Low.

.claude/commands/test.md

Write comprehensive tests for the selected code using Vitest.
Cover: happy path, edge cases, error conditions.
Use descriptive test names that read like specifications.
Mock external dependencies. Do not test implementation details.

Use your commands in any session by typing /commit, /review, or /test in the Claude Code prompt.

Pro tips

Use $ARGUMENTS for dynamic input. You can pass arguments to commands at call time. In your command file, include $ARGUMENTS as a placeholder:

Explain this code to a developer who is unfamiliar with $ARGUMENTS.
Focus on the overall purpose, key design decisions, and anything non-obvious.

Then call it as: /explain TypeScript generics — Claude receives the full prompt with “TypeScript generics” substituted in.

Commit commands with your project. Commands in .claude/commands/ are tracked by git. Check them in. Your team gets the same shortcuts, and new developers onboard with your conventions from day one.

Global vs project commands. Use ~/.claude/commands/ for personal commands that apply everywhere (your preferred commit style, your personal review checklist). Use .claude/commands/ for project-specific commands that reflect that project’s conventions and tech stack.

When NOT to use

Custom slash commands are prompt templates — they’re static Markdown, not code. If you need dynamic logic (conditional prompts, loops, computed values), slash commands aren’t the right tool. For that level of sophistication, look at the Hooks system or the Claude Code SDK. Slash commands shine for static, reusable prompts that you’d otherwise type repeatedly.