功能

技能

为专业化工作流创建可重用的指令集。定义自定义工作流,添加支持文件,并教 Bob 专业化任务以获得一致的结果。

技能是可重用的指令集,可以教 Bob 新的工作流和专业化任务。把它们想象成 Bob 遵循的配方,以一致、可重复的方式完成特定类型的工作。

为什么使用技能

  • 可重用性:一次定义工作流,在多次对话中使用。
  • 一致性:确保 Bob 每次针对特定任务都遵循相同的方法。
  • 专业化:为代码审查、测试、文档等创建特定领域的专业知识。
  • 团队协作:通过版本控制与团队共享标准化工作流。
  • 灵活性:包含支持文件,如检查清单、模板和参考资料。

技能的工作原理

激活技能时,Bob 会收到技能的指令并获得访问技能目录中任何支持文件的权限。然后 Bob 按照这些指令根据定义的工作流完成你的任务。

技能每次对话加载一次,以避免重复提示。Bob 根据你的请求和技能描述自动决定何时激活技能。

创建技能

基本设置

在项目根目录的 .bob/skills/ 内创建一个文件夹,或使用 ~/.bob/skills/ 作为全局技能。

在该文件夹内添加一个 SKILL.md 文件。

示例结构:

SKILL.md

SKILL.md 格式

SKILL.md 文件使用 YAML frontmatter,后跟技能指令:

---
name: code-review
description: Review code for bugs, security issues, and best practices
---

When reviewing code, check for:
- Security vulnerabilities
- Performance issues
- Missing error handling at API boundaries
- Unused imports and dead code

Provide a summary with severity levels for each finding.

必填字段:

  • name:在 Bob 界面中使用的技能显示名称
  • description:帮助 Bob 决定何时激活此技能的清晰摘要 — 没有描述的技能将被忽略

指令部分: --- 分隔符以下的所有内容都会成为技能激活时 Bob 收到的指令。

添加支持文件

你可以在 SKILL.md 旁边包含额外的文件和子文件夹,以提供参考资料、模板、检查清单、脚本或其他资源。技能激活后,Bob 可以自动读取这些文件。

包含支持文件的示例:

SKILL.md
checklist.md
severity-guide.md
analyze.sh
report-generator.py

支持文件和文件夹可以包括:

  • 检查清单和模板
  • 参考文档
  • 配置示例
  • 子文件夹中的脚本和实用程序
  • 样式指南
  • 技能所需的任何其他资源

技能位置

技能可以在两个级别定义:

位置范围使用场景
<project>/.bob/skills/项目特定此项目独有的工作流
~/.bob/skills/全局个人或组织范围的工作流

优先级: 如果两个位置都包含同名技能,项目级技能优先。

审批技能

默认情况下,Bob 在激活技能之前会请求你的许可。这让你可以控制何时应用专业化工作流。

跳过审批提示:

打开 Bob 设置。

导航到自动审批部分。

打开 Skills 的开关。

启用此设置后,Bob 在适当时会自动激活技能,无需请求许可。

技能设置选项卡

Bob 设置中的 Skills 选项卡提供了一个集中位置来查看和管理工作区中可用的技能。使用它来查看哪些技能已加载,检查它们的位置,并验证来自项目或全局目录的技能是否被正确识别。

编写有效的技能

清晰的描述

编写清晰指明何时应使用技能的描述。Bob 依赖这些描述来确定技能的相关性。

好的示例:"Review code for bugs, security issues, and best practices"

避免:"Code review skill"

专注的指令

保持主 SKILL.md 文件专注于核心工作流。将详细的参考资料、示例和检查清单移至支持文件。

示例:

---
name: api-documentation
description: Generate API documentation following OpenAPI standards
---

Generate API documentation that includes:
- Endpoint descriptions
- Request/response schemas
- Authentication requirements
- Example requests and responses

Follow the style guide in `api-style-guide.md` and use the template in `api-template.md`.

可执行步骤

将指令构造为 Bob 可以系统遵循的清晰、可执行步骤。

示例:

---
name: feature-implementation
description: Implement new features following team standards
---

<Steps>
<Step>
Review the feature requirements.

</Step>

<Step>
Create a plan with file changes needed.

</Step>

<Step>
Implement the feature with tests.

</Step>

<Step>
Update documentation.

</Step>

<Step>
Verify all tests pass.

</Step>
</Steps>

Follow coding standards in `coding-standards.md`.

技能示例

代码审查技能

---
name: security-review
description: Review code for security vulnerabilities and best practices
---

Perform a security-focused code review:

<Steps>
<Step>
Check for common vulnerabilities:
- SQL injection risks
- XSS vulnerabilities
- Authentication/authorization issues
- Sensitive data exposure

</Step>

<Step>
Review security best practices:
- Input validation
- Output encoding
- Secure configuration
- Error handling

</Step>

<Step>
Provide findings with:
- Severity level (Critical, High, Medium, Low)
- Location in code
- Recommended fix
- Reference to security standards

</Step>
</Steps>

Use the severity guide in `severity-levels.md` for classification.

文档技能

---
name: api-docs
description: Generate comprehensive API documentation
---

Create API documentation that includes:

<Steps>
<Step>
Overview section:
- Purpose and use cases
- Authentication requirements
- Base URL and versioning

</Step>

<Step>
For each endpoint:
- HTTP method and path
- Description and purpose
- Request parameters
- Request body schema
- Response codes and schemas
- Example requests and responses

</Step>

<Step>
Additional sections:
- Error handling
- Rate limiting
- Pagination

</Step>
</Steps>

Follow the template in `api-doc-template.md` and examples in `api-examples.md`.

技巧和最佳实践

  • 从简单开始:从基本指令开始,根据结果进行细化。
  • 使用支持文件:通过将详细内容移至附属文件来保持 SKILL.md 简洁。
  • 彻底测试:在与团队共享之前验证技能是否按预期工作。
  • 版本控制:将项目技能包含在仓库中以保持团队一致性。
  • 清晰命名:使用能够指明其用途的描述性技能名称。
  • 单一职责:为特定任务创建专注的技能,而不是试图处理多个不相关的工作流。
这个主题怎么样?