skill-best-practices

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Skill Authoring Procedure

Skill创作流程

Follow these steps to generate a skill that adheres to the agentskills.io specification and progressive disclosure principles.
按照以下步骤生成符合agentskills.io规范和渐进式披露原则的技能。

Step 1: Initialize and Validate Metadata

步骤1:初始化并验证元数据

  1. Define a unique
    name
    : 1-64 characters, lowercase, numbers, and single hyphens only.
  2. Draft a
    description
    : Max 1,024 characters, written in the third person, including negative triggers.
  3. Execute Validation Script: Run the validation script to ensure compliance before proceeding:
    python3 scripts/validate-metadata.py --name "[name]" --description "[description]"
  4. If the script returns an error, self-correct the metadata based on the
    stderr
    output and re-run until successful.
  1. 定义唯一的
    name
    :1-64个字符,仅允许小写字母、数字和单个连字符。
  2. 撰写
    description
    :最多1024个字符,采用第三人称撰写,包含触发排除条件。
  3. 执行验证脚本:在继续之前运行验证脚本以确保合规:
    python3 scripts/validate-metadata.py --name "[name]" --description "[description]"
  4. 如果脚本返回错误,根据
    stderr
    输出自行修正元数据,重新运行直至成功。

Step 2: Structure the Directory

步骤2:构建目录结构

  1. Create the root directory using the validated
    name
    .
  2. Initialize the following subdirectories:
    • scripts/
      : For tiny CLI tools and deterministic logic.
    • references/
      : For flat (one-level deep) context like schemas or API docs.
    • assets/
      : For output templates, JSON schemas, or static files.
  3. Ensure no human-centric files (README.md, INSTALLATION.md) are created.
  1. 使用已验证的
    name
    创建根目录。
  2. 初始化以下子目录:
    • scripts/
      :用于小型CLI工具和确定性逻辑。
    • references/
      :用于扁平化(仅一层深度)的上下文内容,如模式或API文档。
    • assets/
      :用于输出模板、JSON模式或静态文件。
  3. 确保不创建以人为中心的文件(如README.md、INSTALLATION.md)。

Step 3: Draft Core Logic (SKILL.md)

步骤3:编写核心逻辑(SKILL.md)

  1. Use the template in
    assets/skill-template.md
    as the starting point.
  2. Write all instructions in the third-person imperative (e.g., "Extract the text," "Run the build").
  3. Enforce Progressive Disclosure:
    • Keep the main logic under 500 lines.
    • If a procedure requires a large schema or complex rule set, move it to
      references/
      .
    • Command the agent to read the specific file only when needed: "Read references/api-spec.md to identify the correct endpoint."
  1. assets/skill-template.md
    中的模板为起点。
  2. 所有说明均采用第三人称祈使语气(例如:"提取文本"、"运行构建命令")。
  3. 强制执行渐进式披露原则
    • 主逻辑内容控制在500行以内。
    • 如果某个流程需要大型模式或复杂规则集,将其移至
      references/
      目录下。
    • 仅在需要时指示Agent读取特定文件:"阅读references/api-spec.md以确定正确的端点。"

Step 4: Identify and Bundle Scripts

步骤4:识别并打包脚本

  1. Identify "fragile" tasks (regex, complex parsing, or repetitive boilerplate).
  2. Outline a single-purpose script for the
    scripts/
    directory.
  3. Ensure the script uses standard output (stdout/stderr) to communicate success or failure to the agent.
  1. 识别"易出错"任务(如正则表达式处理、复杂解析或重复的样板代码)。
  2. scripts/
    目录编写一个单一用途的脚本。
  3. 确保脚本使用标准输出(stdout/stderr)向Agent传达成功或失败状态。

Step 5: Final Logic Validation

步骤5:最终逻辑验证

  1. Review the
    SKILL.md
    for "hallucination gaps" (points where the agent is forced to guess).
  2. Verify all file paths are relative and use forward slashes (
    /
    ).
  3. Cross-reference the final output against
    references/checklist.md
    .
  1. 检查
    SKILL.md
    中是否存在"幻觉缺口"(即Agent被迫猜测的内容点)。
  2. 验证所有文件路径均为相对路径,并使用正斜杠(
    /
    )。
  3. 根据
    references/checklist.md
    交叉核对最终输出。

Error Handling

错误处理

  • Metadata Failure: If
    scripts/validate-metadata.py
    fails, identify the specific error (e.g., "STYLE ERROR") and rewrite the field to remove first/second person pronouns.
  • Context Bloat: If the draft exceeds 500 lines, extract the largest procedural block and move it to a file in
    references/
    .
  • 元数据验证失败:如果
    scripts/validate-metadata.py
    执行失败,识别具体错误类型(例如:"STYLE ERROR"),重写字段以移除第一/第二人称代词。
  • 上下文内容冗余:如果草稿超过500行,将最大的流程块提取并移至
    references/
    目录下的文件中。