LESSON · 1 OF 3

Custom slash commands

Custom slash commands

You already use built-in slash commands like /init and /model. You can add your own. A custom slash command is just a prompt you type often, saved to a file so you can fire it with a few keystrokes instead of retyping it.

Where they live

A custom command is a markdown file. Drop it in one of two places:

LocationScope
.claude/commands/<name>.mdProject - shared with anyone who clones the repo
~/.claude/commands/<name>.mdUser - available in every project you open

The file name becomes the command name. .claude/commands/review.md gives you /review in the console.

The file body is the prompt

There is no special language here. Whatever you write in the body is the prompt Claude receives when you run the command. A review.md might contain:

markdown
Review the staged changes with `git diff --staged` and flag any bugs,
missing error handling, or secrets that would be risky to commit.

Now typing /review sends exactly that prompt.

Passing arguments

Use $ARGUMENTS and whatever you type after the command name gets substituted in. A fix.md containing:

markdown
Find and fix the bug described here: $ARGUMENTS

lets you run /fix the login form rejects valid emails, and that text lands where $ARGUMENTS sits.

Optional frontmatter

A YAML frontmatter block at the top can set a description (shown in the command list) and allowed-tools (which tools the command may use):

markdown
---
description: Review staged git changes
allowed-tools: Bash(git diff:*)
---
Review the staged changes and flag issues.

Frontmatter is optional. A plain body with no frontmatter works fine.

Next, write your own command and confirm the file lands in the right place.


Your lab setup

This VM comes with Claude Code preinstalled and signed in - just run claude to start.

Spin up a fresh environment and practice live.
claude-code-ubuntu · fresh machine · ready in under a minute