AgentSkillsCN

slash-command-creator

创建Claude Code斜杠命令的指南。当用户想要创建新斜杠命令、更新现有斜杠命令,或询问斜杠命令语法、frontmatter选项或最佳实践时使用此技能。

SKILL.md
--- frontmatter
name: slash-command-creator
description: Guide for creating Claude Code slash commands. Use when the user wants to create a new slash command, update an existing slash command, or asks about slash command syntax, frontmatter options, or best practices.

Slash Command Creator

Create custom slash commands for Claude Code to automate frequently-used prompts.

Quick Start

Initialize a new command:

bash
scripts/init_command.py <command-name> [--scope project|personal]

Command Structure

Slash commands are Markdown files with optional YAML frontmatter:

markdown
---
description: Brief description shown in /help
---

Your prompt instructions here.

$ARGUMENTS

File Locations

ScopePathShown as
Project.claude/commands/(project)
Personal~/.claude/commands/(user)

Namespacing

Organize commands in subdirectories:

  • .claude/commands/frontend/component.md/component shows "(project:frontend)"
  • ~/.claude/commands/backend/api.md/api shows "(user:backend)"

Features

Arguments

All arguments - $ARGUMENTS:

markdown
Fix issue #$ARGUMENTS following our coding standards
# /fix-issue 123 → "Fix issue #123 following..."

Positional - $1, $2, etc.:

markdown
Review PR #$1 with priority $2
# /review 456 high → "Review PR #456 with priority high"

Bash Execution

Execute shell commands with ! prefix (requires allowed-tools in frontmatter):

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

Current status: !`git status`
Changes: !`git diff HEAD`

File References

Include file contents with @ prefix:

markdown
Review @src/utils/helpers.js for issues.
Compare @$1 with @$2.

Frontmatter Options

FieldPurposeRequired
descriptionBrief description for /helpYes
allowed-toolsTools the command can useNo
argument-hintExpected arguments hintNo
modelSpecific model to useNo
disable-model-invocationPrevent SlashCommand tool invocationNo

See references/frontmatter.md for detailed reference.

Examples

See references/examples.md for complete examples including:

  • Simple review/explain commands
  • Commands with positional arguments
  • Git workflow commands with bash execution
  • Namespaced commands for frontend/backend

Creation Workflow

  1. Identify the use case: What prompt do you repeat often?
  2. Choose scope: Project (shared) or personal (private)?
  3. Initialize: Run scripts/init_command.py <name>
  4. Edit: Update description and body
  5. Test: Run the command in Claude Code