What Are Commands?
Commands are entry-point prompts that define reusable workflows in Claude Code. They’re invoked by typing/command-name in the interactive CLI and serve as the starting point for orchestrating complex tasks.
Commands live in
.claude/commands/<name>.md and use YAML frontmatter for configuration.Why Commands Matter
Commands bridge the gap between user intent and AI execution:- Single entry point: One
/commandcan orchestrate multiple agents and skills - Reusable workflows: Define once, invoke anytime with consistent behavior
- Team collaboration: Share workflows in version control for team-wide use
- Dynamic context: Inject shell command output and arguments at runtime
Frontmatter Fields
string
required
What the command does. Shown in autocomplete and used by Claude for auto-discovery.
string
Hint shown during autocomplete (e.g.,
[issue-number], [filename]).string
Tools allowed without permission prompts when this command is active.Examples:
Read, Edit, Write, Bash(npm run *), WebFetch(domain:*)string
Model to use when this command runs.Accepted values:
haiku, sonnet, opusString Substitutions
Commands support dynamic values that are replaced before Claude sees them:How to Use Commands
1
Create a command file
Create a markdown file in
.claude/commands/ with YAML frontmatter:2
Define the workflow
Add frontmatter and instructions:
3
Invoke the command
Type
/my-workflow in Claude Code:Real Example: Weather Orchestrator
From the reference repository at.claude/commands/weather-orchestrator.md:
Key Pattern: Command orchestrates → Agent fetches data → Skill creates output
Commands vs Agents vs Skills
Scope and Priority
When multiple commands share the same name, Claude Code uses this priority order:1
Project (highest priority)
.claude/commands/ — Project-specific commands, committed to git2
Personal
~/.claude/commands/ — Your personal commands across all projects3
Plugin (lowest priority)
<plugin>/commands/ — Commands from installed pluginsBest Practices
Keep commands focused
Keep commands focused
Each command should have a single, clear purpose. Break complex workflows into multiple commands or use agents for sub-tasks.Good:
/deploy-staging, /run-tests, /generate-docsBad: /do-everythingUse descriptive names
Use descriptive names
Command names appear in autocomplete and should clearly indicate what they do.Good:
/fix-github-issue, /weather-orchestratorBad: /cmd1, /thingLeverage dynamic context
Leverage dynamic context
Use
!`command` to inject real-time data:Document the workflow
Document the workflow
Add clear step-by-step instructions in the command body. This helps Claude understand the workflow and makes commands self-documenting for your team.
Set appropriate models
Set appropriate models
Use
haiku for simple commands, sonnet for most workflows, and opus for complex reasoning.Subdirectories
Organize commands in subdirectories for better structure:Commands in subdirectories use the format
/subdir:command-name in the slash menu.Cross-Links
Subagents
Learn how to invoke agents from commands using the Task tool
Skills
Use skills in commands for reusable procedures
Orchestration Workflow
See the Command → Agent → Skill pattern in action
Commands Best Practice
Complete reference with all built-in slash commands
