Create custom slash commands for Claude Code including syntax, arguments, bash execution, file references, and frontmatter configuration. Use when creating slash commands, custom commands, .md command files, or when asked about command creation, /command syntax, or command best practices.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
examples/code-analysis.mdexamples/code-generation.mdexamples/git-workflows.mdreference/best-practices.mdreference/syntax-guide.mdreference/troubleshooting.mdtemplates/basic-command.mdtemplates/complex-command.mdtemplates/with-arguments.mdtemplates/with-bash.mdtemplates/with-files.mdCreate effective custom slash commands for Claude Code with proper structure, dynamic features, and best practices.
Command File Location:
.claude/commands/name.md~/.claude/commands/name.mdDynamic Features:
$ARGUMENTS (all) or $1, $2, $3 (positional)allowed-tools: Bash(...))@path/to/fileFrontmatter: Optional YAML with description, allowed-tools, argument-hint, model
Use AskUserQuestion to understand what they need:
What should the command do?
Who will use it?
Does it need dynamic inputs?
What tools should it access?
Personal Command (~/.claude/commands/):
Project Command (.claude/commands/):
Basic command structure:
---
description: Brief description for /help
allowed-tools: Optional tool restrictions
argument-hint: Optional argument guidance
---
[Your prompt here]
Decision tree:
# For project commands
touch .claude/commands/your-command.md
# For personal commands
touch ~/.claude/commands/your-command.md
The filename (without .md) becomes the command name.
Use templates from templates/ directory:
---
description: What this command does (appears in /help)
allowed-tools: Read, Grep, Glob # Optional restrictions
argument-hint: [arg1] [arg2] # Optional user guidance
---
Verify command appears:
/help
Look for your command in the list.
Test basic invocation:
/your-command
Test with arguments (if applicable):
/your-command arg1 arg2
Test bash execution (if applicable):
Test file references (if applicable):
Team testing (for project commands):
Start simple, add complexity incrementally:
Don't try to add all features at once. Build incrementally.
---
description: Analyze code for [specific criteria]
allowed-tools: Read, Grep, Glob
argument-hint: [file-or-directory]
---
Analyze @$1 for:
1. [Criterion 1]
2. [Criterion 2]
3. [Criterion 3]
Provide specific findings with examples.
---
description: [Git operation] with context
allowed-tools: Bash(git:*)
---
## Current State
Branch: !\`git branch --show-current\`
Status: !\`git status --short\`
## Task
[What to do with this context]
---
description: Generate [artifact] following patterns
allowed-tools: Read, Grep, Glob, Write
argument-hint: [what-to-generate]
---
## Existing Patterns
@[relevant examples]
## Task
Generate $ARGUMENTS following the patterns above.
---
description: Deep analysis of [topic]
---
Think deeply about $ARGUMENTS considering:
1. [Aspect 1]
2. [Aspect 2]
3. [Aspect 3]
[Extended thinking triggered by keywords]
See examples/ for complete working examples:
Use $ARGUMENTS when:
Use $1, $2, $3 when:
Example:
# $ARGUMENTS approach
Explain $ARGUMENTS in detail.
# Positional approach
Review PR #$1 with priority $2 assigned to $3.
Execute commands BEFORE the prompt runs:
---
allowed-tools: Bash(git:*)
---
Current branch: !\`git branch --show-current\`
Recent commits: !\`git log --oneline -5\`
Requirements:
allowed-tools: Bash(...)Security: Limit bash access with specific tool patterns:
allowed-tools: Bash(git:*) # Git only
allowed-tools: Bash(npm:*), Bash(git:*) # npm and git
Include file contents with @ prefix:
Review @src/auth/login.js for security issues.
Features:
Complete frontmatter options:
---
description: Brief description (required for /help and SlashCommand tool)
allowed-tools: Read, Grep, Glob, Bash(git:*) # Optional restrictions
argument-hint: [file] [priority] # Optional guidance
model: claude-3-5-haiku-20241022 # Optional model override
disable-model-invocation: false # Optional, prevent auto-calling
---
Always include description
/helpUse argument-hint for clarity
Limit allowed-tools when appropriate
Read, Grep, GlobBash(git:*)Structure complex commands
Reference project conventions
@CLAUDE.md for standardsTest incrementally
Organize with subdirectories
Commit project commands
Causes:
Solutions:
.claude/commands/ or ~/.claude/commands/.md extensionCauses:
$ARGUMENT instead of $ARGUMENTS)Solutions:
$ARGUMENTS, $1, $2/command arg1 arg2Causes:
allowed-tools: Bash(...) in frontmatterSolutions:
allowed-tools: Bash(command:*)Causes:
@ prefixSolutions:
@path/to/file syntaxls path/to/fileWhen to use each:
| Use Slash Commands | Use Skills |
|---|---|
| Manual invocation (you decide when) | Automatic discovery (Claude decides when) |
| Simple prompt templates | Complex multi-file workflows |
| Quick, focused operations | Broad capabilities |
| Single .md file | Directory with multiple files |
Example:
/commit - You invoke when ready to commitskill-builder - Claude discovers when you mention SkillsBoth complement each other in your workflow.
For detailed syntax documentation, see reference/syntax-guide.md.
For best practices and patterns, see reference/best-practices.md.
For troubleshooting help, see reference/troubleshooting.md.
After creating a command:
Remember: Slash commands are user-invoked prompt templates. Start simple, test frequently, and add features incrementally. The best commands are clear, focused, and solve real workflow problems.