返回播客Claude
Claude Code skills
配置与多文件 skill
A basic skill works with just a name and description, but here are some other advanced tips that can make your skills really effective in claw code.
基础 skill 只需要名称和描述,但还有一些高级技巧可以让你的 skill 在 Claude Code 中更高效。
The agentskills.io open standard has many available fields.
agentskills.io 开放标准提供了许多可用字段。
We already went over the name, which identifies your skill, uses lowercase letters, numbers, and hyphens only.
名称字段我们已经介绍过了:用于标识你的 skill,只能使用小写字母、数字和连字符。
A maximum of 64 characters and should match your directory name.
最多 64 个字符,且应与目录名一致。
a description which is also required which tells Claude when to use the skill.
描述字段同样必填,告诉 Claude 何时使用该 skill。
This is a maximum of,024 characters and is the most important field.
最多 1024 个字符,是最重要的字段。
Claude uses this for matching.
Claude 用它来进行匹配。
But we can also add other optional fields.
此外还可以添加其他可选字段。
One of them is the allowed tools field which restricts which tools Claude can use when the skill is active.
allowed tools 字段可限制 skill 激活时 Claude 可用的工具。
The model field which specifies which cla model to use for the skill.
model 字段指定 skill 使用的 Claude 模型。
Try to be explicit with your instructions.
请尽量在描述中写清楚指令。
For example, if someone told me my job was to help with dogs, I wouldn't know what to do.
举个例子,如果有人告诉我工作是帮助处理狗的事,我根本不知道该做什么。
So, we have to assume Claude would think the same way.
所以我们必须假设 Claude 也会有同样的困惑。
A good description answers two questions.
一个好的描述能回答两个问题。
What does this skill do?
这个 skill 做什么?
And when should Claus use it?
Claude 应该在什么时候使用它?
Now, if this job description was given to me, I feel a little bit more confident that I could get the job done.
如果我拿到这样的职位描述,我会觉得更有把握完成任务。
If your skill isn't triggering, add more keywords that match how you phrase requests.
skill 未触发时,加入与你提请求方式匹配的关键词。
Sometimes you want a skill that can only read files, not modify them.
有时你希望 skill 只能读取文件,而不能修改。
This could be for security sensitive workflows, read only tasks or more.
这适用于安全敏感的工作流、只读任务等场景。
We have the allowed tools field to make this possible.
allowed tools 字段可实现这一点。
When this skill is active, Claw can only use those tools without asking permission.
skill 激活时,Claude 只能使用那些工具,无需额外询问权限。
No editing, no writing, no bash commands.
无法编辑、写入或执行 bash 命令。
If you omit allowed tools, the skill doesn't restrict anything.
省略此字段时,skill 不会限制任何工具权限。
Claude uses its normal permission model.
Claude 使用正常权限模型。
Skills share Claw's context window with your conversation.
Skill 与对话共享 Claude 的上下文窗口。
When Claude wants to use a skill, it will decide to load the contents of that skill into context.
当 Claude 想使用某个 skill 时,会决定将该 skill 的内容加载到上下文中。
However, sometimes you'll need some references, examples, or some utility scripts that are required by the skill.
但有时 skill 需要一些参考资料、示例或实用脚本。
But cramming it all into one 20,000 line text file means you take up a lot of space in the context window.
把所有内容塞进一个 2 万行的文本文件,会占用大量上下文窗口空间。
And let's be real here, it's just not a lot of fun to maintain that.
说实话,维护这样的文件也实在不好玩。
This is where progressive disclosure comes in.
这就是渐进式披露的用武之地。
Put your essential instructions in skill.mmp and detailed reference material in separate files that Claude reads only when needed.
把核心指令放在 skill.md 中,详细参考资料放在独立文件里,让 Claude 仅在需要时读取。
The open standard also suggests having a scripts folder for executable code, references for additional documentation and assets for images, templates or other data files that would be relevant for that skill.
开放标准还建议设置 scripts 文件夹存放可执行代码,references 文件夹存放补充文档,assets 文件夹存放图片、模板或其他数据文件。
Then in skill.md link to the supporting files.
然后在 skill.md 中链接这些支撑文件。
Here, Claude reads architecture.md only when someone asks about system design.
Claude 只在有人询问系统设计时才读取 architecture.md。
If they're asking where to add a component, let's say, it just never loads.
如果问的是在哪里添加组件,它就不会加载这个文件。
It's like having a table of contents in the context window rather than fitting the whole entire document in there.
就像在上下文窗口里放目录,而不是把整份文档全部塞进去。
Keep skill.md under 500 lines.
skill.md 保持在 500 行以内。
If you're exceeding that, then maybe consider should this be split up into different content.
如果超出了,可以考虑是否应该拆分成不同的内容。
Scripts in your skill directory can run without loading their contents into context.
skill 目录中的脚本可以直接运行,无需将其内容加载到上下文中。
The script executes and only the output consumes tokens.
脚本执行后,只有输出结果消耗 token。
Tell claw to run the script, not read it.
让 Claude 执行脚本,不要读取。
This is very useful for environment validation, data transformations that need to be consistent, operations that are more reliable as tested code than generated code.
这对于环境验证、需要保持一致性的数据转换,以及用经过测试的代码比生成代码更可靠的操作非常有用。
Skills support metadata fields.
Skill 支持元数据字段。
Name and description which are required.
名称和描述是必填项。
Allowed tools restricts available tools and model specifies which claw to use.
此字段限制可用工具,model 则指定所用的 Claude 模型。
Descriptions need specific actions and trigger phrases to match for reliability.
描述需要包含具体操作和触发短语,以确保匹配的可靠性。
For larger skills, use progressive disclosure.
较大的 skill 用渐进式披露。
Keep your skill.md file under 500 lines and link to the supporting files that load only when needed.
将 skill.md 文件保持在 500 行以内,并链接到仅在需要时才加载的支撑文件。
Scripts [music] can execute without loading their contents, keeping context efficient.
脚本 [音乐] 可以直接执行而无需加载内容,从而保持上下文高效。