← Back to Skills

creating-claude-commands

pr-pm
Updated Today
27 views
62
9
62
View on GitHub
Metaaidesign

About

This skill provides expert guidance for developers creating Claude Code slash commands, focusing on correct frontmatter, structure, and best practices. Use it when building new commands, understanding required fields like description and argument-hint, or needing validation guidance. It helps ensure commands are properly formatted and functional within the Claude Code environment.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/pr-pm/prpm
Git CloneAlternative
git clone https://github.com/pr-pm/prpm.git ~/.claude/skills/creating-claude-commands

Copy and paste this command in Claude Code to install this skill

Documentation

Creating Claude Code Slash Commands

Expert guidance for creating Claude Code slash commands - quick actions triggered by /command-name.

When to Use This Skill

Activate this skill when:

  • User wants to create a new slash command
  • User needs to understand slash command structure
  • User asks about frontmatter fields for commands
  • User wants validation guidance for commands
  • User needs examples of command patterns

Quick Reference

FieldRequiredTypeDescription
descriptionNostringBrief description shown in autocomplete
allowed-toolsNostringComma-separated list of tools (inherits if not specified)
argument-hintNostringExpected arguments (e.g., add [tagId] | remove [tagId] | list)
modelNostringSpecific model (sonnet, opus, haiku, inherit)
disable-model-invocationNobooleanPrevent SlashCommand tool from calling this
commandTypeNostringSet to "slash-command" for round-trip conversion

File Location

Slash commands must be saved as Markdown files:

Project commands (shared with team):

.claude/commands/command-name.md

Personal commands (individual use):

~/.claude/commands/command-name.md

Format Requirements

Basic Structure

---
description: Generate documentation for code
allowed-tools: Read, Edit
model: sonnet
---

# πŸ“ Documentation Generator

Generate comprehensive documentation for the selected code.

## Instructions

- Analyze code structure and purpose
- Generate clear, concise documentation
- Include parameter descriptions
- Add usage examples
- Follow JSDoc/TSDoc format for TypeScript

With Arguments

---
description: Manage tags for files
argument-hint: add [tagId] | remove [tagId] | list
allowed-tools: Read, Write
---

# Tag Manager

Manage tags for project files.

## Usage

- `/tags add <tagId>` - Add a tag
- `/tags remove <tagId>` - Remove a tag
- `/tags list` - List all tags

Minimal Command

---
description: Quick code review
---

Review the current file for:
- Code quality issues
- Security vulnerabilities
- Performance bottlenecks
- Best practice violations

Frontmatter Fields

description (optional)

Brief description of what the command does. Shown in autocomplete. Defaults to first line from prompt if not specified.

---
description: Generate comprehensive documentation for selected code
---

allowed-tools (optional)

Comma-separated string of tools the command can use. Inherits from conversation if not specified.

Valid tools: Read, Write, Edit, Grep, Glob, Bash, WebSearch, WebFetch, Task, Skill, SlashCommand, TodoWrite, AskUserQuestion

---
allowed-tools: Read, Edit, Grep
---

With Bash restrictions:

---
allowed-tools: Bash(git status:*), Bash(git diff:*), Read
---

argument-hint (optional)

Expected arguments for the command. Shown when auto-completing.

---
argument-hint: [file-path]
---
---
argument-hint: add [tagId] | remove [tagId] | list
---

model (optional)

Specific model to use for this command. Inherits from conversation if not specified.

Valid values:

  • sonnet - General purpose (Claude Sonnet 3.5)
  • haiku - Fast, simple tasks (Claude Haiku 3.5)
  • opus - Complex reasoning (Claude Opus 4)
  • inherit - Use conversation model (default)
---
model: sonnet
---

disable-model-invocation (optional)

Set to true to prevent Claude from automatically invoking this command via the SlashCommand tool.

---
disable-model-invocation: true
---

commandType (optional)

Set to "slash-command" for explicit type preservation in round-trip conversion (PRPM extension).

---
commandType: slash-command
---

Content Format

The content after frontmatter contains the command prompt and instructions.

H1 Title (optional)

Can include emoji icon for visual identification:

# πŸ“ Documentation Generator
# πŸ” Code Reviewer

Instructions

Clear, actionable guidance for what the command should do:

## Instructions

- Analyze code structure and purpose
- Generate clear, concise documentation
- Include parameter descriptions
- Add usage examples

Output Format

Specify expected output format:

## Output Format

Return formatted documentation ready to paste above the code:

/**
 * Function description
 * @param {string} name - Parameter description
 * @returns {Promise<User>} Return value description
 */

Examples

Show Claude what good output looks like:

## Example Output

```typescript
/**
 * Creates a new user with the provided data
 * @param {UserData} userData - User information (email, name)
 * @returns {Promise<User>} Created user with ID
 * @throws {ValidationError} If email format is invalid
 */
async function createUser(userData: UserData): Promise<User> {
  // ...
}

## Schema Validation

Commands are validated against the JSON Schema:

**Schema Location:** https://github.com/pr-pm/prpm/blob/main/packages/converters/schemas/claude-slash-command.schema.json

**Required structure:**
```json
{
  "frontmatter": {
    "description": "string (optional)",
    "allowed-tools": "string (optional)",
    "argument-hint": "string (optional)",
    "model": "string (optional)",
    "disable-model-invocation": "boolean (optional)",
    "commandType": "slash-command (optional)"
  },
  "content": "string (markdown content)"
}

Common Mistakes

MistakeProblemSolution
Using array for toolsallowed-tools: [Read, Write]Use string: allowed-tools: Read, Write
Wrong field namestools:, arguments:Use allowed-tools, argument-hint
Missing frontmatter delimitersFrontmatter not parsedUse --- before and after YAML
Invalid tool namesbash, grep (lowercase)Use capitalized: Bash, Grep
Invalid model values3.5-sonnet, claude-opusUse: sonnet, opus, haiku, inherit
Icons in frontmattericon: πŸ“Put icon in H1: # πŸ“ Title
No descriptionAutocomplete shows filenameAdd description field

Best Practices

1. Keep Commands Focused

Each command should do ONE thing well:

Good:

---
description: Generate JSDoc comments for functions
---

Bad:

---
description: Generate docs, fix linting, add tests, refactor code
---

2. Use Clear Descriptions

Make descriptions specific and actionable:

Good:

description: Generate comprehensive JSDoc documentation for selected code

Bad:

description: Make docs

3. Specify Tool Permissions

Only request tools actually needed:

Good:

allowed-tools: Read, Edit

Bad:

allowed-tools: Read, Write, Edit, Grep, Glob, Bash, WebSearch

4. Document Expected Arguments

Use argument-hint to show expected arguments:

argument-hint: [file-path]
argument-hint: <feature-name>
argument-hint: add [item] | remove [item] | list

5. Include Usage Examples

Show users how to invoke the command:

## Usage

- `/generate-docs path/to/file.ts` - Generate docs for specific file
- `/generate-docs` - Generate docs for current selection

6. Specify Output Format

Tell Claude what format you want:

## Output Format

Generate TypeScript interfaces with JSDoc comments:

```typescript
/**
 * User account information
 */
interface User {
  /** Unique identifier */
  id: string;
  /** User email address */
  email: string;
}

### 7. Add Examples to Prompt

Show Claude examples of good output:

```markdown
## Example

Good documentation:

```typescript
/**
 * Calculates total price with tax
 * @param price - Base price before tax
 * @param taxRate - Tax rate as decimal (e.g., 0.08 for 8%)
 * @returns Total price including tax
 */
function calculateTotal(price: number, taxRate: number): number {
  return price * (1 + taxRate);
}

### 8. Use Icons for Visual Identification

Add emoji to H1 heading for quick recognition:

```markdown
# πŸ“ Documentation Generator
# πŸ” Code Reviewer
# πŸ§ͺ Test Generator
# πŸ”§ Refactoring Assistant
# πŸ› Bug Finder

Common Patterns

Code Review Command

---
description: Review code for quality, security, and performance issues
allowed-tools: Read, Grep
---

# πŸ” Code Reviewer

Review the selected code or current file for:

## Code Quality
- Clean, readable code
- Proper naming conventions
- DRY principle adherence
- SOLID principles

## Security
- Input validation
- SQL injection risks
- XSS vulnerabilities
- Authentication/authorization

## Performance
- Inefficient algorithms
- Unnecessary computations
- Memory leaks
- Database query optimization

## Output Format

Provide specific file:line references for all issues:

**[Issue Type]** (file.ts:42) - Issue description and suggested fix

Documentation Generator

---
description: Generate comprehensive documentation for selected code
allowed-tools: Read, Edit
model: sonnet
---

# πŸ“ Documentation Generator

Generate comprehensive documentation for the selected code.

## Instructions

- Analyze code structure and purpose
- Generate clear, concise documentation
- Include parameter descriptions with types
- Add usage examples
- Follow JSDoc/TSDoc format for TypeScript
- Document error conditions and edge cases

## Output Format

Return formatted documentation ready to paste above the code.

For TypeScript/JavaScript:
```typescript
/**
 * Function description
 * @param {Type} paramName - Parameter description
 * @returns {ReturnType} Return value description
 * @throws {ErrorType} Error conditions
 */

### Test Generator

```markdown
---
description: Generate test cases for selected code
allowed-tools: Read, Write
---

# πŸ§ͺ Test Generator

Generate comprehensive test cases for the selected code.

## Test Coverage

Create tests covering:
- Happy path scenarios
- Edge cases
- Error conditions
- Boundary values
- Invalid input handling

## Structure

Follow the project's testing conventions:
- Use existing test framework (Jest, Mocha, etc.)
- Match naming patterns
- Follow setup/teardown patterns
- Use appropriate matchers

## Example

```typescript
describe('calculateTotal', () => {
  it('should calculate total with valid inputs', () => {
    const result = calculateTotal(100, 0.08);
    expect(result).toBe(108);
  });

  it('should handle zero tax rate', () => {
    const result = calculateTotal(100, 0);
    expect(result).toBe(100);
  });

  it('should throw for negative price', () => {
    expect(() => calculateTotal(-100, 0.08)).toThrow();
  });
});

### Git Workflow Command

```markdown
---
description: Create and push feature branch
argument-hint: <feature-name>
allowed-tools: Bash(git *)
---

# 🌿 Feature Branch Creator

Create and push a new feature branch.

## Process

1. Create branch: `feature/$1`
2. Switch to new branch
3. Push to origin with upstream tracking

## Usage

```bash
/feature user-authentication
/feature api-optimization

Implementation

git checkout -b feature/$1
git push -u origin feature/$1

### Refactoring Command

```markdown
---
description: Refactor code while preserving behavior
allowed-tools: Read, Edit, Bash
---

# πŸ”§ Refactoring Assistant

Refactor the selected code while maintaining functionality.

## Guidelines

- Preserve existing behavior exactly
- Improve code structure and readability
- Extract reusable functions
- Reduce complexity
- Follow project conventions
- Update related tests

## Process

1. Read and understand current implementation
2. Identify refactoring opportunities
3. Propose changes with explanations
4. Update code with improvements
5. Verify tests still pass
6. Update documentation if needed

## Safety

- Run tests after refactoring
- Commit changes incrementally
- Keep changes focused and atomic

Validation Checklist

Before finalizing a slash command:

  • Command name is clear and concise
  • Description is specific and actionable
  • Argument hints provided if arguments expected
  • Tool permissions are minimal and specific
  • Model selection appropriate for task complexity
  • Frontmatter uses correct field names
  • Frontmatter values match allowed types
  • allowed-tools is comma-separated string, not array
  • H1 title includes icon (optional but recommended)
  • Instructions are clear and actionable
  • Expected output format is specified
  • Examples included in prompt
  • File saved to .claude/commands/*.md
  • Command tested and working

Related Documentation

GitHub Repository

pr-pm/prpm
Path: .claude/skills/creating-claude-commands
claudeclaude-codecursorcursor-ai-editcursorrulespackage-manager

Related Skills

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

llamaguard

Other

LlamaGuard is Meta's 7-8B parameter model for moderating LLM inputs and outputs across six safety categories like violence and hate speech. It offers 94-95% accuracy and can be deployed using vLLM, Hugging Face, or Amazon SageMaker. Use this skill to easily integrate content filtering and safety guardrails into your AI applications.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill