如何安装 skills-ref 并完成 Agent Skills 技能首次校验【免费下载链接】agentskillsSpecification and documentation for Agent Skills项目地址: https://gitcode.com/GitHub_Trending/ag/agentskills你写好了一个 Agent Skill一个包含SKILL.md的文件夹需要确认它的 frontmatter 合法、命名符合规范再交给 agent 使用。agentskills 仓库中的skills-ref参考库提供了skills-ref validate命令完成这次首次校验。本文流程在 Python 虚拟环境中安装 skills-ref准备一个待校验的技能目录运行校验命令并根据输出和退出码判断结果。前提条件与限制Python 3.11 及以上。skills-ref/pyproject.toml 声明requires-python 3.11依赖click8.0和strictyaml1.7.3会在安装时自动解析。skills-ref 的 README 明确说明该库仅供演示demonstration purposes only不打算用于生产环境。以下命令都在 agentskills 仓库的skills-ref/目录内执行pip install -e .和uv sync都以该目录下的pyproject.toml为项目根。安装 skills-refmacOS / Linuxpippython -m venv .venv source .venv/bin/activate pip install -e .macOS / Linuxuv可选替代uv sync source .venv/bin/activateWindowspipPowerShellpython -m venv .venv .venv\Scripts\Activate.ps1 pip install -e .Command Promptpython -m venv .venv .venv\Scripts\activate.bat pip install -e .Windows 使用 uvPowerShelluv sync .venv\Scripts\Activate.ps1安装成功的判断标准来自 README在激活的虚拟环境中skills-ref可执行文件会出现在PATH上。安装完成后直接进入下面的校验步骤即可确认它可用。准备待校验的技能一个技能是一个包含SKILL.md的文件夹SKILL.md必须由 YAML frontmatter 开头后接 Markdown 正文正文本身没有格式限制见 specification。首次校验只检查 frontmatter 和命名规则要求name必填最长 64 个字符只允许小写字母、数字和连字符不能以连字符开头或结尾且必须与所在目录名一致description必填非空最长 1024 个字符frontmatter 中只接受name、description、license、allowed-tools、metadata、compatibility这些字段出现其他字段会被判为校验错误compatibility若填写最长 500 个字符。如果还没有现成的技能可以直接用 Quickstart 中的roll-dice技能作为首次校验对象。创建目录roll-dice/写入roll-dice/SKILL.md--- name: roll-dice description: Roll dice using a random number generator. Use when asked to roll a die (d6, d20, etc.), roll dice, or generate a random dice roll. --- To roll a die, use the following command that generates a random number from 1 to the given number of sides: bash echo $((RANDOM % sides 1)) 正文中的sides是技能指令内部给 agent 运行时替换的占位符Quickstart 文档说明了替换方式不是安装或校验前需要处理的模板变量——校验不解析正文内容。执行首次校验在激活虚拟环境的 shell 中对技能目录运行skills-ref validate roll-dice换成自己的技能时把参数换成技能目录路径例如 specification 中给出的形式skills-ref validate ./my-skill参数要求来自 CLI 实现路径必须存在可以指向技能目录也可以直接指向目录内的SKILL.md文件小写skill.md也识别直接指向文件时命令会自动改用其父目录退出码0表示技能有效1表示发现校验错误。判读校验结果成功时退出码 0输出形如Valid skill: roll-dice失败时退出码 1输出Validation failed for 路径:随后每条错误单独一行例如Validation failed for my-skill: - Skill name MySkill must be lowercase以上是按源码中实际的消息格式构造的示例结果你的输出取决于具体的技能内容。出现失败时按下面的对照表定位原因消息文本来自 validator.py 与 parser.py输出中的错误行对应原因Missing required file: SKILL.md目录里没有SKILL.md或小写skill.mdSKILL.md must start with YAML frontmatter (---)文件开头不是---SKILL.md frontmatter not properly closed with ---frontmatter 没有用---闭合Invalid YAML in frontmatter: ...frontmatter 的 YAML 语法不合法Missing required field in frontmatter: name/...: description缺少必填字段Skill name ... exceeds 64 character limitname超过 64 个字符Skill name ... must be lowercasename含大写字母Skill name cannot start or end with a hyphenname以连字符开头或结尾Skill name cannot contain consecutive hyphensname含连续连字符Skill name ... contains invalid characters. ...name含字母、数字、连字符以外的字符Directory name ... must match skill name ...目录名与name不一致比较前双方都做 Unicode NFKC 规范化Description exceeds 1024 character limitdescription超过 1024 个字符Compatibility exceeds 500 character limitcompatibility超过 500 个字符Unexpected fields in frontmatter: ...frontmatter 出现了允许列表之外的字段这些规则在 tests/test_validator.py 中有对应的测试用例可以对照阅读每种失败的具体形态。用 read-properties 交叉核对可选校验通过后可以用第二条命令确认 frontmatter 实际被解析成了什么skills-ref read-properties roll-dice它会解析SKILL.md的 YAML frontmatter 并以 JSON 输出技能属性name、description及可选字段。退出码0表示成功1表示解析错误失败时输出Error: ...。这条命令不做完整校验只反映 agent 发现技能时读取的元数据。限制与下一步skills-ref validate检查的是 frontmatter 的合法性与命名规范SKILL.md正文没有格式限制校验不检查正文内容也不检查技能实际能否完成任务。skills-ref是参考实现仅供演示生产用途请使用其他工具链。下一步技能校验通过后可以用skills-ref to-prompt 技能目录 [更多技能目录]生成available_skillsXML 块放入 agent 的系统提示词该格式推荐给 Anthropic 的模型其他 Skill Client 可以自行调整格式见 skills-ref README。【免费下载链接】agentskillsSpecification and documentation for Agent Skills项目地址: https://gitcode.com/GitHub_Trending/ag/agentskills创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考