Slash Commands
Powerful shortcuts to extend Claude Code functionality, automate workflows, and streamline your development process with custom commands.
Overview
Slash commands are special commands prefixed with / that provide quick access to Claude Code features and custom functionality. They can execute bash scripts, reference files, and accept arguments.
Built-in Commands
30+ built-in commands for managing agents, memory, plugins, and more
Custom Commands
Create project or personal commands with markdown files
Script Execution
Execute bash commands directly within command definitions
File References
Reference files with @ syntax for contextual commands
Built-in Commands
Claude Code includes 30+ built-in slash commands for managing configuration and features:
| Command | Description |
|---|---|
/agents |
Open agent management interface to create, edit, and manage sub-agents |
/clear |
Clear the current conversation and start fresh |
/compact |
Toggle compact mode for denser output formatting |
/config |
Open configuration editor for settings management |
/cost |
Display API usage and cost information for current session |
/debug |
Toggle debug mode for detailed logging |
/help |
Show help information and available commands |
/hooks |
Manage lifecycle hooks for automation |
/mcp |
Manage Model Context Protocol (MCP) server connections |
/memory |
View and manage conversation memory |
/model |
Switch between Claude models (Opus, Sonnet, Haiku) |
/permissions |
Manage tool permissions and access controls |
/plan |
Toggle plan mode for strategic task planning |
/plugin |
Manage Claude Code plugins |
/quit |
Exit Claude Code |
/reset |
Reset configuration to defaults |
/resume |
Resume a previous conversation |
/save |
Save current conversation |
/skills |
Manage and view available skills |
/status |
Show current session status and settings |
/system |
View or modify system prompt |
/task |
Create and manage tasks |
/tools |
List available tools and their status |
/version |
Display Claude Code version information |
Tip: Use /help to see the complete list of available commands including custom and MCP commands.
Custom Slash Commands
Create custom commands as markdown files in specific directories. Project commands override personal commands with the same name.
File Locations
| Type | Location | Scope | Priority |
|---|---|---|---|
| Project commands | .claude/commands/ |
Current project only | Highest (overrides personal) |
| Personal commands | ~/.claude/commands/ |
All projects | Medium |
| Plugin commands | Plugin's commands/ directory |
Plugin scope | Lowest (namespaced) |
Command Naming
Command filenames determine the slash command name:
review.mdbecomes/reviewrun-tests.mdbecomes/run-testsdeploy-prod.mdbecomes/deploy-prod
Command Structure
Commands are markdown files with optional YAML frontmatter and support special syntax for arguments, bash execution, and file references.
Basic Command Example
---
description: Run the test suite
allowed-tools: Bash
---
Run the project's test suite:
!`npm test`
Report the results and any failures.
Arguments: $ARGUMENTS and Positional
Commands can accept arguments using special variables:
$ARGUMENTS- All arguments as a single string$1,$2,$3, etc. - Individual positional arguments
---
description: Search codebase for a pattern
argument-hint: search-pattern
allowed-tools: Grep, Read
---
Search the codebase for: $ARGUMENTS
Use Grep to find all occurrences and provide context.
Usage: /search "authentication logic"
Bash Execution with !
Execute bash commands inline using the !`command` syntax:
---
description: Show git status and recent commits
allowed-tools: Bash
---
Here's the current repository status:
!`git status`
Recent commits:
!`git log --oneline -10`
Analyze the state and suggest next steps.
File References with @
Reference files using @filename syntax to include their contents in context:
---
description: Review the main application file
allowed-tools: Read
---
Review the following file for code quality and best practices:
@src/app.js
Provide specific recommendations for improvements.
Combined Example
---
description: Analyze test coverage for a specific file
argument-hint: file-path
allowed-tools: Bash, Read, Grep
---
Analyzing test coverage for: $1
Source file:
@$1
Running coverage:
!`npm run test:coverage -- $1`
Find related test files:
!`find . -name "*$1*.test.js" -o -name "*$1*.spec.js"`
Provide a detailed coverage analysis and suggest missing test cases.
Frontmatter Configuration
Configure command behavior using YAML frontmatter at the top of the markdown file:
| Field | Required | Description |
|---|---|---|
description |
No | Brief description shown in command listings |
argument-hint |
No | Hint text for expected arguments (e.g., "file-path") |
allowed-tools |
No | Comma-separated list of tools Claude can use (Read, Write, Edit, Bash, Grep, Glob) |
model |
No | Override model for this command: sonnet, opus, haiku |
disable-model-invocation |
No | If true, executes command without invoking Claude (pure script execution) |
Full Example
---
description: Deploy application to specified environment
argument-hint: environment (staging|production)
allowed-tools: Bash
model: sonnet
---
Deploying to environment: $1
Pre-deployment checks:
!`npm run lint && npm run test`
Build for production:
!`npm run build`
Deploy to $1:
!`npm run deploy:$1`
Verify deployment:
!`curl https://$1.example.com/health`
Report deployment status and any issues.
Plugin Commands
Plugins can provide their own slash commands, which are automatically namespaced to prevent conflicts.
Namespacing Pattern
Plugin commands use the pattern /pluginname__commandname:
- Plugin:
my-plugin - Command file:
my-plugin/commands/analyze.md - Slash command:
/my-plugin__analyze
Example: Docker Plugin
/docker__ps - List running containers
/docker__logs - View container logs
/docker__build - Build Docker image
MCP Slash Commands
Model Context Protocol (MCP) servers can expose prompts as slash commands using a special naming pattern.
Pattern: /mcp__server__prompt
MCP prompts are automatically available as slash commands:
- MCP Server:
github - Prompt name:
create-issue - Slash command:
/mcp__github__create-issue
Example: GitHub MCP Server
/mcp__github__create-issue
Create a new GitHub issue
/mcp__github__search-code
Search code across repositories
/mcp__github__list-prs
List pull requests
Note: MCP slash commands require the corresponding MCP server to be configured and running. Use /mcp to manage MCP server connections.
SlashCommand Tool
Claude can programmatically invoke slash commands using the SlashCommand tool. This enables autonomous command execution based on context.
How It Works
When Claude has access to the SlashCommand tool, it can:
- Automatically invoke appropriate commands based on conversation context
- Chain multiple commands together for complex workflows
- Execute commands with dynamic arguments
Example Scenario
User: "Can you check if our tests are passing?"
Claude: Invokes SlashCommand("run-tests") automatically
Result: Tests are executed and results are analyzed without manual command invocation
Enabling SlashCommand Tool
Configure in .claude/settings.json:
{
"tools": {
"SlashCommand": {
"enabled": true
}
}
}
Skills vs Slash Commands
Understanding the difference between Skills and Slash Commands helps you choose the right tool for your workflow.
| Feature | Slash Commands | Skills |
|---|---|---|
| Invocation | User types /command |
Claude invokes automatically |
| Control | Explicit, user-initiated | Implicit, model-decided |
| Purpose | Quick shortcuts and workflows | Extend Claude's capabilities |
| Arguments | User provides via command line | Claude determines from context |
| Use Case | Repetitive tasks, automation scripts | Contextual assistance, proactive help |
| Examples | /deploy, /run-tests, /review |
Code analysis, refactoring, testing |
When to Use Slash Commands
- You want explicit control over when something runs
- Creating shortcuts for repetitive workflows
- Building deployment or CI/CD automation
- Quick access to specific project tasks
When to Use Skills
- You want Claude to help proactively
- Extending Claude's reasoning capabilities
- Context-aware assistance during development
- Automatic code quality checks
Best Practices
Use descriptive command names
Choose clear, action-oriented names like /deploy-staging instead of /ds
Add helpful descriptions
Always include description frontmatter so users understand what the command does
Limit tool access
Use allowed-tools to grant only necessary permissions for security and clarity
Provide argument hints
Use argument-hint to guide users on expected input format
Test bash commands separately
Verify !`command` syntax works before integrating into commands
Version control project commands
Commit .claude/commands/ to share team workflows
Keep personal preferences personal
Use ~/.claude/commands/ for your own shortcuts across all projects
Document complex commands
Add explanatory comments in the markdown for multi-step or complex workflows
Related
Skills
Model-invoked capabilities for proactive assistance
Sub-Agents
Specialized AI assistants for task-specific workflows
Hooks
Lifecycle automation for Claude Code events
MCP Tools
Extend Claude with external integrations
Plugins
Package and share commands, skills, and agents
CLAUDE.md
Project configuration templates