generate_command

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create a Custom Claude Code Command

创建自定义Claude代码命令

Create a new skill in
.claude/skills/
for the requested task.
.claude/skills/
目录下为所需任务创建一个新的Skill。

Goal

目标

#$ARGUMENTS
#$ARGUMENTS

Key Capabilities to Leverage

可利用的核心功能

File Operations:
  • Read, Edit, Write - modify files precisely
  • Glob, Grep - search codebase
  • MultiEdit - atomic multi-part changes
Development:
  • Bash - run commands (git, tests, linters)
  • Task - launch specialized agents for complex tasks
  • TodoWrite - track progress with todo lists
Web & APIs:
  • WebFetch, WebSearch - research documentation
  • GitHub (gh cli) - PRs, issues, reviews
  • Playwright - browser automation, screenshots
Integrations:
  • AppSignal - logs and monitoring
  • Context7 - framework docs
  • Stripe, Todoist, Featurebase (if relevant)
文件操作:
  • Read、Edit、Write - 精准修改文件
  • Glob、Grep - 搜索代码库
  • MultiEdit - 原子化多部分修改
开发工具:
  • Bash - 运行命令(git、测试、代码检查工具)
  • Task - 为复杂任务启动专用Agent
  • TodoWrite - 用待办事项列表跟踪进度
Web与API:
  • WebFetch、WebSearch - 查阅文档
  • GitHub (gh cli) - 拉取请求、问题、评审
  • Playwright - 浏览器自动化、截图
集成工具:
  • AppSignal - 日志与监控
  • Context7 - 框架文档
  • Stripe、Todoist、Featurebase(如相关)

Best Practices

最佳实践

  1. Be specific and clear - detailed instructions yield better results
  2. Break down complex tasks - use step-by-step plans
  3. Use examples - reference existing code patterns
  4. Include success criteria - tests pass, linting clean, etc.
  5. Think first - use "think hard" or "plan" keywords for complex problems
  6. Iterate - guide the process step by step
  1. 明确具体 - 详细的指令能带来更好的结果
  2. 拆分复杂任务 - 使用分步计划
  3. 使用示例 - 参考现有代码模式
  4. 包含成功标准 - 测试通过、代码检查无问题等
  5. 先思考 - 针对复杂问题使用"think hard"或"plan"关键词
  6. 迭代优化 - 逐步引导流程

Required: YAML Frontmatter

必填:YAML前置元数据

EVERY command MUST start with YAML frontmatter:
yaml
---
name: command-name
description: Brief description of what this command does (max 100 chars)
argument-hint: "[what arguments the command accepts]"
---
Fields:
  • name
    : Lowercase command identifier (used internally)
  • description
    : Clear, concise summary of command purpose
  • argument-hint
    : Shows user what arguments are expected (e.g.,
    [file path]
    ,
    [PR number]
    ,
    [optional: format]
    )
每个命令都必须以YAML前置元数据开头:
yaml
---
name: command-name
description: Brief description of what this command does (max 100 chars)
argument-hint: "[what arguments the command accepts]"
---
字段说明:
  • name
    : 小写命令标识符(内部使用)
  • description
    : 清晰、简洁的命令用途概述(最多100字符)
  • argument-hint
    : 向用户展示所需参数(例如
    [文件路径]
    [PR编号]
    [可选:格式]

Structure Your Command

命令结构

markdown
undefined
markdown
undefined

[Command Name]

[命令名称]

[Brief description of what this command does]
[命令功能的简短描述]

Steps

步骤

  1. [First step with specific details]
    • Include file paths, patterns, or constraints
    • Reference existing code if applicable
  2. [Second step]
    • Use parallel tool calls when possible
    • Check/verify results
  3. [Final steps]
    • Run tests
    • Lint code
    • Commit changes (if appropriate)
  1. [第一步,包含具体细节]
    • 包含文件路径、模式或约束条件
    • 如有需要,参考现有代码
  2. [第二步]
    • 尽可能使用并行工具调用
    • 检查/验证结果
  3. [最终步骤]
    • 运行测试
    • 代码检查
    • 提交变更(如适用)

Success Criteria

成功标准

  • Tests pass
  • Code follows style guide
  • Documentation updated (if needed)
undefined
  • 测试通过
  • 代码遵循风格指南
  • 文档已更新(如需要)
undefined

Tips for Effective Commands

高效命令编写技巧

  • Use $ARGUMENTS placeholder for dynamic inputs
  • Reference CLAUDE.md patterns and conventions
  • Include verification steps - tests, linting, visual checks
  • Be explicit about constraints - don't modify X, use pattern Y
  • Use XML tags for structured prompts:
    <task>
    ,
    <requirements>
    ,
    <constraints>
  • 使用$ARGUMENTS作为动态输入的占位符
  • 参考CLAUDE.md中的模式与规范
  • 包含验证步骤 - 测试、代码检查、视觉检查
  • 明确约束条件 - 不要修改X、使用模式Y
  • 使用XML标签构建结构化提示:
    <task>
    <requirements>
    <constraints>

Example Pattern

示例模板

markdown
Implement #$ARGUMENTS following these steps:

1. Research existing patterns
   - Search for similar code using Grep
   - Read relevant files to understand approach

2. Plan the implementation
   - Think through edge cases and requirements
   - Consider test cases needed

3. Implement
   - Follow existing code patterns (reference specific files)
   - Write tests first if doing TDD
   - Ensure code follows CLAUDE.md conventions

4. Verify
   - Run tests: `bin/rails test`
   - Run linter: `bundle exec standardrb`
   - Check changes with git diff

5. Commit (optional)
   - Stage changes
   - Write clear commit message
markdown
按照以下步骤实现#$ARGUMENTS:

1. 研究现有模式
   - 使用Grep搜索相似代码
   - 阅读相关文件以了解实现方式

2. 规划实现方案
   - 仔细考虑边缘情况与需求
   - 思考所需的测试用例

3. 开发实现
   - 遵循现有代码模式(参考具体文件)
   - 如果采用TDD,先编写测试
   - 确保代码遵循CLAUDE.md规范

4. 验证结果
   - 运行测试:`bin/rails test`
   - 运行代码检查工具:`bundle exec standardrb`
   - 使用git diff检查变更

5. 提交(可选)
   - 暂存变更
   - 编写清晰的提交信息

Creating the Command File

创建命令文件

  1. Create the directory at
    .claude/skills/[name]/SKILL.md
  2. Start with YAML frontmatter (see section above)
  3. Structure the skill using the template above
  4. Test the skill by using it with appropriate arguments
  1. 创建目录
    .claude/skills/[name]/SKILL.md
  2. 添加YAML前置元数据(见上文章节)
  3. 使用上述模板构建Skill结构
  4. 使用合适的参数测试该Skill

Command File Template

命令文件模板

markdown
---
name: command-name
description: What this command does
argument-hint: "[expected arguments]"
---
markdown
---
name: command-name
description: What this command does
argument-hint: "[expected arguments]"
---

Command Title

命令标题

Brief introduction of what the command does and when to use it.
命令功能及使用场景的简短介绍。

Workflow

工作流程

Step 1: [First Major Step]

步骤1:[主要步骤1]

Details about what to do.
具体操作说明。

Step 2: [Second Major Step]

步骤2:[主要步骤2]

Details about what to do.
具体操作说明。

Success Criteria

成功标准

  • Expected outcome 1
  • Expected outcome 2
undefined
  • 预期结果1
  • 预期结果2
undefined