/command syntax.
What Are Commands?
Commands are markdown files (.md) stored in .claude/commands/ that define:
- Workflow steps - Automated sequences of operations
- Context gathering - What information to collect before execution
- Tool usage - Which Claude Code tools the command needs
- Output format - How results are presented
Commands appear in Claude Code’s command palette (press
/) and provide autocomplete with hints.Command Structure
Commands use YAML frontmatter followed by markdown instructions:Frontmatter Fields
Special Syntax
Commands support special syntax for dynamic context:$ARGUMENTS- User-provided arguments after command name@path/to/file- Read and include file contents!\command“ - Execute shell command and include output
Command Categories
- Setup & Configuration
- Git Workflow
- Deployment
- Database
- Security
- Documentation
Project setup and configuration commands:Usage:
- setup-testing - Configure testing framework (Jest, Vitest, etc.)
- setup-linting - Set up ESLint, Prettier, and code quality tools
- setup-typescript - Initialize TypeScript with optimal config
- setup-docker - Create Docker and docker-compose files
Real-World Example: CI/CD Pipeline Command
File:.claude/commands/ci-pipeline.md
Multi-Environment Deployment
Configure staging and production deployments with environment-specific secrets.Security & Quality Gates
- Dependency vulnerability scanning
- Secret detection with TruffleHog
- SAST analysis with Super Linter
Shell Commands
Execute commands to gather system information:User Arguments
Capture user input after the command:/command arg1 arg2 makes $ARGUMENTS equal to “arg1 arg2”.
Using Commands
Installation
Invocation
Commands appear in Claude Code’s command palette:Press
/ in Claude Code to see all available commands with autocomplete.Command Best Practices
1. Clear Argument Hints
Provide helpful argument hints:2. Context Before Action
Gather context before executing:3. Clear Sections
Organize commands into logical sections:4. Error Handling
Include fallbacks for missing tools:5. Tool Permissions
Only request necessary tools:Creating Custom Commands
1
Create Command File
Create
.claude/commands/my-command.md2
Add Frontmatter
Define tools, arguments, and description
3
Define Context
Specify what information to gather:
4
Write Instructions
Provide clear steps for execution:
5
Test
Use the command in Claude Code:
Command vs Agent
When to use commands vs agents:Commands are great for repeatable workflows. Agents are better for exploratory tasks and ongoing assistance.
Advanced Features
Conditional Execution
Commands can include conditional logic:Multi-Tool Workflows
Combine tools for complex operations:Integration with Hooks
Commands can be triggered by hooks:Next Steps
Browse Commands
Explore 225+ available commands
Create Custom Commands
Build your own commands
Hooks
Automate command execution
Workflows
Combine commands into workflows