Command Types
Claude Code supports three types of commands:Built-in Commands
Core commands that ship with Claude Code
Slash Commands
User-defined commands in
.claude/commands/Plugin Commands
Commands provided by installed plugins
Command Execution
Interactive Mode
In interactive mode, commands are executed in the terminal session:Headless Mode
You can execute commands directly from the command line:Command Structure
Commands are defined using markdown files with YAML frontmatter:The frontmatter controls command permissions and behavior, while the body provides instructions to Claude.
Command Arguments
Commands can accept arguments that are passed to Claude:Full Arguments
Access all arguments using$ARGUMENTS:
Indexed Arguments
Access specific arguments using bracket notation:Inline Command Execution
Commands can execute shell commands inline and include their output:Permission Model
Commands can specify which tools Claude is allowed to use:List of tools the command can use. Examples:
Bash(git:*)- Only git commandsBash(./scripts/gh.sh:*)- Only specific scriptRead, Write, Edit- File operationsBash- All bash commands (requires user approval)
Tool Permission Syntax
Session ID Variable
Commands can access the current session ID:Best Practices
Keep commands focused
Keep commands focused
Each command should do one thing well. If a command becomes too complex, consider breaking it into multiple commands or using an agent instead.
Use descriptive names
Use descriptive names
Command names should clearly indicate what they do. Use kebab-case for multi-word commands:
/commit-push-pr instead of /cpp.Minimize tool permissions
Minimize tool permissions
Only grant the minimum permissions needed. Use specific command patterns like
Bash(git:*) instead of Bash.Document inline commands
Document inline commands
When using inline execution (!`…`), add comments explaining what information is being gathered.
Test with different inputs
Test with different inputs
Test your commands with various argument combinations to ensure they handle edge cases properly.
Next Steps
Built-in Commands
Explore all built-in commands available in Claude Code
Create Slash Commands
Learn how to create your own custom commands