AI Engineer Guide

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:

2025-07-02 at 23.03.17@2x.png

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 👇

Pasted image 20250702231028.png

References

Happy open sourcing!

#TIL #Claude-Code

Want to stay updated?
Sign up for the newsletter.

No spam. Unsubscribe at any time.