What Are Slash Commands?
Slash commands are special prompts that start with a forward slash (/) and trigger specific behaviors or workflows in Claude Code. They act as shortcuts for common tasks, ensuring consistency and reducing the need to write detailed instructions each time.
Key Benefits
- Consistency: Standardize how common tasks are performed across your team
- Efficiency: Execute complex workflows with a single command
- Reusability: Share and reuse proven prompts across projects
- Customization: Tailor Claude’s behavior to your specific needs and conventions
- Documentation: Commands serve as living documentation of your development processes
Command Categories
Slash commands are organized into several categories based on their purpose:Version Control & Git
Commands for managing commits, pull requests, branches, and GitHub issues.
Code Analysis & Testing
Commands for code quality checks, testing, and performance optimization.
Context Loading & Priming
Commands for loading project context and priming Claude with relevant information.
Documentation & Changelogs
Commands for generating and maintaining documentation and changelogs.
CI / Deployment
Commands for continuous integration, releases, and deployment workflows.
Project & Task Management
Commands for managing tasks, creating plans, and organizing development work.
How Slash Commands Work
When you invoke a slash command:- Trigger: You type the command name (e.g.,
/commit,/tdd,/docs) - Load: Claude loads the associated prompt or workflow
- Execute: Claude follows the instructions defined in the command
- Output: Claude performs the task according to the command’s specifications
Creating Custom Slash Commands
You can create your own slash commands tailored to your project’s needs:Popular Slash Commands
Some of the most commonly used slash commands include:/commit: Create properly formatted git commits/create-pr: Streamline pull request creation/tdd: Guide Test-Driven Development workflows/docs: Generate comprehensive documentation/optimize: Analyze and improve code performance/context-prime: Load comprehensive project context
Getting Started
- Explore the command categories to find commands relevant to your workflow
- Review example commands from similar projects
- Start with simple commands before creating complex workflows
- Document your custom commands for team sharing
- Iterate and refine commands based on actual usage
Slash commands are stored in the
.claude/commands/ directory of your project. Each command is typically a separate markdown file that defines its behavior.Best Practices
- Keep commands focused: Each command should do one thing well
- Use clear names: Command names should be self-explanatory
- Include examples: Show expected input and output
- Document parameters: Clearly specify any required or optional parameters
- Test thoroughly: Ensure commands work as expected before sharing
- Version control: Keep commands in your repository for team collaboration