Tired of typing the same prompts over and over?
If you use Claude Code to write code, you’ve definitely been here: every time you want Claude to generate a Git commit message, you retype “Please generate a commit message that follows our team’s commit conventions based on my code changes.” Every time you want a code review, you type out “Please review this code for security, performance, and readability.”
Retyping these prompts isn’t just a waste of time. Worse, you might phrase them slightly differently each time, making Claude’s responses inconsistent.
Slash commands exist to solve exactly this problem. They let you “package” commonly used prompts into simple commands starting with a slash. Just type /commit or /review, and you instantly trigger the complete workflow. This isn’t just a time-saving trick—it’s an important habit for mastering Vibe Coding rhythm and boosting your AI coding efficiency.
In this post, I’ll walk you through slash commands from scratch: core concepts, three key benefits, and hands-on guidance to build your first custom command. Finally, we’ll learn from SuperClaude, a popular project that empowers Claude Code further, to see how experts design and use custom slash commands.
What Are Claude Code Slash Commands? Core Concept in 60 Seconds#
Slash commands are basically pre-written “shortcuts.”
Imagine your phone has a “go home” shortcut that automatically opens navigation, texts your family, and adjusts the AC with one tap. Claude Code slash commands work the same way: they condense multi-step operations into a simple command.
You don’t even need to design these shortcuts yourself. Anthropic built tons of useful slash commands for you! You can see the full list in the official docs, or better yet, type /help inside Claude Code. This gives you a cheat sheet whenever you’re working, so you don’t need to memorize everything.

How slash commands work is super straightforward: you write a prompt in a Markdown file, and Claude Code turns that filename into a command. When you type /command-name in a conversation, Claude automatically reads that Markdown file’s content and injects the entire prompt into the current conversation. Just like a “copy-paste.”
This is pure string substitution:
[You type /commit]
↓
[Read commit.md file content]
↓
[Inject prompt into conversation]
↓
[Claude executes task]
Why You Should Know Slash Commands: Three Reasons#
⏰ Save Time, Make Work Repeatable#
Every developer has their own rituals—maybe a standard format for Git commit messages, or specific items you always check when debugging. Slash commands let you standardize these processes, ensuring you follow the same best practices every time.
Example: Create a /commit command
Generate a commit message following team conventions based on current code changes.
Format: <type>(<scope>): <subject>
Message in English. Keep it clear, concise, minimal words, and explain "why" this change was made.
Now every time you commit code, just type /commit. Claude follows this standard process to generate your message. No more inconsistent formatting, no more re-explaining your conventions.
🧠 Give Claude Memory: It Never Forgets Project Context#
I want to highlight two memory commands: /init and /memory.
Large language models are inherently stateless. Every conversation is a fresh start, and what you discussed days ago doesn’t count. But development projects aren’t like that. Your code architecture, naming conventions, testing strategies—if Claude forgets these project details every time and you have to re-explain them, that’s a huge waste of time.
To solve this, we can use the built-in /init and /memory commands with CLAUDE.md to activate AI memory.
Run /init, and Claude Code scans your entire project to auto-generate a file called CLAUDE.md. This file is your project’s memory brain, recording:
- Overall project architecture
- Important execution commands (like
npm run build) - Code style conventions
- Core tech stack
Every time you start Claude Code, it automatically loads this CLAUDE.md, so Claude “remembers” your project context from the beginning. You don’t need to repeat “we use React + TypeScript” or “testing framework is Jest”—after /init creates CLAUDE.md, Claude already knows.
Projects evolve daily, and memory needs updates too. You can directly edit the CLAUDE.md file in VSCode, or use /memory inside Claude Code to edit memory content directly in the terminal without leaving your workflow.
Want to dive deeper into how CLAUDE.md unlocks Claude’s memory power? I wrote two detailed posts:
- [Beginner] Claude Code’s Memory Brain: CLAUDE.md Makes AI Remember Your Coding Preferences
- [Advanced] CLAUDE.md Advanced Tips: 10 Settings That Make Claude Code Smarter
🎯 Precise Control: You Decide When to Act#
One of AI’s biggest problems is unpredictability. Sometimes you only want Claude to do A, but it decides to do B on its own.
Slash commands require manual triggering. You have to type /command-name for AI to act. This feature gives you complete control over execution timing. Need a code PR review? Type /review. Need a security check? Type /security-review. Claude won’t guess your intent or act when it shouldn’t.
This precise control is especially important in these scenarios:
- Pre-commit check workflows: You want a fixed sequence of Lint → Unit Test → Review
- Security audits: You need to check the same security items every time
- Document generation: You want completely consistent document format with no surprises(Basic example: don’t let AI randomly switch between Python and Bash in docs!)
How Are Slash Commands Different from Skills?#
What’s the difference between slash commands and skills? This question comes up all the time. Even Anthropic repeatedly explains it across official docs, blog posts, and YouTube videos because it’s genuinely confusing.
Simple answer: Slash commands are manually triggered; Skills are Claude’s autonomous decision.
Skills’ benefit is AI decides when using a skill is most efficient. For example, ask AI to write technical docs, and it automatically activates the article-refine skill to check grammar and wording after writing. But the downside of autonomous decisions is AI might forget to activate skills! Whether action happens becomes unpredictable. For instance, this person had to test various hooks to boost skill activation rates.
So now you can probably understand: why does manual triggering matter for slash commands?
The key feature of slash commands is you must explicitly type them to execute. This differs from Claude Skills, where Claude judges whether to use them. With slash commands, you control the timing. This precise control means in scenarios requiring clear execution timing (like code commits or security reviews), you won’t get thrown off by AI’s “taking initiative.”
(Further reading: Complete Claude Skills Guide and Tutorial)
Custom Slash Commands: Commands’ Versatile Functions#
Claude Code slash commands fall into two categories: built-in commands we covered above, plus custom slash commands.
| Type | Storage Location | Scope | Description |
|---|---|---|---|
| Built-in Commands | Claude Code built-in | All scopes | Official commands for chat management, model selection, project init, etc. |
| Custom - Project Commands | .claude/commands/ | Single project, team-shareable | Stored in project folder, shared with team via Git |
| Custom - Personal Commands | ~/.claude/commands/ | All projects | Stored in your personal home directory, applies to all projects for personal habits |
Built-in commands are tools Claude Code provides by default, like /clear to clear conversation history, /compact to condense current conversation to save token costs, /init to initialize project memory.
Next, custom slash commands can be divided into project commands and personal commands based on scope.
Project commands suit team collaboration. Create custom commands in the .claude/commands/ folder, then add this folder to Git version control. This way the whole team uses the same workflow—ensuring everyone’s code review standards and commit message formats are consistent.
Personal commands are your secret weapons. Maybe your personal debug process or your preferred documentation style. These commands live in ~/.claude/commands/, only you can use them, but they apply to all your projects.
=========================================
📘 Project Level Scope
=========================================
📁 Your Project/ <-- [Usually Git controlled]
│
└── 📁 .claude/
│
├── 🔵 📂 commands/ 👥 <-- [Team-shared commands]
│ │
│ ├── 📄 commit.md
│ └── 📄 review.md
│
└── (other project files...)
=========================================
📙 Personal Level Scope
=========================================
📁 Your Home Directory (~/)/
│
└── 📁 .claude/
│
└── 🟠 📂 commands/ 👤 <-- [Personal commands]
│
├── 📄 fix-issue.md
└── 📄 my-workflow.md
Step-by-Step Tutorial: Build Your First Custom Slash Command#
After understanding custom slash command concepts, let’s build one.
Create a Simple /optimize Command#
Step 1: Create directory
mkdir -p .claude/commands
Step 2: Create Markdown file
echo "Analyze this code's performance issues and provide three specific optimization suggestions:" > .claude/commands/optimize.md
This just creates a new file in the .claude/commands/ folder. You can also use VSCode to create the file directly instead of using terminal commands.
Step 3: Use the command In Claude Code, type:
/optimize
That simple! You’ve built your first custom command.
Advanced Features: Design More Flexible Commands#
Basic slash commands are already useful, but if you want more flexibility, use these three advanced features:
1. Parameter Passing ($ARGUMENTS)#
Make a single command template work across different scenarios.
Example custom command: fix-issue.md
Fix Issue #$ARGUMENTS and ensure it follows best practices.
First analyze the root cause, then propose a solution.
Usage:
/fix-issue 123
AI focuses on Issue #123.
Why it’s useful: You don’t need to create separate commands for each issue, like /fix-issue-123, /fix-issue-321, etc. One template with dynamic parameters handles all cases.
2. Bash Command Execution (!)#
Embed bash commands in prompts using the exclamation mark !bash-command. Let’s use a real example to show bash’s benefit: !git status gives Claude real-time project status.
Example custom command: commit.md
---
allowed-tools: Bash(git*)
---
Generate commit message based on the following Git status:
!git status
!git diff HEAD
Why it’s useful: Claude no longer guesses or infers from conversation history. It bases the message on “this very second’s” code changes, ensuring commit message accuracy.
3. File References (@)#
Directly include specific file content in context using the @file-path symbol.
Example custom command: security-review.md
Review this file's security:
@src/auth/login.js
Follow all rules listed in @docs/security-rules.md
Pay special attention to SQL Injection and XSS risks.
Why it’s useful: No need to manually copy-paste code or worry about missing files. Claude automatically reads and analyzes.
Complete Advanced Example (Combining Three Features)#
Now let’s combine all three features to build a precise “Commit Message Generator”:
---
allowed-tools: Bash(git*)
description: Commit message generator
---
Based on Issue #$ARGUMENTS requirements, analyze the following changes:
!git diff HEAD
And review related files:
@src/components/Button.js
Review must follow all rules in @docs/security-rules.md
Generate commit message following team conventions.
Format: <type>(<scope>): <subject>
Usage:
/smart-commit 456
Claude Code will:
- Read Issue #456 requirements (via
$ARGUMENTS) - Execute
git diff HEADto see actual changes (via!) - Review
Button.jscode (via@to find key js files and reference important docs) - Generate a complete, accurate, convention-following commit message
Issue #456 ($ARGUMENTS)
↓
git diff (!command) ──┐
↓ │
Button.js (@reference) ────┤──→ Integrate complete prompt ──→ Claude generates commit message
Expert Demo: Learn Custom Command Power from SuperClaude#
After seeing basic and advanced features, want to see more examples of how experts use custom slash commands?
SuperClaude is an open-source framework developed to enhance Claude Code functionality, providing 16+ specialized slash commands covering the complete workflow from development to testing to documentation. Let’s look at /sc:improve to see what advanced custom commands can do.
SuperClaude requires separate installation, but you don’t need to rush installing it! This section’s goal is learning how experts write custom slash commands. This link has the complete /sc:improve command content. Below we’ll just look at a snippet:
## Behavioral Flow
1. **Analyze**: Examine codebase for improvement opportunities and quality issues
2. **Plan**: Choose improvement approach and activate relevant personas for expertise
3. **Execute**: Apply systematic improvements with domain-specific best practices
4. **Validate**: Ensure improvements preserve functionality and meet quality standards
5. **Document**: Generate improvement summary and recommendations for future work
Key behaviors:
- Multi-persona coordination (architect, performance, quality, security) based on improvement type
- Framework-specific optimization via Context7 integration for best practices
- Systematic analysis via Sequential MCP for complex multi-component improvements
- Safe refactoring with comprehensive validation and rollback capabilities
From this snippet we can see:
/sc:improveisn’t just “glance at code and give suggestions.” It follows a structured flow:Analyze code → Plan and discuss solution → Execute → Validate → Document. Each step has clear goals and checkpoints, ensuring improvements are “evidence-based” rather than “gut feeling”- Auto-activates specialized personas. For example, when you run
/sc:improve --type security, the framework automatically activates “Security Persona,” making Claude review code from a security expert’s perspective
This snippet is just a fragment, but even learning from this piece, /sc:improve has proven custom slash commands can:
- Standardize complex multi-step workflows: Not just “prompt templates” but complete automation flows
- Auto-adjust behavior based on context: Through flags and parameters (
$ARGUMENT), one command beats ten fixed commands - Integrate professional knowledge: Through auto-activated role systems, let AI work from expert perspectives
SuperClaude currently provides 16+ similar professional commands (like /sc:analyze, /sc:build, /sc:test) covering development, testing, documentation, and more. All built using the same custom slash command mechanism. These commands show how slash commands evolve from “simple shortcuts” to “professional workflow engines,” so SuperClaude is one of my important models for learning slash command usage.
Conclusion#
After reading this post, you should now understand:
- Slash commands are Claude Code’s foundation: From simple shortcuts to complex workflows, all built on this mechanism
- Slash commands give you control over AI behavior: No more relying on AI’s random performance—it executes according to your rules
- Customization and advanced features make commands smarter: Parameter passing, bash execution, file references—combining these three creates powerful automation flows
Start trying today:
- Super simple first step: Type
/helpin Claude Code, review all built-in commands. You’ll definitely find one that fits your needs - Custom commands aren’t hard either: Start by creating a simple
/optimizeor/commitcommand. Don’t chase perfection—get it working first, then gradually improve. You’ll find that with each custom command you add, your Vibe Coding rhythm gets a bit smoother
References:
- Scott Spence: How to Make Claude Code Skills Activate Reliably
- SuperClaude: Transform Claude Code into a Structured Development Platform
- Claude Code Doc: Slash Commands
Hope this post helped you. I’ll keep sharing what I learn about Claude and AI tools.

