技能
為專業化工作流程建立可重用的指令集。定義自訂工作流程,新增支援檔案,並教 Bob 專業化任務以獲得一致的結果。
技能是可重用的指令集,可以教 Bob 新的工作流程和專業化任務。把它們想像成 Bob 遵循的配方,以一致、可重複的方式完成特定類型的工作。
為什麼使用技能
- 可重用性:一次定義工作流程,在多次對話中使用。
- 一致性:確保 Bob 每次針對特定任務都遵循相同的方法。
- 專業化:為程式碼審查、測試、文件撰寫等建立特定領域的專業知識。
- 團隊協作:透過版本控制與團隊共享標準化工作流程。
- 彈性:包含支援檔案,如檢查清單、範本和參考資料。
技能的運作方式
啟用技能時,Bob 會收到技能的指令並獲得存取技能目錄中任何支援檔案的權限。然後 Bob 按照這些指令根據定義的工作流程完成你的任務。
技能每次對話載入一次,以避免重複提示。Bob 根據你的請求和技能描述自動決定何時啟用技能。
建立技能
基本設定
在專案根目錄的 .bob/skills/ 內建立一個資料夾,或使用 ~/.bob/skills/ 作為全域技能。
在該資料夾內新增一個 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 可以自動讀取這些檔案。
包含支援檔案的範例:
支援檔案和資料夾可以包括:
- 檢查清單和範本
- 參考文件
- 設定範例
- 子資料夾中的腳本和公用程式
- 樣式指南
- 技能所需的任何其他資源
技能位置
技能可以在兩個層級定義:
| 位置 | 範圍 | 使用場景 |
|---|---|---|
<project>/.bob/skills/ | 專案特定 | 此專案獨有的工作流程 |
~/.bob/skills/ | 全域 | 個人或組織範圍的工作流程 |
優先順序: 如果兩個位置都包含同名技能,專案層級技能優先。
核准技能
預設情況下,Bob 在啟用技能之前會請求你的許可。這讓你可以控制何時套用專業化工作流程。
略過核准提示:
開啟 Bob 設定。
導覽至自動核准部分。
開啟 Skills 的切換開關。
啟用此設定後,Bob 在適當時會自動啟用技能,無需請求許可。
技能設定索引標籤
Bob 設定中的 Skills 索引標籤提供了一個集中位置來檢視和管理 workspace 中可用的技能。使用它來查看哪些技能已載入,檢查它們的位置,並驗證來自專案或全域目錄的技能是否被正確偵測到。
撰寫有效的技能
清晰的描述
撰寫清晰指明何時應使用技能的描述。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簡潔。 - 徹底測試:在與團隊共享之前驗證技能是否按預期運作。
- 版本控制:將專案技能包含在存放庫中以保持團隊一致性。
- 清晰命名:使用能夠指明其用途的描述性技能名稱。
- 單一職責:為特定任務建立專注的技能,而不是試圖處理多個不相關的工作流程。