Marketplace

slash-command-creator

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.

$ 安裝

git clone https://github.com/basher83/lunar-claude /tmp/lunar-claude && cp -r /tmp/lunar-claude/plugins/meta/meta-claude/skills/slash-command-creator ~/.claude/skills/lunar-claude

// tip: Run this command in your terminal to install the skill


name: slash-command-creator description: > 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.

Slash Command Creator

Create custom slash commands for Claude Code - from simple prompts to advanced commands with bash execution, file references, and tool restrictions.

Quick Start

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

Command Locations

LocationScopeDescription Label
.claude/commands/Project(project)
~/.claude/commands/Personal(user)
plugins/<name>/commands/Plugin(plugin:<name>)

Frontmatter Reference

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
---
FieldPurposeDefault
descriptionShown in /help and SlashCommand tool contextFirst line of content
argument-hintAutocomplete hint for argumentsNone
allowed-toolsRestrict available toolsInherits from conversation
modelOverride model for this commandInherits from conversation
disable-model-invocationPrevent SlashCommand tool from callingfalse

Arguments

Capture All: $ARGUMENTS

---
description: Fix GitHub issue
---

Fix issue #$ARGUMENTS following project coding standards.

Usage: /fix-issue 123 high-priority$ARGUMENTS = "123 high-priority"

Positional: $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

Bash Execution

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.

File References

Include file contents using @path syntax:

Review the implementation in @src/utils/helpers.js

Compare @src/old-version.js with @src/new-version.js

Namespacing

Subdirectories organize commands and appear in descriptions:

File LocationCommandDescription
.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

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

SlashCommand Tool

Claude can invoke custom commands programmatically. Commands must have description field to be available.

Permission Rules

SlashCommand:/commit        # Exact match (no arguments)
SlashCommand:/review-pr:*   # Prefix match (any arguments)

Disable for Specific Command

---
description: Sensitive command
disable-model-invocation: true
---

Character Budget

Default: 15,000 characters for all command metadata. Override: SLASH_COMMAND_TOOL_CHAR_BUDGET environment variable.

Thinking Mode

Commands can trigger extended thinking by including keywords like "think deeply", "step by step", or "analyze thoroughly" in the command content.

Slash Commands vs Skills

AspectSlash CommandsSkills
ComplexitySimple promptsComplex capabilities
StructureSingle .md fileDirectory with SKILL.md + resources
DiscoveryExplicit (/command)Automatic (context-based)
FilesOne file onlyMultiple files, scripts, templates

Use slash commands when:

  • Prompt fits in a single file
  • You invoke it repeatedly with explicit control
  • Simple, focused task

Use skills when:

  • Multiple reference files or scripts needed
  • Claude should auto-discover capability
  • Complex workflows with validation steps

Common Patterns

Git Commit Command

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

Code Generator Command

---
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/

Review with Tool Restrictions

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

Validation Checklist

Before finalizing a command:

  • description frontmatter is present and descriptive
  • argument-hint matches actual argument usage
  • allowed-tools restricts to necessary tools only
  • Bash execution has matching tool permissions
  • File references use valid relative paths
  • Command name is kebab-case and descriptive

References

Repository

basher83
basher83
Author
basher83/lunar-claude/plugins/meta/meta-claude/skills/slash-command-creator
10
Stars
1
Forks
Updated3d ago
Added6d ago