write-a-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Writing Skills

编写Skill

Process

流程

  1. Gather requirements — 询问用户:
    • skill 覆盖什么 task/domain?
    • 应处理哪些具体 use cases?
    • 需要 executable scripts,还是只需要 instructions?
    • 是否有 reference materials 要包含?
  2. Draft the skill — 创建:
    • 带 concise instructions 的 SKILL.md
    • 如果内容超过 500 行,创建 additional reference files
    • 如果需要 deterministic operations,创建 utility scripts
  3. Review with user — 展示 draft 并询问:
    • 是否覆盖你的 use cases?
    • 是否缺失或不清楚?
    • 是否有 section 应更详细或更简短?
  1. 收集需求 — 询问用户:
    • Skill 覆盖什么任务/领域?
    • 应处理哪些具体用例?
    • 需要可执行脚本,还是仅需说明文档?
    • 是否有要包含的参考资料?
  2. 编写Skill草稿 — 创建:
    • 带有简洁说明的SKILL.md
    • 如果内容超过500行,创建额外的参考文件
    • 如果需要确定性操作,创建实用脚本
  3. 与用户评审 — 展示草稿并询问:
    • 是否覆盖了你的用例?
    • 是否有缺失或表述不清的内容?
    • 是否有章节需要更详细或更简洁?

Skill Structure

Skill结构

skill-name/
├── SKILL.md           # Main instructions (required)
├── REFERENCE.md       # Detailed docs (if needed)
├── EXAMPLES.md        # Usage examples (if needed)
└── scripts/           # Utility scripts (if needed)
    └── helper.js
skill-name/
├── SKILL.md           # 主说明文档(必填)
├── REFERENCE.md       # 详细文档(如有需要)
├── EXAMPLES.md        # 使用示例(如有需要)
└── scripts/           # 实用脚本(如有需要)
    └── helper.js

SKILL.md Template

SKILL.md模板

md
---
name: skill-name
description: Brief description of capability. Use when [specific triggers].
---
md
---
name: skill-name
description: 功能简要描述。在[特定触发场景]时使用。
---

Skill Name

Skill名称

Quick start

快速开始

[Minimal working example]
[最简可用示例]

Workflows

工作流程

[Step-by-step processes with checklists for complex tasks]
[针对复杂任务的分步流程及检查清单]

Advanced features

高级功能

[Link to separate files: See REFERENCE.md]
undefined
[链接至独立文件:详见REFERENCE.md]
undefined

Description Requirements

描述要求

description 是 agent 决定是否加载 skill 时唯一看到的内容。它会和其他 installed skills 一起出现在 system prompt 中。agent 会读取这些 descriptions,并根据用户请求选择相关 skill。
Goal:给 agent 足够信息,让它知道:
  1. 这个 skill 提供什么 capability
  2. 何时/为什么触发它(specific keywords、contexts、file types)
Format
  • 最多 1024 chars
  • 使用 third person
  • 第一句说明它做什么
  • 第二句:"Use when [specific triggers]"
Good example
Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when user mentions PDFs, forms, or document extraction.
Bad example
Helps with documents.
坏例子无法让 agent 区分它和其他 document skills。
description是Agent决定是否加载Skill时唯一看到的内容。它会和其他已安装的Skills一同出现在系统提示词中。Agent会读取这些描述,并根据用户请求选择相关Skill。
目标:为Agent提供足够信息,使其明确:
  1. 该Skill具备什么功能
  2. 何时/为何触发它(特定关键词、场景、文件类型)
格式
  • 最多1024字符
  • 使用第三人称
  • 第一句说明功能
  • 第二句:"Use when [specific triggers]"
优秀示例
Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when user mentions PDFs, forms, or document extraction.
反面示例
Helps with documents.
反面示例无法让Agent区分它与其他文档类Skill。

When to Add Scripts

何时添加脚本

以下情况添加 utility scripts:
  • Operation 是 deterministic(validation、formatting)
  • 同一段 code 会被反复生成
  • Errors 需要明确 handling
相比 generated code,scripts 节省 tokens 并提升 reliability。
以下情况添加实用脚本:
  • 操作具有确定性(验证、格式化)
  • 同一段代码会被反复生成
  • 需要明确处理错误
相比生成的代码,脚本可节省token并提升可靠性。

When to Split Files

何时拆分文件

以下情况拆分为独立文件:
  • SKILL.md 超过 100 行
  • 内容有不同 domains(finance vs sales schemas)
  • Advanced features 很少需要
以下情况拆分为独立文件:
  • SKILL.md超过100行
  • 内容涉及不同领域(如财务与销售架构)
  • 高级功能很少被用到

Review Checklist

评审检查清单

draft 完成后验证:
  • Description 包含 triggers("Use when...")
  • SKILL.md 低于 100 行
  • 没有 time-sensitive info
  • Terminology 一致
  • 包含 concrete examples
  • References 只深入一层
草稿完成后验证:
  • Description包含触发条件("Use when...")
  • SKILL.md少于100行
  • 无时效性信息
  • 术语表述一致
  • 包含具体示例
  • 参考内容仅深入一层