npx skills add ...
npx skills add anthropics/claude-plugins-public --skill command-development
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This repo is now called anthropics/claude-plugins-official. Both names install the same content, but the install count here only covers this one.
npx skills add anthropics/claude-plugins-public --skill command-development
Note: The
.claude/commands/directory is a legacy format. For new skills, use the.claude/skills/<name>/SKILL.mddirectory format. Both are loaded identically — the only difference is file layout. See theskill-developmentskill for the preferred format.
Slash commands are frequently-used prompts defined as Markdown files that Claude executes during interactive sessions. Understanding command structure, frontmatter options, and dynamic features enables creating powerful, reusable workflows.
Key concepts:
A slash command is a Markdown file containing a prompt that Claude executes when invoked. Commands provide:
Commands are written for agent consumption, not human consumption.
When a user invokes /command-name, the command content becomes Claude's instructions. Write commands as directives TO Claude about what to do, not as messages TO the user.
Correct approach (instructions for Claude):
Incorrect approach (messages to user):
The first example tells Claude what to do. The second tells the user what will happen but doesn't instruct Claude. Always use the first approach.
Project commands (shared with team):
.claude/commands//helpPersonal commands (available everywhere):
~/.claude/commands//helpPlugin commands (bundled with plugins):
plugin-name/commands//helpCommands are Markdown files with .md extension:
Simple command:
No frontmatter needed for basic commands.
Add configuration using YAML frontmatter:
Purpose: Brief description shown in /help
Type: String
Default: First line of command prompt
Best practice: Clear, actionable description (under 60 characters)
Purpose: Specify which tools command can use Type: String or Array Default: Inherits from conversation
Patterns:
Read, Write, Edit - Specific toolsBash(git:*) - Bash with git commands only* - All tools (rarely needed)Use when: Command requires specific tool access
Purpose: Specify model for command execution Type: String (sonnet, opus, haiku) Default: Inherits from conversation
Use cases:
haiku - Fast, simple commandssonnet - Standard workflowsopus - Complex analysisPurpose: Document expected arguments for autocomplete Type: String Default: None
Benefits:
Purpose: Prevent SlashCommand tool from programmatically calling command Type: Boolean Default: false
Use when: Command should only be manually invoked
Capture all arguments as single string:
Usage:
Expands to:
Capture individual arguments with $1, $2, $3, etc.:
Usage:
Expands to:
Mix positional and remaining arguments:
Usage:
Expands to:
Include file contents in command:
Usage:
Effect: Claude reads src/api/users.ts before processing command
Reference multiple files:
Reference known files without arguments:
Commands can execute bash commands inline to dynamically gather context before Claude processes the command. This is useful for including repository state, environment information, or project-specific context.
When to use:
Implementation details:
For complete syntax, examples, and best practices, see references/plugin-features-reference.md section on bash execution. The reference includes the exact syntax and multiple working examples to avoid execution issues
Simple organization for small command sets:
Use when: 5-15 commands, no clear categories
Organize commands in subdirectories:
Benefits:
/helpUse when: 15+ commands, clear categories
/helpallowed-tools when neededargument-hintBash(git:*) not Bash(*)Command not appearing:
.md extension presentArguments not working:
$1, $2 syntax correctargument-hint matches usageBash execution failing:
allowed-tools includes BashFile references not working:
@ syntax correctPlugin commands have access to ${CLAUDE_PLUGIN_ROOT}, an environment variable that resolves to the plugin's absolute path.
Purpose:
Basic usage:
Common patterns:
Why use it:
Plugin commands discovered automatically from commands/ directory:
Namespace benefits:
/help outputNaming conventions:
Configuration-based pattern:
Template-based pattern:
Multi-script pattern:
See references/plugin-features-reference.md for detailed patterns.
Commands can integrate with other plugin components for powerful workflows.
Launch plugin agents for complex tasks:
Key points:
plugin/agents/ directoryLeverage plugin skills for specialized knowledge:
Key points:
plugin/skills/ directoryDesign commands that work with plugin hooks:
See references/plugin-features-reference.md for examples of commands that coordinate with hooks
Combine agents, skills, and scripts:
When to use:
Commands should validate inputs and resources before processing.
Best practices:
For detailed frontmatter field specifications, see references/frontmatter-reference.md.
For plugin-specific features and patterns, see references/plugin-features-reference.md.
For command pattern examples, see examples/ directory.