Skip to main content
Commands are custom slash commands that provide Claude Code with specialized workflows, automation, and context-aware operations. They’re like custom macros that execute complex tasks with a simple /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

Project setup and configuration commands:
  • 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
Usage:

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
/ci-pipeline setup /ci-pipeline status /ci-pipeline fix
When the command runs, Claude reads these files automatically.

Shell Commands

Execute commands to gather system information:
Results are included in the command’s context.

User Arguments

Capture user input after the command:
Usage: /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:
Shows users exactly how to use the command.

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.md
2

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