If you keep typing the same instructions into Claude Code, such as “review this diff for bugs”, “write a commit message in our style” or “run the tests and fix what fails”, turn them into commands. Claude Code custom slash commands are plain Markdown files: the file name becomes the command, and the contents become the prompt. This guide shows where to put them, how to pass arguments, and when a skill is the better choice.
Where custom commands live
There are two places, depending on who should get the command:
- Project commands in
.claude/commands/inside the repository. Commit them and everyone on the project gets them. - Personal commands in
~/.claude/commands/. They follow you into every project.
A file called review.md becomes /review. Type / in Claude Code to see the list, including your own commands next to the built-in ones.
Your first command
Create the folder and a file:
mkdir -p .claude/commands
$EDITOR .claude/commands/review.md
Put the prompt in the file, written exactly as you’d type it:
Review the uncommitted changes in this repository.
Look for bugs, missing error handling and anything that breaks
existing behaviour. List problems in order of severity, with the file
and line for each. Don't make any edits.
Now /review runs that prompt. The value is consistency: the same checks every time, with no need to remember the wording.
Passing arguments
Use $ARGUMENTS where the text typed after the command should go:
Fix GitHub issue #$ARGUMENTS.
Read the issue with `gh issue view $ARGUMENTS`, find the cause,
make the fix, and add a test that would have caught it.
Saved as fix-issue.md, running /fix-issue 482 fills in the number. For several separate values, use positional arguments, $1, $2 and so on. For example, /port $1 $2 could mean “port this file to that language”.
Frontmatter: description, tools and model
A YAML block at the top of the file controls how the command behaves:
---
description: Write a commit message for the staged changes
argument-hint: [optional ticket id]
allowed-tools: Bash(git diff:*), Bash(git commit:*)
model: haiku
---
Write a conventional commit message for the staged changes and commit.
If a ticket id is given ($ARGUMENTS), put it at the start of the subject.
descriptionis shown in the/menu, so make it say what the command does.argument-hintreminds you what to type after the command.allowed-toolspre-approves specific tools while the command runs, so you aren’t asked for permission at every step. Keep it narrow. Claude Code permission modes and allow rules explains the rule syntax.modelruns the command on a different model. A cheaper, faster model is fine for commit messages.
Pulling in files and command output
Two shortcuts make commands much more useful. An @ path includes a file’s contents, for example Compare @docs/style.md with the README. A line starting with ! followed by a command in backticks runs that shell command first and puts its output into the prompt, so Claude starts with the real git status or test output in front of it. Shell commands need matching Bash entries in allowed-tools.
Organising lots of commands
Subfolders help once you have more than a handful. A file at .claude/commands/frontend/component.md still runs as /component, and the menu shows which folder it came from. If a project command and a personal command share a name, rename one; it’s clearer than working out which one wins.
Commands or skills?
Claude Code has folded custom commands into skills. A file in .claude/commands/ and a skill in .claude/skills/<name>/SKILL.md both give you a /name command, and existing command files keep working. The difference is what else you get:
- Use a command file for a single prompt you trigger yourself.
- Use a skill when the job needs supporting files, such as scripts, templates or reference docs, or when you want Claude to pick it up automatically whenever a task matches. Claude skills as reusable agent playbooks covers how to write one.
Commands worth stealing
/review: review uncommitted changes without editing anything./commit: write and make a commit in your team’s message style./test-fix: run the test suite and fix failures one at a time./explain: explain a file or function for a newcomer, with$ARGUMENTSas the path./handover: summarise what changed this session and what’s left, ready to paste into a ticket.
For bigger repeatable jobs, a command can also hand work to a specialist; see building a custom code reviewer with Claude Code subagents.

Leave a Reply
You must be logged in to post a comment.