command-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Command Creator

命令创建器

This skill guides the creation of Claude Code slash commands - reusable workflows that can be invoked with
/command-name
in Claude Code conversations.
此技能指导你创建Claude Code斜杠命令——这些是可复用的工作流程,在Claude Code对话中可通过
/command-name
调用。

About Slash Commands

关于斜杠命令

Slash commands are markdown files stored in
.claude/commands/
(project-level) or
~/.claude/commands/
(global/user-level) that get expanded into prompts when invoked. They're ideal for:
  • Repetitive workflows (code review, PR submission, CI fixing)
  • Multi-step processes that need consistency
  • Agent delegation patterns
  • Project-specific automation
斜杠命令是存储在
.claude/commands/
(项目级)或
~/.claude/commands/
(全局/用户级)的Markdown文件,调用时会展开为提示词。它们非常适合:
  • 重复性工作流(代码审查、PR提交、CI修复)
  • 需要一致性的多步骤流程
  • Agent委托模式
  • 项目特定的自动化

When to Use This Skill

何时使用此技能

Invoke this skill when users:
  • Ask to "create a command" or "make a slash command"
  • Want to automate a repetitive workflow
  • Need to document a consistent process for reuse
  • Say "I keep doing X, can we make a command for it?"
  • Want to create project-specific or global commands
当用户出现以下情况时,调用此技能:
  • 要求“创建命令”或“制作斜杠命令”
  • 希望自动化重复性工作流
  • 需要将一致的流程文档化以便复用
  • 说“我一直在做X,我们能为此制作一个命令吗?”
  • 想要创建项目特定或全局命令

Bundled Resources

附带资源

This skill includes reference documentation for detailed guidance:
  • references/patterns.md - Command patterns (workflow automation, iterative fixing, agent delegation, simple execution)
  • references/examples.md - Real command examples with full source (submit-stack, ensure-ci, create-implementation-plan)
  • references/best-practices.md - Quality checklist, common pitfalls, writing guidelines, template structure
Load these references as needed when creating commands to understand patterns, see examples, or ensure quality.
此技能包含参考文档,供你获取详细指导:
  • references/patterns.md - 命令模式(工作流自动化、迭代修复、Agent委托、简单执行)
  • references/examples.md - 完整源码的真实命令示例(submit-stack、ensure-ci、create-implementation-plan)
  • references/best-practices.md - 质量检查表、常见陷阱、编写指南、模板结构
创建命令时,可根据需要加载这些参考文档,以了解模式、查看示例或确保质量。

Command Structure Overview

命令结构概述

Every slash command is a markdown file with:
markdown
---
description: Brief description shown in /help (required)
argument-hint: <placeholder> (optional, if command takes arguments)
---
每个斜杠命令都是一个Markdown文件,结构如下:
markdown
---
description: 显示在/help中的简短描述(必填)
argument-hint: <占位符>(可选,如果命令接受参数)
---

Command Title

命令标题

[Detailed instructions for the agent to execute autonomously]
undefined
[供Agent自主执行的详细说明]
undefined

Command Creation Workflow

命令创建工作流

Step 1: Determine Location

步骤1:确定存储位置

Auto-detect the appropriate location:
  1. Check git repository status:
    git rev-parse --is-inside-work-tree 2>/dev/null
  2. Default location:
    • If in git repo → Project-level:
      .claude/commands/
    • If not in git repo → Global:
      ~/.claude/commands/
  3. Allow user override:
    • If user explicitly mentions "global" or "user-level" → Use
      ~/.claude/commands/
    • If user explicitly mentions "project" or "project-level" → Use
      .claude/commands/
Report the chosen location to the user before proceeding.
自动检测合适的位置:
  1. 检查Git仓库状态:
    git rev-parse --is-inside-work-tree 2>/dev/null
  2. 默认位置:
    • 如果在Git仓库内 → 项目级:
      .claude/commands/
    • 如果不在Git仓库内 → 全局:
      ~/.claude/commands/
  3. 允许用户覆盖:
    • 如果用户明确提到“global”或“user-level” → 使用
      ~/.claude/commands/
    • 如果用户明确提到“project”或“project-level” → 使用
      .claude/commands/
在继续之前,将选定的位置告知用户。

Step 2: Show Command Patterns

步骤2:展示命令模式

Help the user understand different command types. Load references/patterns.md to see available patterns:
  • Workflow Automation - Analyze → Act → Report (e.g., submit-stack)
  • Iterative Fixing - Run → Parse → Fix → Repeat (e.g., ensure-ci)
  • Agent Delegation - Context → Delegate → Iterate (e.g., create-implementation-plan)
  • Simple Execution - Run command with args (e.g., codex-review)
Ask the user: "Which pattern is closest to what you want to create?" This helps frame the conversation.
帮助用户了解不同的命令类型。加载references/patterns.md查看可用模式:
  • 工作流自动化 - 分析 → 执行 → 报告(例如submit-stack)
  • 迭代修复 - 运行 → 解析 → 修复 → 重复(例如ensure-ci)
  • Agent委托 - 上下文 → 委托 → 迭代(例如create-implementation-plan)
  • 简单执行 - 带参数运行命令(例如codex-review)
询问用户:“哪种模式最接近你想要创建的命令?”这有助于引导对话。

Step 3: Gather Command Information

步骤3:收集命令信息

Ask the user for key information:
向用户询问关键信息:

A. Command Name and Purpose

A. 命令名称与用途

Ask:
  • "What should the command be called?" (for filename)
  • "What does this command do?" (for description field)
Guidelines:
  • Command names MUST be kebab-case (hyphens, NOT underscores)
    • ✅ CORRECT:
      submit-stack
      ,
      ensure-ci
      ,
      create-from-plan
    • ❌ WRONG:
      submit_stack
      ,
      ensure_ci
      ,
      create_from_plan
  • File names match command names:
    my-command.md
    → invoked as
    /my-command
  • Description should be concise, action-oriented (appears in
    /help
    output)
询问:
  • “命令应该叫什么名字?”(用于文件名)
  • “这个命令的作用是什么?”(用于description字段)
指南:
  • 命令名称必须使用短横线分隔式(kebab-case,即使用连字符,而非下划线)
    • ✅ 正确:
      submit-stack
      ,
      ensure-ci
      ,
      create-from-plan
    • ❌ 错误:
      submit_stack
      ,
      ensure_ci
      ,
      create_from_plan
  • 文件名与命令名称一致:
    my-command.md
    → 调用方式为
    /my-command
  • 描述应简洁、以行动为导向(会显示在
    /help
    输出中)

B. Arguments

B. 参数

Ask:
  • "Does this command take any arguments?"
  • "Are arguments required or optional?"
  • "What should arguments represent?"
If command takes arguments:
  • Add
    argument-hint: <placeholder>
    to frontmatter
  • Use
    <angle-brackets>
    for required arguments
  • Use
    [square-brackets]
    for optional arguments
询问:
  • “这个命令是否接受参数?”
  • “参数是必填还是可选?”
  • “参数代表什么内容?”
如果命令接受参数:
  • 在前置元数据中添加
    argument-hint: <占位符>
  • 使用
    <尖括号>
    表示必填参数
  • 使用
    [方括号]
    表示可选参数

C. Workflow Steps

C. 工作流步骤

Ask:
  • "What are the specific steps this command should follow?"
  • "What order should they happen in?"
  • "What tools or commands should be used?"
Gather details about:
  • Initial analysis or checks to perform
  • Main actions to take
  • How to handle results
  • Success criteria
  • Error handling approach
询问:
  • “这个命令应该遵循哪些具体步骤?”
  • “步骤的执行顺序是什么?”
  • “应该使用哪些工具或命令?”
收集以下细节:
  • 要执行的初始分析或检查
  • 主要操作
  • 如何处理结果
  • 成功标准
  • 错误处理方式

D. Tool Restrictions and Guidance

D. 工具限制与指导

Ask:
  • "Should this command use any specific agents or tools?"
  • "Are there any tools or operations it should avoid?"
  • "Should it read any specific files for context?"
询问:
  • “这个命令是否应该使用特定的Agent或工具?”
  • “是否有任何工具或操作是需要避免的?”
  • “它是否需要读取特定文件以获取上下文?”

Step 4: Generate Optimized Command

步骤4:生成优化的命令

Create the command file with agent-optimized instructions. Load references/best-practices.md for:
  • Template structure
  • Best practices for agent execution
  • Writing style guidelines
  • Quality checklist
Key principles:
  • Use imperative/infinitive form (verb-first instructions)
  • Be explicit and specific
  • Include expected outcomes
  • Provide concrete examples
  • Define clear error handling
创建包含Agent优化执行说明的命令文件。加载references/best-practices.md获取以下内容:
  • 模板结构
  • Agent执行的最佳实践
  • 写作风格指南
  • 质量检查表
核心原则:
  • 使用祈使/不定式形式(以动词开头的说明)
  • 明确且具体
  • 包含预期结果
  • 提供具体示例
  • 定义清晰的错误处理

Step 5: Create the Command File

步骤5:创建命令文件

  1. Determine full file path:
    • Project:
      .claude/commands/[command-name].md
    • Global:
      ~/.claude/commands/[command-name].md
  2. Ensure directory exists:
    bash
    mkdir -p [directory-path]
  3. Write the command file using the Write tool
  4. Confirm with user:
    • Report the file location
    • Summarize what the command does
    • Explain how to use it:
      /command-name [arguments]
  1. 确定完整文件路径:
    • 项目级:
      .claude/commands/[command-name].md
    • 全局级:
      ~/.claude/commands/[command-name].md
  2. 确保目录存在:
    bash
    mkdir -p [directory-path]
  3. 使用Write工具写入命令文件
  4. 与用户确认:
    • 告知文件位置
    • 总结命令的作用
    • 说明使用方式:
      /command-name [arguments]

Step 6: Test and Iterate (Optional)

步骤6:测试与迭代(可选)

If the user wants to test:
  1. Suggest testing:
    You can test this command by running: /command-name [arguments]
  2. Be ready to iterate based on feedback
  3. Update the file with improvements as needed
如果用户想要测试:
  1. 建议测试:
    你可以通过运行以下命令测试此命令:/command-name [arguments]
  2. 随时根据反馈进行迭代
  3. 根据需要更新文件以优化内容

Quick Tips

快速提示

For detailed guidance, load the bundled references:
  • Load references/patterns.md when designing the command workflow
  • Load references/examples.md to see how existing commands are structured
  • Load references/best-practices.md before finalizing to ensure quality
Common patterns to remember:
  • Use Bash tool for
    pytest
    ,
    pyright
    ,
    ruff
    ,
    prettier
    ,
    make
    ,
    gt
    commands
  • Use Task tool to invoke subagents for specialized tasks
  • Check for specific files first (e.g.,
    .PLAN.md
    ) before proceeding
  • Mark todos complete immediately, not in batches
  • Include explicit error handling instructions
  • Define clear success criteria
如需详细指导,请加载附带的参考文档:
  • 设计命令工作流时,加载references/patterns.md
  • 查看现有命令结构时,加载references/examples.md
  • 最终确定前,加载references/best-practices.md以确保质量
需要记住的常见模式:
  • pytest
    pyright
    ruff
    prettier
    make
    gt
    命令使用Bash工具
  • 使用Task工具调用子Agent以执行专业任务
  • 先检查特定文件(例如
    .PLAN.md
    ),再继续执行后续步骤
  • 立即标记待办事项为完成,而非批量处理
  • 包含明确的错误处理说明
  • 定义清晰的成功标准

Summary

总结

When creating a command:
  1. Detect location (project vs global)
  2. Show patterns to frame the conversation
  3. Gather information (name, purpose, arguments, steps, tools)
  4. Generate optimized command with agent-executable instructions
  5. Create file at appropriate location
  6. Confirm and iterate as needed
Focus on creating commands that agents can execute autonomously, with clear steps, explicit tool usage, and proper error handling.
创建命令时:
  1. 检测位置(项目级 vs 全局级)
  2. 展示模式以引导对话
  3. 收集信息(名称、用途、参数、步骤、工具)
  4. 生成优化命令,包含Agent可自主执行的说明
  5. 在合适位置创建文件
  6. 确认并按需迭代
重点创建Agent可自主执行的命令,包含清晰的步骤、明确的工具使用说明和完善的错误处理机制。