技能最佳实践
- 作者仓库星标 2,143
- 作者仓库 compozy
- 领域
- 文档
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @compozy · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 命令执行
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
定义唯一的`name`:仅限 1-64 个字符、小写字母、数字和单个连字符。起草`description`:最多 1,024 个字符,以第三人称书写,包括负面触发器。执行验证脚本:在继续之前运行验证脚本以确保合规性:`python3 scripts/validate-metadata.py --name "[name]" --description "[description]"`如果脚本返回错误,请根据`stderr`输出自行更正元数据并重新运行,直到成功。
使用经过验证的`name`创建根目录。初始化以下子目录: `scripts/`:用于小型 CLI 工具和确定性逻辑。 `references/`:适用于扁平(一层深)上下文,如模式或 API 文档。 `assets/`:用于输出模板、JSON 模式或静态文件。
使用`assets/skill-template.md`中的模板作为起点。用第三人称命令编写所有指令(例如“提取文本”、“运行构建”)。强制渐进式披露:将主要逻辑控制在 500 行以下。如果过程需要大型模式或复杂的规则集,请将其移至`references/`。
识别“脆弱”任务(正则表达式、复杂解析或重复的样板文件)。概述 `scripts/` 目录的单一用途脚本。确保脚本使用标准输出 (stdout/stderr) 向代理传达成功或失败信息。
查看`SKILL.md` 的“幻觉间隙”(智能体被迫猜测的点)。验证所有文件路径都是相对的并使用正斜杠 (`/`)。将最终输出与`references/checklist.md`交叉引用。
# Skill Authoring Procedure
Follow these steps to generate a skill that adheres to the agentskills.io specification and progressive disclosure principles.
## Step 1: Initialize and Validate Metadata
1. Define a unique `name`: 1-64 characters, lowercase, numbers, and single hyphens only.
2. Draft a `description`: Max 1,024 characters, written in the third person, including negative triggers.
3. **Execute Validation Script:** Run the validation script to ensure compliance before proceeding:
`python3 scripts/validate-metadata.py --name "[name]" --description "[description]"`
4. If the script returns an error, self-correct the metadata based on the `stderr` output and re-run until successful.
## Step 2: Structure the Directory
1. Create the root directory using the validated `name`.
2. Initialize the following subdirectories:
* `scripts/`: For tiny CLI tools and deterministic logic.
* `references/`: For flat (one-level deep) context like schemas or API docs.
* `assets/`: For output templates, JSON schemas, or static files.
3. Ensure no human-centric files (README.md, INSTALLATION.md) are created.
## Step 3: Draft Core Logic (SKILL.md)
1. Use the template in `assets/skill-template.md` as the starting point.
2. Write all instructions in the **third-person imperative** (e.g., "Extract the text," "Run the build").
3. **Enforce Progressive Disclosure:**
* Keep the main logic under 500 lines.
* If a procedure requires a large schema or complex rule set, move it to `references/`.
* Command the agent to read the specific file only when needed: *"Read references/api-spec.md to identify the correct endpoint."*
## Step 4: Identify and Bundle Scripts
1. Identify "fragile" tasks (regex, complex parsing, or repetitive boilerplate).
2. Outline a single-purpose script for the `scripts/` directory.
3. Ensure the script uses standard output (stdout/stderr) to communicate success or failure to the agent.
## Step 5: Final Logic Validation
1. Review the `SKILL.md` for "hallucination gaps" (points where the agent is forced to guess).
2. Verify all file paths are **relative** and use forward slashes (`/`).
3. Cross-reference the final output against `references/checklist.md`.
## Error Handling
* **Metadata Failure:** If `scripts/validate-metadata.py` fails, identify the specific error (e.g., "STYLE ERROR") and rewrite the field to remove first/second person pronouns.
* **Context Bloat:** If the draft exceeds 500 lines, extract the largest procedural block and move it to a file in `references/`.
按说明文件中的顺序排列。
第 1 步:初始化并验证元数据
第 2 步:构建目录
步骤 3:起草核心逻辑 (SKILL.md)
第 4 步:识别并捆绑脚本
第 5 步:最终逻辑验证
文件/命令 -> name · description · python3 scripts/validate-metadata.py --name "[name]" --description "[description]" · stderr · scripts/ · references/ · assets/ · assets/skill-template.md
内容校验值 -> 58cdb083531b
当前原文的自动摘译,尚未人工审校。
第 2 步:构建目录
使用经过验证的
name创建根目录。初始化以下子目录:scripts/:用于微型 CLI 工具和确定性逻辑。references/:适用于扁平(一层深)上下文,如模式或 API 文档。assets/:用于输出模板、JSON 模式或静态文件。