creating-commands
Creates new Claude Code slash commands following best practices. Guides through command structure, naming, arguments, and frontmatter. Use when user wants to create a command, build a slash command, or asks about command best practices.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Creating Commands
Guides creation of Claude Code slash commands using documented best practices.
Quick Start
For a new command:
- Ask user for command purpose and arguments needed
- Generate using appropriate template
- Validate against checklist
For reviewing existing command:
- Read command file
- Check against anti-patterns in reference.md
- Report issues with fixes
Workflow: Create New Command
Progress:
- [ ] Gather requirements (purpose, arguments, scope)
- [ ] Choose template (basic, with-args, workflow)
- [ ] Generate command file
- [ ] Validate against checklist
Step 1: Gather Requirements
Ask user with AskUserQuestion:
- What should this command do? (purpose)
- Does it need arguments? (none, single, multiple)
- Project or personal? (scope)
Step 2: Choose Template
| Type | Template | When to Use |
|---|---|---|
| Basic | templates/basic.md | No arguments, simple prompt |
| With Args | templates/with-args.md | Single or multiple arguments |
| Workflow | templates/workflow.md | Integrates with skills/agents |
Step 3: Generate Command
Create in appropriate location:
-
.claude/commands/- Project commands (git-tracked) -
~/.claude/commands/- Personal commands (your machine only)
Step 4: Validate
Run through checklist before finishing:
Validation Checklist:
- [ ] Name: lowercase with hyphens only
- [ ] Name: descriptive, verb-noun format preferred
- [ ] Description: explains what command does
- [ ] Arguments: documented with argument-hint if used
- [ ] Prompt: clear, actionable instructions
- [ ] Tools: allowed-tools declared if needed
Naming Rules
Format: verb-noun or action (lowercase, hyphens)
-
fix-issue -
review-pr -
run-tests -
optimize
Constraints:
- Lowercase letters, numbers, hyphens only
- No spaces or underscores
- Keep concise (1-3 words)
Command File Format
---
description: Brief explanation shown in help
allowed-tools:
- Bash(bash:*)
- WebSearch
argument-hint: "param_name"
---
Your command prompt here.
Use $ARGUMENTS for all args or $1, $2 for positional.
Argument Syntax
| Syntax | Usage | Example |
|---|---|---|
$ARGUMENTS |
All arguments as one string | /cmd foo bar → foo bar |
$1, $2 |
Positional arguments | /cmd foo bar → $1=foo, $2=bar |
@file |
Include file contents | Review @src/main.ts |
Frontmatter Options
| Field | Purpose | Required |
|---|---|---|
description |
Shown in help, enables auto-invoke | Recommended |
allowed-tools |
Tools the command can use | If using tools |
argument-hint |
Documents expected args | If has args |
model |
Specific model to use | Optional |
Example: Basic Command
---
description: Run all tests and report failures
allowed-tools:
- Bash(npm:*)
---
Run the test suite and summarize results:
1. Execute `npm test`
2. If failures, show failing tests with context
3. Suggest fixes for common issues
See reference.md for detailed best practices and anti-patterns.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-28
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!