How to Add Custom Slash Commands in Claude Code
Claude Code now supports custom slash commands 🌟
Basically, you can think of custom slash commands as a common prompts that you use with Claude Code regularly.
Here are some of the other interesting things about it:
- Store the prompts in a markdown file.
- Has support for namespacing through directory structures.
- Commands are organized by scope (project-specific or personal)
Command Types
Project commands
Commands (prompts) are stored in your repo so that you can share it with teams.
Location:Â .claude/commands/
Prefix:Â /project:
In the following example, we create the /project:optimize
 command:
# Create a project command
mkdir -p .claude/commands
echo "Analyze this code for performance issues and suggest optimizations:" > .claude/commands/optimize.md
Personal commands
Commands available across all your projects.
Location:Â ~/.claude/commands/
Prefix:Â /user:
# Create a personal command
mkdir -p ~/.claude/commands
echo "Review this code for security vulnerabilities:" > ~/.claude/commands/security-review.md
Features
Namespacing
Just place the commands in a subdirectories. Organize commands in subdirectories to create namespaced commands.
Structure:Â <prefix>:<namespace>:<command>
For example, a file at .claude/commands/frontend/component.md
 creates the command /project:frontend:component
Arguments
Pass dynamic values to commands using the $ARGUMENTS
 placeholder.
Here is an example command 👇
References
Happy open sourcing!