Cookbook/Create Custom Slash Commands
advanced
10 min

Create Custom Slash Commands

customization
commands
productivity

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

  1. Create command directory - mkdir -p .claude/commands
  2. Write command files - Create .md files with your command logic
  3. Use parameters - Include {{parameter}} for dynamic values
  4. Test commands - Use /command-name in Claude Code
  5. Share with team - Commit .claude/ directory to version control

Master Claude Code with Expert Training

These recipes are from our comprehensive 2-day training course. Learn directly from experts and transform your development workflow.