Skip to main content

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 /command can 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, opus

String Substitutions

Commands support dynamic values that are replaced before Claude sees them:
Use !`command` for dynamic context injection. The shell command runs before Claude sees the prompt, allowing you to inject real-time data like git status, file lists, or API responses.

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

Best Practice: Use commands for workflows instead of standalone agents. Commands provide better UX with autocomplete and / menu visibility.

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 git
2

Personal

~/.claude/commands/ — Your personal commands across all projects
3

Plugin (lowest priority)

<plugin>/commands/ — Commands from installed plugins

Best Practices

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-everything
Command names appear in autocomplete and should clearly indicate what they do.Good: /fix-github-issue, /weather-orchestratorBad: /cmd1, /thing
Use !`command` to inject real-time data:
Add clear step-by-step instructions in the command body. This helps Claude understand the workflow and makes commands self-documenting for your team.
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.

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

Further Reading