示例
Skill 模板示例
一个实用的起步模板,用来打包可复用的 agent 经验。
推荐结构
my-skill/
├── SKILL.md
├── references/
│ ├── domain-rules.md
│ └── examples.md
├── scripts/
│ └── validate-output.js
└── assets/
└── report-template.mdSKILL.md 起步模板
---
name: my-skill
description: 说明这个 Skill 处理什么样的用户任务,包括动作动词和期望产物。
compatibility:
runtimes:
- node >= 18
---
# 我的 Skill
当 ...
不要在 ... 的时候使用这个 Skill。
## 工作流
1. 检查输入并找出缺失信息。
2. 按下面的流程执行。
3. 如果用户要报告,就使用输出模板。
4. 在回复前验证结果。
## 参考
- 当任务涉及领域规则时,读取 `references/domain-rules.md`。
- 如果输出格式不清楚,读取 `references/examples.md`。
## 脚本
- 在交付结构化文件前,运行 `node scripts/validate-output.js --file PATH`。
## 输出
最终报告遵循 `assets/report-template.md`。参考文件示例
当领域规则有用但太详细,不适合放进主指令时,可以放到 references 里。
# references/domain-rules.md ## 严重性等级 - Critical:用户数据丢失、安全暴露、支付失败或生产事故。 - High:核心流程坏了,而且没有简单绕行办法。 - Medium:流程变差,但还有替代办法。 - Low:视觉问题、文案问题或轻微体验问题。 ## 升级规则 如果严重性是 Critical 或 High,就在最终报告里写清楚负责人和下一步动作。
资产模板示例
如果最终答案必须遵守稳定结构,assets 会很有用。
# assets/report-template.md ## 摘要 ## 发现 | 严重性 | 发现 | 证据 | 建议 | | --- | --- | --- | --- | ## 未解决问题 ## 下一步
验证脚本示例
脚本应当非交互,并尽可能给出机器可读输出。
// scripts/validate-output.js
import fs from "node:fs"
const fileIndex = process.argv.indexOf("--file")
const file = fileIndex >= 0 ? process.argv[fileIndex + 1] : null
if (!file) {
console.error(JSON.stringify({ ok: false, error: "缺少 --file PATH" }))
process.exit(1)
}
const text = fs.readFileSync(file, "utf8")
const required = ["## 摘要", "## 发现", "## 未解决问题", "## 下一步"]
const missing = required.filter((section) => !text.includes(section))
console.log(JSON.stringify({ ok: missing.length === 0, missing }, null, 2))
process.exit(missing.length === 0 ? 0 : 1)发布前检查
激活测试多个应该触发和不应该触发的提示词。
上下文把
SKILL.md 里过长的细节挪出去并按条件引用。脚本让脚本保持非交互,并给出清楚错误。
评估用真实案例跑 Skill 并保存失败点。