Create Custom Slash Commands
You can create a .claude/commands folder in your project to hold commands you use over and over. You can also design these commands to accept arguments.
Code Example
Create a .claude/commands/
directory in your project root, then add custom command files:
# Project structure
my-project/
├── .claude/
│ └── commands/
│ ├── review.md
│ ├── test.md
│ └── deploy.md
Example: Code Review Command (.claude/commands/review.md
)
# Code Review
Please review this code for:
- Security vulnerabilities
- Performance issues
- Code style and best practices
- Potential bugs
Focus on {{file}} if specified, otherwise review recent changes.
Provide specific suggestions with line numbers where applicable.
Example: Test Command (.claude/commands/test.md
)
# Run Tests
1. Run the test suite for {{component}} (or all tests if not specified)
2. If tests fail, analyze the failures and suggest fixes
3. Ensure test coverage is adequate
4. Check for missing edge cases
Use the appropriate test framework for this project.
Usage
/review components/auth.js
/test user-authentication
/deploy staging
Quick Steps
- Create command directory -
mkdir -p .claude/commands
- Write command files - Create
.md
files with your command logic - Use parameters - Include
{{parameter}}
for dynamic values - Test commands - Use
/command-name
in Claude Code - Share with team - Commit
.claude/
directory to version control