Create custom slash commands for Claude Code with complete frontmatter, arguments, and advanced features. Use when creating /commands, writing command .md files, configuring allowed-tools, adding argument placeholders ($ARGUMENTS, $1, $2), embedding bash execution with !`command`, using file references with @path, setting up plugin commands with namespacing, or deciding between slash commands vs skills.
Creates custom slash commands for Claude Code with frontmatter, arguments, and tool restrictions. Use when building /commands, configuring allowed-tools, or setting up bash execution and file references.
/plugin marketplace add basher83/lunar-claude/plugin install meta-claude@lunar-claudeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/agent-skills-best-practices.mdreferences/agent-skills-overview.mdreferences/agent-skills-quickstart.mdreferences/anthropic-slash-commands.mdreferences/hooks-guide.mdreferences/hooks.mdreferences/mcp.mdreferences/memory.mdreferences/output-styles.mdreferences/plugin-marketplaces.mdreferences/plugins-reference.mdreferences/plugins.mdreferences/settings.mdreferences/skills.mdreferences/slash-commands.mdreferences/statusline.mdreferences/sub-agents.mdCreate custom slash commands for Claude Code - from simple prompts to advanced commands with bash execution, file references, and tool restrictions.
Create a simple command:
mkdir -p .claude/commands
cat > .claude/commands/review.md << 'EOF'
---
description: Review code for bugs and improvements
---
Review the provided code for:
- Logic errors and bugs
- Performance issues
- Security vulnerabilities
- Code style violations
Provide actionable feedback with specific line references.
EOF
Invoke with: /review
| Location | Scope | Description Label |
|---|---|---|
.claude/commands/ | Project | (project) |
~/.claude/commands/ | Personal | (user) |
plugins/<name>/commands/ | Plugin | (plugin:<name>) |
All frontmatter fields:
---
description: Brief description shown in /help
argument-hint: [file] [options]
allowed-tools: Bash(git:*), Read, Write
model: claude-sonnet-4-20250514
disable-model-invocation: false
---
| Field | Purpose | Default |
|---|---|---|
description | Shown in /help and SlashCommand tool context | First line of content |
argument-hint | Autocomplete hint for arguments | None |
allowed-tools | Restrict available tools | Inherits from conversation |
model | Override model for this command | Inherits from conversation |
disable-model-invocation | Prevent SlashCommand tool from calling | false |
$ARGUMENTS---
description: Fix GitHub issue
---
Fix issue #$ARGUMENTS following project coding standards.
Usage: /fix-issue 123 high-priority → $ARGUMENTS = "123 high-priority"
$1, $2, $3---
description: Review PR with priority
argument-hint: [pr-number] [priority] [assignee]
---
Review PR #$1 with priority $2 and assign to $3.
Focus on security, performance, and code style.
Usage: /review-pr 456 high alice → $1=456, $2=high, $3=alice
Execute commands before prompt expansion using the ! + backtick syntax (e.g., ! followed by a command in backticks).
Requires allowed-tools: Bash(...) in frontmatter.
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
description: Create a git commit
---
## Context
- Current status: !`git status`
- Staged diff: !`git diff --cached`
- Current branch: !`git branch --show-current`
- Recent commits: !`git log --oneline -10`
## Task
Based on the staged changes above, create a commit with a descriptive message.
Include file contents using @path syntax:
Review the implementation in @src/utils/helpers.js
Compare @src/old-version.js with @src/new-version.js
Subdirectories organize commands and appear in descriptions:
| File Location | Command | Description |
|---|---|---|
.claude/commands/deploy.md | /deploy | (project) |
.claude/commands/frontend/build.md | /build | (project:frontend) |
~/.claude/commands/utils/format.md | /format | (user:utils) |
Note: Subdirectories don't affect command names, only descriptions.
Plugin commands live in commands/ directory of plugin root:
plugins/my-plugin/
├── commands/
│ ├── deploy.md
│ └── test/
│ └── run.md
└── plugin.json
Invocation patterns:
/deploy # Direct (if no conflicts)
/my-plugin:deploy # Namespaced (for disambiguation)
/my-plugin:run # Subdirectory command
Claude can invoke custom commands programmatically. Commands must have description field to be available.
SlashCommand:/commit # Exact match (no arguments)
SlashCommand:/review-pr:* # Prefix match (any arguments)
---
description: Sensitive command
disable-model-invocation: true
---
Default: 15,000 characters for all command metadata.
Override: SLASH_COMMAND_TOOL_CHAR_BUDGET environment variable.
Commands can trigger extended thinking by including keywords like "think deeply", "step by step", or "analyze thoroughly" in the command content.
| Aspect | Slash Commands | Skills |
|---|---|---|
| Complexity | Simple prompts | Complex capabilities |
| Structure | Single .md file | Directory with SKILL.md + resources |
| Discovery | Explicit (/command) | Automatic (context-based) |
| Files | One file only | Multiple files, scripts, templates |
Use slash commands when:
Use skills when:
---
allowed-tools: Bash(git:*)
description: Create atomic git commit
argument-hint: [message]
---
## Context
!`git status`
!`git diff --cached`
## Task
Create a git commit. If $ARGUMENTS provided, use as message.
Otherwise, generate descriptive message from diff.
---
description: Generate boilerplate code
argument-hint: [type] [name]
---
Generate $1 boilerplate named $2.
Supported types: component, hook, service, util
Follow project conventions in @src/templates/
---
allowed-tools: Read, Grep, Glob
description: Read-only code review
---
Review the codebase for the issue described.
DO NOT modify any files - this is a read-only review.
Provide analysis and recommendations only.
Before finalizing a command:
description frontmatter is present and descriptiveargument-hint matches actual argument usageallowed-tools restricts to necessary tools onlyThis 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 skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.