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
What the command does. Shown in autocomplete and used by Claude for auto-discovery.
Hint shown during autocomplete (e.g.,
[issue-number], [filename]).Tools allowed without permission prompts when this command is active.Examples:
Read, Edit, Write, Bash(npm run *), WebFetch(domain:*)Model to use when this command runs.Accepted values:
haiku, sonnet, opusString Substitutions
Commands support dynamic values that are replaced before Claude sees them:| Variable | Description | Example |
|---|---|---|
$ARGUMENTS | All arguments passed to the command | /fix-issue urgent → "urgent" |
$ARGUMENTS[N] | Specific argument by index | $0, $1, $2 |
$N | Shorthand for $ARGUMENTS[N] | Same as above |
${CLAUDE_SESSION_ID} | Current session identifier | Unique session ID |
!`command` | Shell command output injected | !`git branch --show-current` |
How to Use Commands
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
| Feature | Commands | Agents | Skills |
|---|---|---|---|
| Purpose | Entry point | Task execution | Reusable knowledge |
| Invocation | /command-name | Task(subagent_type) | /skill-name or Skill(skill) |
| Location | .claude/commands/ | .claude/agents/ | .claude/skills/ |
| Best for | User-initiated workflows | Specialized task execution | Background knowledge or procedures |
Scope and Priority
When multiple commands share the same name, Claude Code uses this priority order:Best 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
