Claude Code Slash Commands: Boost Your Productivity with Custom Automation
Learn how Claude Code slash commands can automate repetitive workflows, reduce token consumption, and streamline your development process with custom commands.
I recently discovered one of Claude Code’s most powerful features: slash commands. These aren’t just shortcuts - they’re a game-changer for automating repetitive workflows and reducing token consumption.
What Are Slash Commands?
Slash commands in Claude Code are custom prompts stored as Markdown files that you can trigger with a simple /command-name
syntax. Think of them as reusable prompt templates that encapsulate specific workflows or instructions.
According to Anthropic’s documentation, slash commands help you:
- Reduce token consumption by extracting fixed workflows from your
CLAUDE.md
files - Standardize processes across team members
- Speed up common tasks with pre-written instructions
- Maintain consistency in how Claude handles specific scenarios
How Slash Commands Work
There are two types of slash commands:
- Personal commands (stored in
~/.claude/commands/
) - Available across all projects - Project commands (stored in
.claude/commands/
) - Shared with your team via git
When you type /
in Claude Code, it shows all available commands. You can reference them in your CLAUDE.md
like this:
### Work Keywords
- **"commit my changes"**: Execute `/commit` command
- **"mid-checkpoint"**: Execute `/nakajime` command
This way, you can use natural language (“commit my changes”) and Claude will automatically execute the appropriate slash command.
Real-World Example: My Custom Commit Command
Here’s my custom slash command that automatically handles git commits with conventional commit messages:
# Commit and Push Changes
Create a conventional commit with all current changes and push to the remote repository.
## Steps
1. Run `git status` to see all changes
2. Run `git diff` to review the changes
3. Analyze the changes and determine the appropriate conventional commit type:
- `feat:` for new features
- `fix:` for bug fixes
- `docs:` for documentation changes
- `style:` for formatting changes
- `refactor:` for code refactoring
- `test:` for test additions/changes
- `chore:` for maintenance tasks
4. Stage all changes with `git add -A`
5. Create a conventional commit with a descriptive message
6. Push to the current branch with `git push`
Remember: This project follows Conventional Commits specification. Do NOT add co-authors to the commit message.
I saved this as ~/.claude/commands/commit.md
, and now I can simply type /commit
or say “commit my changes” to trigger this entire workflow.
The Benefits I’ve Experienced
1. Token Reduction
Instead of loading lengthy workflow instructions in every session, I only load them when needed. One developer reported a 20% reduction in token usage by converting fixed workflows to slash commands.
2. Consistency
Every commit follows the same process, ensuring I never forget to check diffs or use proper conventional commit formats.
3. Speed
What used to take multiple prompts now happens with a single command.
4. Team Sharing
Project-specific commands in .claude/commands/
get shared via git, so the entire team benefits from standardized workflows.
Creating Your Own Slash Commands
-
Create the directory structure:
# For personal commands mkdir -p ~/.claude/commands # For project commands mkdir -p .claude/commands
-
Create a Markdown file:
echo "Your command instructions here" > ~/.claude/commands/my-command.md
-
Use the
$ARGUMENTS
placeholder for flexibility:# Fix GitHub Issue Please analyze and fix GitHub issue: $ARGUMENTS ## Steps 1. Use `gh issue view $ARGUMENTS` to get issue details 2. Implement necessary changes 3. Create tests and verify the fix 4. Commit and create PR
-
Reference in your
CLAUDE.md
:### Custom Commands - **"fix issue"**: Execute `/fix-issue` command with issue number
Popular Slash Command Ideas
Based on the community examples I found:
/session-start
- Initialize development session/deploy-check
- Pre-deployment verification/error-report
- Standardized error reporting/pr-create
- Pull request creation workflow/backup-create
- Backup procedures/security-review
- Security audit checklist
Why This Matters
Slash commands represent a shift from treating AI as a conversational partner to treating it as a programmable automation tool. Instead of explaining the same workflow repeatedly, you encode it once and reuse it efficiently.
The best part? You don’t need to remember command names. Just describe what you want in natural language, and Claude will reference your CLAUDE.md
to execute the appropriate command.
Try creating your first slash command for a workflow you repeat daily - you’ll be amazed at how much time and tokens you save!