---name:skill-creatordescription:|
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends agent capabilities with specialized knowledge, workflows, or tool integrations.
license:CompletetermsinLICENSE.txt---
name 和 description 是唯一必需的字段
description 必须同时说明"技能做什么"和"何时使用它"
所有"何时使用"的信息必须放在 description 中,因为 body 只在 Skill 触发后才加载
2.2 Body 正文结构
正文使用祈使形式(imperative form),直接给出指令而非建议。例如:
'Challenge each piece of information' 质疑每一条信息
'Prefer concise examples over verbose explanations' 用简洁的例子替代冗长的解释
三、从源码提炼的 7 大核心原则
原则 1:上下文窗口是公共资源(Concise is Key)
源码原文:
'The context window is a public good. Skills share the context window with everything else the agent needs: system prompt, conversation history, other Skills' metadata, and the actual user request.'
解读:
Skill 与系统提示、对话历史、其他 Skill 元数据、用户请求共享上下文窗口
每个词都要有价值,不断质疑:"AI 真的需要这个解释吗?"
默认假设 AI 已经很智能,只添加它不知道的信息
实践建议:
用简洁示例替代冗长解释
SKILL.md 正文保持在 500 行以内
接近限制时将内容拆分到 references/
原则 2:设置适当的自由度(Degrees of Freedom)
源码原文:
'Match the level of specificity to the task's fragility and variability'
**解读:**根据任务的脆弱性和可变性,匹配合适的约束级别:
自由度级别
适用场景
实现方式
高自由度
多种方法有效、依赖上下文决策
文本指令
中自由度
有推荐模式、可接受变化
伪代码或带参数的脚本
低自由度
操作脆弱易错、一致性关键
特定脚本、最少参数
原则 3:渐进式披露设计(Progressive Disclosure)
源码原文:
'Skills use a three-level loading system to manage context efficiently'
'A skill should only contain essential files that directly support its functionality. Do NOT create extraneous documentation or auxiliary files, including: README.md, INSTALLATION_GUIDE.md, QUICK_REFERENCE.md, CHANGELOG.md, etc.'
解读:
Skill 只应包含 AI Agent 完成工作所需的信息
不应包含创建过程的辅助上下文、设置和测试程序、面向用户的文档
额外的文档只会增加混乱
原则 5:编写高质量的 description
源码原文:
'Only name and description are read by the agent to determine when the skill triggers, so be clear and comprehensive about what the skill is and when it should be used.'
好的 description 示例(来自 docx Skill):
description:|
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. Use when the agent needs to work with professional documents (.docx files) for:
(1) Creating new documents,
(2) Modifying or editing content,
(3) Working with tracked changes,
(4) Adding comments,
or any other document tasks
差的 description 示例:
description:"Helps with PDFs"
要点:
同时包含"功能描述"和"触发场景"
所有"何时使用"信息都放在 description 中
Body 只在触发后加载,所以 body 中的"何时使用"对 AI 没有帮助
原则 6:使用祈使/不定式形式
源码原文(Writing Guidelines):
'Always use imperative/infinitive form' (始终使用祈使句/动词原形形式)
推荐写法:
'Run the script to check dependencies' (运行该脚本以检查依赖项)
'Extract text using pandoc' (使用 pandoc 提取文本)
'Validate page count before merging PDFs' (在合并 PDF 文件之前先验证页数数量)
避免写法:
'You should run the script to check dependencies' (您应该运行该脚本以检查依赖项)
'We can use pandoc to extract text' (我们可以使用 pandoc 来提取文本)
'I recommend validating the page count' (我建议确认页面数量)
原则 7:避免信息重复
源码原文(Avoid duplication):
'Information should live in either SKILL.md or references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window.'
解读:
信息只应存在于一处
详细信息优先放在 references/
SKILL.md 只保留核心程序指令和工作流指导
四、Skill 创建的 6 步流程(源自源码)
skill-creator 的 SKILL.md 明确给出了创建 Skill 的 6 个步骤:
步骤 1:通过具体示例理解 Skill
源码原文:
'To create an effective skill, clearly understand concrete examples of how the skill will be used.'
实践方法:
询问:"这个 Skill 应该支持什么功能?"
询问:"你能给出一些使用示例吗?"
询问:"用户会说什么来触发这个 Skill?"
**示例:**构建 image-editor Skill 时:
'移除这张图片的红眼'
'将图片旋转 90 度'
'调整图片亮度'
步骤 2:规划可复用的 Skill 内容
源码原文:
'To turn concrete examples into an effective skill, analyze each example by: Considering how to execute on the example from scratch; Identifying what scripts, references, and assets would be helpful'
Skill 类型
示例查询
可复用资源
pdf-editor
'帮我旋转这个 PDF'
scripts/rotate_pdf.py
webapp-builder
'构建一个待办应用'
assets/hello-world/模板
big-query
'今天有多少用户登录?'
references/schema.md
步骤 3:初始化 Skill
源码原文:
'When creating a new skill from scratch, always run the init_skill.py script.'
'After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.'
迭代流程:
在真实任务中使用 Skill
注意困难或低效的地方
识别 SKILL.md 或资源的更新点
实现更改并再次测试
五、Agent Skills 开放标准
5.1 什么是 Agent Skills?
Agent Skills 是一个开放标准(agentskills.io),最初由 Anthropic 开发,现已被多个 AI 工具采纳:OpenCode,Claude Code,Cursor,GitHub Copilot,Ampcode,trae
5.2 标准规范要点
目录结构:
skill-name/
└── SKILL.md # 必需
可选目录:
scripts/ - 可执行代码
references/ - 参考文档
assets/ - 静态资源
SKILL.md 格式:
---name:skill-name# 必需,1-64 字符description:Whatthisskilldoes# 必需,1-1024 字符license:Apache-2.0# 可选compatibility:Requirements# 可选,1-500 字符metadata:author:example-orgversion:"1.0"---# Markdown body with instructions
#!/usr/bin/env python3"""
提取 Word 文档中的文本内容
用法:python extract_text.py <document.docx>
输出:生成与输入文件同名的 .txt 文件
"""import sys
from docx import Document
defextract_text(docx_path: str) -> str:
"""从 Word 文档中提取所有文本"""
doc = Document(docx_path)
# 收集所有段落的文本
paragraphs = []
for para in doc.paragraphs:
if para.text.strip():
# 跳过空段落
paragraphs.append(para.text)
# 收集表格中的文本
tables_text = []
for table in doc.tables:
table_rows = []
for row in table.rows:
row_text = [cell.text.strip() for cell in row.cells]
table_rows.append(' | '.join(row_text))
tables_text.append('\n'.join(table_rows))
# 组合所有文本
result = '\n\n'.join(paragraphs)
if tables_text:
result += '\n\n=== 表格内容 ===\n\n'
result += '\n\n'.join(tables_text)
return result
defmain():
iflen(sys.argv) != 2:
print('用法:python extract_text.py <document.docx>')
print('示例:python extract_text.py report.docx')
sys.exit(1)
docx_path = sys.argv[1]
try:
text = extract_text(docx_path)
# 生成输出文件名
output_path = docx_path.replace('.docx', '.txt')
# 写入文件withopen(output_path, 'w', encoding='utf-8') as f:
f.write(text)
print(f'文本已提取:{output_path}')
print(f'共 {len(text)} 个字符')
except FileNotFoundError:
print(f'错误:找不到文件 {docx_path}')
sys.exit(1)
except Exception as e:
print(f'错误:{e}')
sys.exit(1)
if __name__ == '__main__':
main()
6.6 references/ooxml-reference.md
# OOXML 参考指南
本文档提供 Office Open XML (OOXML) 格式的技术参考,用于深度操作 Word 文档。
## 什么是 OOXML?
OOXML 是 Microsoft Office 2007 及以后版本使用的基于 XML 的文档格式。.docx 文件实际上是一个 ZIP 压缩包,包含多个 XML 文件。
## 文档结构