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.
Step-by-step
How to Create Custom Commands in Claude Code
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).
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`.
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."
Use your command
In Claude Code, type `/project:review src/auth.ts` and Claude executes the prompt with your arguments substituted in.
Tips
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
Related guides