文档
Canonical Skill Spec
Canonical Skill Spec 是一份与厂商无关的 JSON 结构。它只描述「做什么」,不描述「怎么说」。渲染到具体模型时,Adapter 负责把语义转换成该模型偏好的写法。
核心字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | kebab-case 技能 ID,如 code-reviewer |
| name | string | 技能展示名 |
| purpose | string | 一句话说明技能做什么 |
| persona | string? | 身份 / 角色设定(可选) |
| whenToUse | string? | 激活条件,供 Claude / Custom GPT 判断何时调用 |
| steps | string[] | 执行步骤,按顺序渲染 |
| inputs | FieldSchema[] | 输入字段(name / type / description / required) |
| output | OutputContract | 输出契约:format + fields + constraints |
| constraints | string[]? | 硬约束(「禁止...」/「必须...」) |
| examples | ShotExample[]? | Few-shot 示例,推理模型会自动剥离 reasoning |
| tools | ToolSpec[]? | 可调用的工具/函数 |
| knowledge | {title,content}[]? | 长背景文档,Kimi/Gemini 会内联,Claude 建议渐进披露 |
示例 Spec
json
{
"id": "code-reviewer",
"name": "代码审查助手",
"purpose": "对代码进行多维度 Code Review 并产出结构化结果。",
"persona": "一位严格但友好的资深工程师。",
"whenToUse": "当用户贴出代码并要求 review 时调用此技能。",
"steps": [
"理解代码意图",
"从 readability / performance / security / maintainability 四个维度找问题",
"给出严重度与 minimal diff 建议",
"给出一句话总体结论"
],
"inputs": [
{ "name": "language", "type": "string", "description": "代码语言", "required": true },
{ "name": "code", "type": "string", "description": "代码正文", "required": true }
],
"constraints": [
"不要重写整份代码",
"代码质量已好时如实回答,不要硬挑"
],
"output": {
"format": "json",
"fields": [
{ "name": "issues", "type": "object", "description": "数组:dimension/severity/description/suggestion" },
{ "name": "summary", "type": "string", "description": "总结" }
]
},
"examples": [
{
"input": "function sum(a,b){return a+b}",
"reasoning": "简单工具函数,仅缺类型注解",
"output": "{\"issues\":[...],\"summary\":\"...\"}"
}
]
}TIP
reasoning 字段只会被渲染到非推理模型;推理模型(o1 / R1 / QwQ)会自动剥离,避免干扰原生 CoT。