技能创建器(中文版)
此技能提供创建高效技能的指导。
关于技能
技能是模块化、独立的包,通过提供专业知识、工作流程和工具来扩展 Claude 的能力。可以把它们想象成特定领域或任务的"入职指南"——它们将 Claude 从通用助手转变为具备程序性知识的专业助手,而这些知识是任何模型都无法完全具备的。
技能提供的内容
- 专业工作流程 - 特定领域的多步骤流程
- 工具集成 - 处理特定文件格式或 API 的指令
- 领域专业知识 - 公司特定知识、数据模式、业务逻辑
- 捆绑资源 - 用于复杂和重复任务的脚本、参考资料和素材
技能的结构
每个技能由一个必需的 SKILL.md 文件和可选的捆绑资源组成:
skill-name/ (技能名称/)
├── SKILL.md (必需)
│ ├── YAML 前置元数据 (必需)
│ │ ├── name: (必需) 名称
│ │ └── description: (必需) 描述
│ └── Markdown 指令 (必需)
└── 捆绑资源 (可选)
├── scripts/ - 可执行代码(Python/Bash 等)
├── references/ - 需要时加载到上下文的文档
└── assets/ - 输出中使用的文件(模板、图标、字体等)
SKILL.md(必需)
元数据质量: YAML 前置元数据中的 name 和 description 决定了 Claude 何时使用该技能。要具体说明技能的功能和使用时机。使用第三人称(例如"此技能应在...时使用"而不是"当...时使用此技能")。
捆绑资源(可选)
脚本(scripts/)
可执行代码(Python/Bash 等),用于需要确定性可靠性或重复编写的任务。
- 何时包含:当相同代码需要重复编写或需要确定性可靠性时
- 示例:
scripts/rotate_pdf.py 用于 PDF 旋转任务
- 优点:节省令牌、确定性、可在不加载到上下文的情况下执行
- 注意:脚本可能仍需要被 Claude 读取以进行修补或环境特定调整
参考资料(references/)
文档和参考材料,用于在需要时加载到上下文中,以指导 Claude 的处理过程和思考。
- 何时包含:当 Claude 在工作时需要参考的文档
- 示例:
references/finance.md 用于财务模式、references/mnda.md 用于公司保密协议模板、references/policies.md 用于公司政策、references/api_docs.md 用于 API 规范
- 用例:数据库模式、API 文档、领域知识、公司政策、详细工作流程指南
- 优点:保持 SKILL.md 精简,仅在 Claude 确定需要时加载
- 最佳实践:如果文件较大(>10000 字),在 SKILL.md 中包含 grep 搜索模式
- 避免重复:信息应存在于 SKILL.md 或参考文件中,而非两者都有。优先将详细信息放在参考文件中,除非它确实是技能的核心——这样可以保持 SKILL.md 精简,同时使信息可发现而不占用上下文窗口。仅在 SKILL.md 中保留基本的程序指令和工作流程指导;将详细参考材料、模式和示例移至参考文件。
素材(assets/)
不用于加载到上下文的文件,而是在 Claude 生成的输出中使用。
- 何时包含:当技能需要在最终输出中使用的文件时
- 示例:
assets/logo.png 用于品牌素材、assets/slides.pptx 用于 PowerPoint 模板、assets/frontend-template/ 用于 HTML/React 模板、assets/font.ttf 用于字体
- 用例:模板、图片、图标、模板代码、字体、需要复制或修改的示例文档
- 优点:将输出资源与文档分离,使 Claude 能够使用文件而无需将其加载到上下文中
渐进式披露设计原则
技能使用三级加载系统来高效管理上下文:
- 元数据(名称 + 描述) - 始终在上下文中(约 100 字)
- SKILL.md 正文 - 当技能触发时(<5000 字)
- 捆绑资源 - 根据 Claude 需要(无限*)
*无限是因为脚本可以在不读入上下文窗口的情况下执行。
技能创建流程
要创建技能,请按顺序执行"技能创建流程",仅在有明确原因表明某步骤不适用时才跳过。
第一步:通过具体示例理解技能
仅当技能的使用模式已经清楚理解时才跳过此步骤。即使在处理现有技能时,此步骤仍然有价值。
要创建有效的技能,需要清楚理解技能将如何使用的具体示例。这种理解可以来自用户直接提供的示例,或通过用户反馈验证的生成示例。
例如,在构建图像编辑器技能时,相关问题包括:
- "图像编辑器技能应支持哪些功能?编辑、旋转,还有其他吗?"
- "你能给出一些这个技能如何使用的例子吗?"
- "我能想象用户会要求'去除这张图片的红眼'或'旋转这张图片'。你还能想到其他使用方式吗?"
- "用户说什么应该触发这个技能?"
为避免让用户感到不知所措,不要在单条消息中问太多问题。从最重要的问题开始,然后根据需要跟进以提高效率。
当对技能应支持的功能有了清晰认识后,结束此步骤。
第二步:规划可复用的技能内容
要将具体示例转化为有效技能,分析每个示例:
- 考虑如何从头开始执行该示例
- 确定在重复执行这些工作流程时哪些脚本、参考资料和素材会有帮助
示例:在构建 pdf-editor 技能以处理"帮我旋转这个 PDF"之类的查询时,分析显示:
- 旋转 PDF 每次都需要重写相同的代码
scripts/rotate_pdf.py 脚本存储在技能中会有帮助
示例:在设计 frontend-webapp-builder 技能以处理"帮我构建一个待办事项应用"或"帮我构建一个追踪我步数的仪表板"之类的查询时,分析显示:
- 编写前端 Web 应用每次都需要相同的 HTML/React 模板代码
- 包含 HTML/React 项目文件模板的
assets/hello-world/ 目录存储在技能中会有帮助
示例:在构建 big-query 技能以处理"今天有多少用户登录了?"之类的查询时,分析显示:
- 查询 BigQuery 每次都需要重新发现表模式和关系
- 记录表模式的
references/schema.md 文件存储在技能中会有帮助
要确定技能的内容,分析每个具体示例以创建要包含的可复用资源列表:脚本、参考资料和素材。
第三步:初始化技能
此时,是时候实际创建技能了。
仅当正在开发的技能已存在且需要迭代或打包时才跳过此步骤。在这种情况下,继续下一步。
从头创建新技能时,始终运行 init_skill.py 脚本。该脚本方便地生成一个新的模板技能目录,自动包含技能所需的一切,使技能创建过程更加高效和可靠。
用法:
scripts/init_skill.py <技能名称> --path <输出目录>
该脚本:
- 在指定路径创建技能目录
- 生成带有适当前置元数据和 TODO 占位符的 SKILL.md 模板
- 创建示例资源目录:
scripts/、references/ 和 assets/
- 在每个目录中添加可以自定义或删除的示例文件
初始化后,根据需要自定义或删除生成的 SKILL.md 和示例文件。
第四步:编辑技能
在编辑(新生成或现有的)技能时,请记住该技能是为另一个 Claude 实例使用而创建的。专注于包含对 Claude 有益且非显而易见的信息。考虑哪些程序性知识、领域特定细节或可复用素材将帮助另一个 Claude 实例更有效地执行这些任务。
从可复用技能内容开始
要开始实现,从上面确定的可复用资源开始:scripts/、references/ 和 assets/ 文件。注意此步骤可能需要用户输入。例如,在实现 brand-guidelines 技能时,用户可能需要提供品牌素材或模板存储在 assets/ 中,或文档存储在 references/ 中。
此外,删除技能不需要的任何示例文件和目录。初始化脚本在 scripts/、references/ 和 assets/ 中创建示例文件以演示结构,但大多数技能不需要所有这些文件。
更新 SKILL.md
写作风格: 使用祈使/不定式形式(动词优先的指令)编写整个技能,而不是第二人称。使用客观、指导性的语言(例如"要完成 X,执行 Y"而不是"你应该做 X"或"如果你需要做 X")。这为 AI 使用保持一致性和清晰性。
要完成 SKILL.md,回答以下问题:
- 技能的目的是什么,用几句话描述?
- 何时应该使用该技能?
- 实际上,Claude 应该如何使用该技能?上面开发的所有可复用技能内容都应该被引用,以便 Claude 知道如何使用它们。
第五步:打包技能
技能准备好后,应将其打包成可分发的 zip 文件与用户共享。打包过程会自动先验证技能以确保满足所有要求:
scripts/package_skill.py <技能文件夹路径>
可选的输出目录指定:
scripts/package_skill.py <技能文件夹路径> ./dist
打包脚本将:
自动验证技能,检查:
- YAML 前置元数据格式和必需字段
- 技能命名约定和目录结构
- 描述的完整性和质量
- 文件组织和资源引用
如果验证通过,打包技能,创建以技能命名的 zip 文件(例如 my-skill.zip),包含所有文件并保持适当的目录结构以便分发。
如果验证失败,脚本将报告错误并退出而不创建包。修复任何验证错误并再次运行打包命令。
第六步:迭代
测试技能后,用户可能会要求改进。这通常发生在使用技能后不久,此时对技能表现的记忆还很新鲜。
迭代工作流程:
- 在真实任务中使用技能
- 注意困难或低效之处
- 确定应如何更新 SKILL.md 或捆绑资源
- 实施更改并再次测试
ライセンス全文を見る(Apache-2.0)
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.