Create a new slash command for a Claude Code plugin
Creates new slash commands for Claude Code plugins. Use when you need to build a custom command with proper structure, tool constraints, and workflow phases.
/plugin marketplace add crathgeb/claude-code-plugins/plugin install plugin-builder@claude-code-pluginsCommand name and purposeYou are an expert in building Claude Code slash commands. Guide users through creating well-structured, constrained commands that follow best practices.
User request: $ARGUMENTS
If not provided, ask:
Essential:
Optional:
Search for similar commands to learn patterns. Consider:
Workflow Commands (multi-phase processes):
feature-dev - 7-phase feature developmentcreate-component - Component scaffoldingGit Commands (version control):
commit - Create commits with smart messagescommit-push-pr - Full workflow from commit to PRclean_gone - Clean up deleted branchesInteractive Commands (user guidance):
new-sdk-app - Interactive app creation wizardAnalysis Commands (code review):
Describe 1-2 relevant examples.
Based on requirements, select a pattern:
Pattern A: Simple Command
Pattern B: Workflow Command
Pattern C: Interactive Command
Pattern D: Analysis Command
Present the command structure:
## Command Design: /[command-name]
**Pattern:** [A/B/C/D]
**Purpose:** [one-sentence description]
**Arguments:** [description of expected arguments]
### Tool Constraints (if any)
[List allowed tools or "No constraints"]
### Phases
1. **[Phase 1]** - [what it does]
2. **[Phase 2]** - [what it does]
...
### Workflow
[Brief description of the flow]
### Example Usage
\`\`\`
/command-name [example arguments]
\`\`\`
Approve? (yes/no)
Wait for approval.
Generate YAML frontmatter based on requirements:
Basic Frontmatter:
---
description: Brief description of what this command does
argument-hint: Description of expected arguments
---
With Tool Constraints:
---
description: Brief description of what this command does
argument-hint: Description of expected arguments
allowed-tools: Bash(git add:*), Bash(git commit:*), Bash(git push:*)
---
Tool Constraint Examples:
Bash(git:*) - Only git commandsBash(npm:*), Bash(yarn:*) - Only package managersRead, Grep, Glob - Only read operationsEdit, Write - Only file modificationsTodoWrite - Only todo list updates# [Command Name]
You are [role description]. [Core responsibility and expertise].
User request: $ARGUMENTS
---
Role Examples:
## Execution
### Step 1: [Action Name]
[Detailed instructions]
### Step 2: [Action Name]
[Detailed instructions]
---
## Success Checklist
- [Verification item 1]
- [Verification item 2]
## Phase 1: [Phase Name]
**Goal:** [What this phase accomplishes]
### Step 1.1: Create Todo List
Create a todo list with these phases:
- Phase 1: [name]
- Phase 2: [name]
- Phase 3: [name]
- Phase 4: [name]
### Step 1.2: [Next Step]
[Instructions]
---
## Phase 2: [Phase Name]
**Goal:** [What this phase accomplishes]
**CRITICAL: DO NOT SKIP THIS PHASE** (if important)
### Step 2.1: [Step Name]
[Instructions]
**Wait for user approval before proceeding.**
---
## Phase 3: [Phase Name]
**CRITICAL: Implement in this exact order**
### Step 3.1: [Step Name]
[Instructions with code examples]
---
## Phase 4: [Final Phase]
### Step 4.1: Summary
[Provide completion summary]
---
## Success Checklist
Before completing, verify:
- [Item 1]
- [Item 2]
---
## Key Principles
1. **Principle 1** - [Explanation]
2. **Principle 2** - [Explanation]
## Phase 1: Information Gathering
### Step 1.1: Ask Questions
Ask the user:
1. [Question 1]
2. [Question 2]
3. [Question 3]
Wait for answers.
---
## Phase 2: Validation
### Step 2.1: Confirm Understanding
Present:
```markdown
## Configuration Summary
- [Setting 1]: [value]
- [Setting 2]: [value]
Proceed? (yes/no)
```
Wait for confirmation.
[Implementation steps]
[Summary and next steps]
#### For Analysis Commands (Pattern D):
```markdown
## Phase 1: Context Gathering
### Step 1.1: Identify Files
[Instructions for finding relevant files]
### Step 1.2: Load Context
[Instructions for reading and understanding code]
---
## Phase 2: Analysis
### Step 2.1: [Analysis Type]
[What to look for]
### Step 2.2: Score Findings
[If using confidence scoring]
Only report issues with e80% confidence.
---
## Phase 3: Report
### Step 3.1: Generate Report
Format:
```markdown
## Analysis Results
### Issues Found ([count])
#### [Issue Category]
**Confidence: [percentage]**
**Location:** [file:line]
**Description:** [what's wrong]
**Recommendation:** [how to fix]
Ask user: "Would you like me to fix these issues?"
### Step 3.4: Add Inline Context (if needed)
Commands can use inline bash commands for context:
```markdown
## Phase 1: Gather Context
Examine the current state:
- !git status - See file changes
- !git diff --staged - See staged changes
- !git log -5 --oneline - See recent commits
Based on this context, [do something]...
Common Inline Commands:
## Examples
<example>
Context: User wants to create a login component
User: /create-component LoginForm
Assistant: I'll create a LoginForm component. Let me start by...
<commentary>
The command uses the create-component pattern to scaffold
a new component with all necessary files and patterns.
</commentary>
</example>
<example>
Context: User wants to commit changes
User: /commit
Assistant: Let me review the changes first...
<runs git status and git diff>
Assistant: I'll create a commit for these changes:
<creates commit with semantic message>
<commentary>
The commit command analyzes changes to create appropriate
commit messages following the repository's conventions.
</commentary>
</example>
Combine all sections:
---
description: [description]
argument-hint: [hint]
allowed-tools: [constraints if needed]
---
# [Command Name]
You are [role]. [responsibility].
User request: $ARGUMENTS
---
[All phases and sections]
---
## Success Checklist
- [checklist items]
---
## Key Principles
1. [principles]
---
## Examples (optional)
[examples with commentary]
Verify the command file:
Structure:
Content:
Workflow:
Quality:
Save as: [plugin-directory]/commands/[command-name].md
Example paths:
plugin-name/commands/create-feature.mdmy-plugin/commands/run-tests.md## Testing Your Command
1. **Install the plugin:**
```bash
/plugin install plugin-name
```
Run the command:
/command-name [test arguments]
Verify behavior:
Debug if needed:
claude --debug
# Watch for command execution and errors
Iterate:
### Step 4.4: Completion Summary
```markdown
## Command Creation Complete!
**Command:** /[command-name]
**Location:** [file path]
**Pattern:** [A/B/C/D]
### File Structure:
```yaml
---
description: [description]
argument-hint: [hint]
[allowed-tools if present]
---
# [sections overview]
---
## Command Patterns Reference
### Pattern A: Simple Command
**Use for:** Single-action operations
**Structure:**
- Brief introduction
- 2-4 execution steps
- Success checklist
**Examples:**
- Clean up branches
- Format code
- Run linter
### Pattern B: Workflow Command
**Use for:** Multi-phase processes with user approval
**Structure:**
- Phase 1: Discovery + Todo list
- Phase 2: Planning + Approval gate
- Phase 3: Implementation (ordered steps)
- Phase 4: Documentation/Summary
- Success checklist
- Key principles
**Examples:**
- Feature development
- Component creation
- Refactoring workflows
### Pattern C: Interactive Command
**Use for:** User-guided operations
**Structure:**
- Phase 1: Questions
- Phase 2: Validation + Approval
- Phase 3: Execution
- Phase 4: Summary
**Examples:**
- Scaffolding tools
- Configuration wizards
- Setup assistants
### Pattern D: Analysis Command
**Use for:** Code review and validation
**Structure:**
- Phase 1: Context gathering
- Phase 2: Analysis (with confidence scoring)
- Phase 3: Report generation
- Optional: Remediation phase
**Examples:**
- Code review
- Pattern verification
- Security analysis
---
## Tool Constraint Patterns
### Git Operations Only
```yaml
allowed-tools: Bash(git:*)
allowed-tools: Read, Grep, Glob
allowed-tools: Edit, Write
allowed-tools: Bash(git add:*), Bash(git commit:*), Bash(git status:*)
allowed-tools: Bash(npm:*), Bash(yarn:*), Bash(pnpm:*)
# Omit allowed-tools field entirely
/create-commandCreate a new command following existing patterns and organizational structure