create-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

创建Skill

Create Skill

目的

Purpose

创建新的skill文件,如果插件结构不存在则自动初始化。
Create a new skill file, and automatically initialize the plugin structure if it does not exist.

执行逻辑

Execution Logic

1. 检查插件结构

1. Check Plugin Structure

检查当前目录是否存在 .claude/ 目录
├─ 找到 → 继续到步骤3
└─ 未找到 → 进入步骤2
Check if the .claude/ directory exists in the current directory
├─ Found → Proceed to Step 3
└─ Not Found → Enter Step 2

2. 自动初始化插件(如需要)

2. Automatically Initialize Plugin (if required)

  1. 读取 init-plugin skill 获取结构知识
  2. 询问用户:"这个插件应该叫什么名字?"
  3. 验证名称格式(小写、连字符)
  4. 创建 .claude/ 结构:
    • .claude/skills/
    • .claude/agents/
    • .claude/commands/
    • .claude/hooks/hooks.json
  5. 继续到步骤3
  1. Read the init-plugin skill to obtain structure knowledge
  2. Ask the user: "What should this plugin be named?"
  3. Validate name format (lowercase, hyphen-separated)
  4. Create the .claude/ structure:
    • .claude/skills/
    • .claude/agents/
    • .claude/commands/
    • .claude/hooks/hooks.json
  5. Proceed to Step 3

3. 收集skill信息

3. Collect Skill Information

询问用户:
  1. "Skill名称?" (验证:小写、连字符、数字)
  2. "描述?"
  3. "需要哪些工具?(逗号分隔,或留空)"
Ask the user:
  1. "Skill name?" (Validation: lowercase, hyphen-separated, numbers allowed)
  2. "Description?"
  3. "Which tools are needed? (comma-separated, or leave blank)"

4. 创建skill

4. Create Skill

  1. 创建目录:
    .claude/skills/{skill-name}/
  2. 从模板生成 SKILL.md
  3. 插入用户输入(完全按用户提供的内容,不做修改)
  4. 显示成功消息
  1. Create directory:
    .claude/skills/{skill-name}/
  2. Generate SKILL.md from template
  3. Insert user input (exactly as provided, no modifications)
  4. Display success message

验证规则

Validation Rules

  • Skill名称格式:
    ^[a-z0-9-]+$
  • 不允许重复名称: 检查现有skills
  • 描述必需: 至少10个字符
  • Skill name format:
    ^[a-z0-9-]+$
  • Duplicate names not allowed: Check existing skills
  • Description required: At least 10 characters

成功输出

Success Output

✅ Skill已创建: {skill-name}
📁 位置: ./.claude/skills/{skill-name}/SKILL.md
🚀 该skill立即可用
✅ Skill created: {skill-name}
📁 Location: ./.claude/skills/{skill-name}/SKILL.md
🚀 This skill is ready to use immediately

错误处理

Error Handling

  • 名称格式无效 → 重新询问
  • 名称重复 → 提示并询问是否覆盖
  • 无写入权限 → 报告错误
  • Invalid name format → Ask again
  • Duplicate name → Prompt and ask if user wants to overwrite
  • No write permission → Report error

示例

Example

用户: "创建一个reddit-upvote skill"
执行流程:
  1. 检查 .claude/ → 未找到
  2. 询问插件名 → "reddit-automation"
  3. 创建 .claude/ 结构
  4. 询问skill信息:
    • 名称: reddit-upvote
    • 描述: Upvote Reddit posts
    • 工具: (留空)
  5. 创建 .claude/skills/reddit-upvote/SKILL.md
  6. 输出成功消息
User: "Create a reddit-upvote skill"
Execution Flow:
  1. Check .claude/ → Not found
  2. Ask plugin name → "reddit-automation"
  3. Create .claude/ structure
  4. Ask for skill information:
    • Name: reddit-upvote
    • Description: Upvote Reddit posts
    • Tools: (leave blank)
  5. Create .claude/skills/reddit-upvote/SKILL.md
  6. Output success message