创建和使用技能
创建一个可复用的技能,教 Bob 一个可重复的 changelog 条目工作流,然后显式调用它或让 Bob 自动激活它。
技能是一个可复用的指令集,教 Bob 一个专业化的、可重复的工作流。你无需在每个 prompt 中重新输入相同的格式规则或检查清单,只需在 SKILL.md 文件中定义一次工作流即可。之后,无论你直接调用技能还是 Bob 自动激活,Bob 都会在技能适用时遵循这些指令。
在本教程中,你将创建一个技能,使用 Keep a Changelog 格式向 CHANGELOG.md 文件添加条目(如果文件不存在则创建)。你用斜线命令显式调用技能,然后进行第二次更改,并要求 Bob 记录它而不提及技能名称,以观察 Bob 根据技能描述自动激活它。
前提条件
要完成本教程,你需要以下内容:
- 如果尚未拥有,克隆 Galaxium Travels 演示代码。
git clone https://github.com/IBM/galaxium-travels- 已打开 Galaxium Travels 演示代码的 Bob IDE。
- 虽然不是必需的,但建议先完成使用 /init 和 AGENTS.md 启动项目和为 Bob 编写有效的提示词。
创建 changelog 条目技能
打开聊天界面
点击导航栏旁的 Bob 图标打开 Bob 聊天界面,或使用快捷键 Option + Command + B(macOS)或 Ctrl + Alt + B(Windows)。
使用聊天界面中的模式选择器切换到 Agent 模式。Agent 模式为 Bob 提供激活技能和编辑文件所需的工具访问权限。
打开 Skills 设置
在 Bob 中创建技能有多种方式。你可以使用用户界面(UI),或在 Bob 聊天中使用 /create-skill 命令进行引导式设置。
在本教程中,你使用 Bob 设置中的 Skills 选项卡来创建技能。
- 在聊天界面下方,点击 Bob Settings。
- 点击左侧边栏中的 Skills。
- 点击 + 按钮创建新技能。

填写技能详情
在技能创建表单中输入以下值:
| 字段 | 值 |
|---|---|
| Skill Name | changelog-entry |
| Description | Adds an entry to CHANGELOG.md using the Keep a Changelog format, creating the file if it does not exist, so change history stays consistent and release-ready. |
| Allow Bob to use this skill | 开启 |
| Scope & Location | galaxium-travels |
Skill Name 是你输入以直接调用技能的内容,例如 /changelog-entry。Description 是 Bob 在你不按名称调用技能时,用于判断技能是否适用于某个请求而读取的内容。
当 Allow Bob to use this skill 开启时,Bob 可以在 prompt 需要时自行使用技能,或者你也可以显式调用它。将 Scope & Location 设置为 galaxium-travels 会将技能保存在项目的 .bob/skills/ 目录中,这样 git 会与代码一起追踪它,你的团队也可以访问它。选择 Global (all workspaces) 则会将技能保存在仓库外的 ~/.bob/skills/ 中。
在 Skill Instructions 文本框中输入以下内容:
---
name: changelog-entry
description: Adds an entry to CHANGELOG.md using the Keep a Changelog format, creating the file if it does not exist, so change history stays consistent and release-ready.
user-invocable: true
---
Add an entry to CHANGELOG.md using the Keep a Changelog format (https://keepachangelog.com/).
- If CHANGELOG.md does not exist, create it at the project root with this structure before adding an entry:
# Changelog
All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]
- Add new entries under the `## [Unreleased]` section, under one of these subheadings: `### Added`, `### Changed`, `### Fixed`, `### Removed`. Create the subheading if it is not already present under `## [Unreleased]`.
- Write each entry as a single bullet point in the imperative mood ("Add", not "Added"), starting with a capital letter, with no trailing period.
- Base the entry on the actual diff, not on the wording of the request. Run `git diff` to review what changed before writing the entry.
- Only edit CHANGELOG.md. Do not stage or commit the change.点击 Create。
Bob 将技能保存到 galaxium-travels/.bob/skills/changelog-entry/SKILL.md。
直接调用技能
按名称调用技能,以便查看 Bob 遵循的指令。
进行小改动
让 Bob 进行一个小而低风险的编辑,以便有内容可以记录:
Add a one-line note to the end of the README.md that says "Powered by IBM Bob."Bob 编辑 README.md。如果提示,批准编辑。
使用技能记录变更
在聊天界面中,输入 /changelog-entry 并按 Enter,或点击出现的 /changelog-entry 建议。然后输入以下 prompt:
Add a changelog entry for this change.Bob 可能会请求使用技能工具和编辑文件的权限。如果提示,批准。Bob 加载 changelog-entry 技能,由于项目没有 CHANGELOG.md,将其创建,并添加遵循技能中定义格式的条目,类似于:
## [Unreleased]
### Added
- Add "Powered by IBM Bob." note to the end of README.md让 Bob 自动激活技能
点击聊天界面上方的 + 按钮启动新任务窗口。
进行第二次更改,并要求 Bob 记录它,而不提及技能名称。由于你保持 Allow Bob to use this skill 开启,Bob 可以从技能描述中识别出它适用并自行激活。
进行另一个小改动
Add a one-line comment above the main heading in README.md that says "Galaxium Travels".如果提示,批准编辑。
请求 Bob 记录变更,而不命名技能
Update the changelog for this edit.Bob 识别出请求与 changelog-entry 技能的描述匹配,并在你不输入 /changelog-entry 的情况下激活它。如果提示,批准技能和文件编辑权限。Bob 以相同格式添加另一个条目。
启用此设置后,Bob 会在技能(包括 changelog-entry)适用时自动激活,无需先询问。
管理你的技能
你创建 changelog-entry 的 Bob 设置中的 Skills 选项卡,也是你查看当前和全局工作区中所有可用技能的地方。使用它来检查工作区已加载的技能,确认技能来自项目(.bob/skills/)还是全局(~/.bob/skills/)位置,以及编辑或删除技能。
清理
要删除本教程中创建的文件:
- 在 Bob Settings 中,点击 Skills,然后删除
changelog-entry技能。 - 删除在前提条件中克隆的
galaxium-travels目录。这也会删除本教程中进行的CHANGELOG.md和README.md编辑。
后续步骤
在本教程中,你学习了技能如何让你一次定义工作流,并让 Bob 一致地应用它,无论你是用 /skill-name 显式调用技能,还是让 Bob 根据描述自动激活它。
继续学习添加自定义模式,了解自定义模式如何将角色定义、行为指令和工具访问组合成特定工作的专业化角色。