How-To Guide

How to Create Custom Commands in Claude Code

Build reusable slash commands for Claude Code. Automate repetitive tasks with custom prompts stored in your project.

How to Create Custom Commands in Claude Code

1

Create the commands directory

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

2

Write a command file

Create a markdown file like `.claude/commands/review.md`. The filename becomes the slash command name — this one would be invoked with `/project:review`.

3

Define the prompt

Write the prompt template in the markdown file. You can use `$ARGUMENTS` to capture user input passed after the command. Example: "Review the file at $ARGUMENTS for security issues."

4

Use your command

In Claude Code, type `/project:review src/auth.ts` and Claude executes the prompt with your arguments substituted in.

Pro tips

  • *

    Prefix project commands with `/project:` and user commands with `/user:`

  • *

    Commands can reference other files using standard markdown — Claude reads them

  • *

    Share useful commands with your team by committing `.claude/commands/` to git

More Claude Code guides

Explore more