【手把手教程】开发自己的Claude Agent Skills
By 01Coder
Summary
## Key takeaways - **Develop Claude Agent Skills for Reusability**: Creating your own Claude Agent Skills allows you to consolidate and reuse past task execution experiences and techniques, significantly boosting efficiency in future tasks and team collaborations. [00:42], [01:07] - **Claude Agent Skills Architecture**: Claude Agent Skills operate within a virtual machine environment that supports Bash, Python, and Node.js, granting the agent file system access and the ability to execute commands and code. [01:21], [01:48] - **Skill.md Structure: Metadata and Instructions**: Each skill is defined by a skill.md file containing metadata (name, description) that loads initially, and instructions that load only when the skill is triggered, enabling efficient resource management. [02:49], [03:05] - **Skill Packaging: Directory Structure is Key**: To correctly package a skill, create a directory with the skill's name, include necessary files like skill.md, and then zip this directory. Unzipping should reveal the same named directory, not the files directly. [05:14], [05:28] - **Testing Skills in Claude Desktop App**: After packaging, skills can be tested by loading them into applications like the Claude desktop app and interacting with them in a conversation to verify correct loading and functionality. [05:45], [05:50]
Topics Covered
- Why custom AI skills are crucial for personal and team efficiency.
- How Claude's agent virtual machine executes custom skills.
- The lazy loading mechanism of Claude's skill instructions.
- Packaging and validating your custom Claude agent skills.
Full Transcript
大家好我是小木头
欢迎大家来到我的视频频道
本期视频
我们分享如何开发自己的agent skills
在上一期视频分享中
我们介绍了Claude发布的新特性skills
目前在Claude的产品中
比如桌面应用,Claude code以及Claude API
咱们能够使用skills
来拓展AI应用的能力
感兴趣的朋友
可以回到上一期的视频分享
来了解什么是agent skills
以及如何使用它
本期视频呢
咱们再进一步
来尝试开发自己的agent skills
充分地拓展AI的能力
开发自己的agent skills最大的好处在于
不仅能将我们在过去的任务执行中
特别是配合AI
完成任务执行时的一些经验
以及技巧总结整理下来
在后续的任务执行中
轻松地重复使用它们
另一方面在于在团队协作中
我们可以以skill或Plug in的形式
分享给团队的成员
从而在整个团队中形成统一的技能包
这样
也能充分的提高我们工作学习的效率
那么该如何开发自己的agent skill
那我们现在呢就来了解一下
首先我们来看看skills Architecture
也就是它的架构
在下面这张图里
对它做了比较清晰的阐述
agent + skill + computer
agent configuration
在配置这一层呢
会包含它装备的技能
就像咱们个人具备的技能包
这些技能包在哪里呢
我们看右侧这个agent Virtual machine
agent会具备一个
具有代码执行能力的虚拟环境
在这个环境中
Claude是有文件系统访问权限的
同时呢能够执行Bash命令
以及运行代码
那么
在右侧这个Virtual machine的环境当中
咱们看到它支持了Bash、Python、Node.js
这使agent在这个虚拟环境中
具有命令和代码的执行能力
在文件系统当中
则部署了一系列的skills
这些skills分别对应了独立的目录
这些目录中包含了
比如像上一期视频中
我们介绍的
skill的MD文件
以及其他的文件
那究竟每个skill该如何创建目录
如何组织呢
在后续的分享中我们会介绍
这其中还可以包含比如
Python脚本或Node.js的脚本
这些脚本
都可以在这个虚拟的环境中运行
因为我们有了代码执行的能力
接下来看看这个skills是怎么工作的
目前是支持三种类型的内容
每一个skill的MD文件它有固定的格式
首先呢是最上方的这一段metadata
在这个metadata也就是原数据中
包含了skill的名字以及描述
这部分内容是总是会被加载的
接下来是这个skill的指令instruction
这部分内容
只有在触发的时候才会加载
咱们可以这样理解
code初始化加载skills
它并不会加载所有的内容
而仅仅是刚才我们看到的metadata
其中包含了技能的名字和描述
基于这些信息
它会决策究竟该用哪一项技能
在具体的技能要被执行或引用时
才会加载它的指令
也就是instruction部分
这里就有一段非常简单的instruction
是使用PDF Plumber
来抽取PDF文件中的文本
并且给到了一段Python代码
下面还有一段文字for advanced form filling
对于这种高级的表单填写
查看forms的MD文件
也就是说在这个skill的目录当中
还会有一个forms的MD的文本文件
这就是指令部分
当然了
在一个进程包中咱们还可以包含脚本
比如说Python脚本
我们可以创建scripts目录
将这个脚本放在这个目录中
因此通常的一个skill目录
包含了像现在所分享的这么一个结构
必须的是skill的MD文件
那其他的呢
可以根据我们在skill MD文件编写中
按需要来添加必要的文件
这里面呢也包含了Python或Node.js脚本
我们在这里再分享一篇文章
关于如何编写自定义的skills
核心部分还是skill的MD文件
在Metadata中必要的是name和description
如果需要
我们还可以添加version
以及dependencies这两个字段
后面这两个字段是可选的
接下来
就是咱们刚才所介绍的instruction部分
还可以添加资源
比如添加脚本
最后是对skill的打包
大家要注意打包的格式是这样的
当我们创建my skill这么一个目录
添加了必要的文件像skill的MD
需要将其打包为一个zip包
解压以后会看到同名的一个目录
这才是一个正确的结构
如果咱们的压缩包解压后
直接看到的是skill的MD
没有这一层同名的目录
是不正确的
在下面就列出了一个错误的zip包的结构
测试非常简单
当我们打包好以后
将其加载到比如Core桌面应用
在对话中开始引用到这个skill或技能
来进行交互
我们就能看到它是否正常加载
技能包中的skill的MD文件
通过这种方式
我们可以简单地验证当前
技能包是否编写正确
Loading video analysis...