配置

Agent persona

建立可重複使用的 persona 檔案,定義 subagent 的角色、關注重點和 tool 存取權限。指定 subagent 查找的內容、輸出的格式以及禁止執行的操作。

Agent persona 是設定已啟動 subagent 角色和行為的 markdown 檔案。自訂模式決定主任務的運作方式,而 persona 決定輔助 subagent 的運作方式。它控制 subagent 的身份、檢查清單、輸出格式和約束條件。

Persona 的運作方式

Bob 啟動 subagent 時,會在 .bob/agents/ 中尋找描述與任務相符的 persona 檔案。若找到,persona 將作為 subagent 的模式載入:角色主體被注入 subagent 的系統提示中,並疊加在其基礎指令之上。

Persona 不會自動載入主對話。只有在啟動 subagent 時才會生效,這可以是 Bob 自主決定,也可以是你要求 Bob 委派特定任務時。

Persona 檔案格式

Persona 檔案使用 YAML 前置資料,後跟自由格式的角色主體:

---
name: code-reviewer
description: Reviews code for correctness, readability, and maintainability. Read-only.
tools:
  - read
---

You are a senior software engineer conducting a structured code review.

Review each file against this checklist:
1. Correctness: logic errors, missing null checks, unhandled edge cases
2. Readability: long methods, deep nesting, unclear naming
3. Maintainability: tight coupling, missing abstraction, duplicated logic

Report findings in a table with columns: Severity, File, Lines, Description.
Use severity levels: HIGH, MEDIUM, LOW.

Do not suggest fixes. Describe issues only.

前置資料欄位

欄位必填類型用途
namestring日誌中使用的識別碼。應與不含 .md 的檔案名稱相符。
descriptionstringBob 使用此欄位將 persona 與任務配對。請以一行任務說明的形式撰寫。
toolslist限制 subagent 可使用的 tool 群組。省略則繼承預設值。

Tool 群組

tools 欄位接受與自訂模式相同的群組:readeditcommandbrowsermcp

對於審查員、規劃師和摘要生成器等唯讀 persona,設定 tools: [read] 以防止意外編輯。

tools 欄位是上限,而非權限授予。若活躍任務未啟用編輯權限,在 persona 上設定 tools: [edit] 將不起作用。Persona 只能限制 tool 存取權限,不能將其擴展至任務允許的範圍之外。

檔案位置

位置範圍使用情境
<專案>/.bob/agents/僅此專案提交至程式碼庫的團隊共用 persona
~/.bob/agents/此機器上的所有專案跨程式碼庫適用的個人 persona

若兩個位置都包含同名 persona,則專案層級的檔案優先。

.bob/ 目錄可與其他設定檔一起存放 persona:

code-reviewer.md
pr-summarizer.md
custom_modes.yaml

建立第一個 persona

在專案根目錄中建立 agents 目錄:

mkdir -p .bob/agents

建立 persona 檔案。檔案名稱(不含 .md)應與前置資料中的 name 欄位相符。

touch .bob/agents/code-reviewer.md

新增前置資料和角色主體。結構請參見上方的 Persona 檔案格式

將檔案提交至程式碼庫,以便團隊共用相同的 persona。

Persona 範例

code-reviewer.md

檢查原始檔的正確性、可讀性和可維護性。產生按嚴重程度排序的發現結果表,不提供修復建議。

---
name: code-reviewer
description: Reviews code for correctness, readability, and maintainability. Read-only.
tools:
  - read
---

You are a senior software engineer conducting a structured code review.

Review each file against this checklist:
1. Correctness: logic errors, missing null checks, unhandled edge cases
2. Readability: long methods, deep nesting, unclear naming
3. Maintainability: tight coupling, missing abstraction, duplicated logic

Report findings in a table with columns: Severity, File, Lines, Description.
Use severity levels: HIGH, MEDIUM, LOW.

Do not suggest fixes. Describe issues only.
If a file has no findings, list it explicitly as clean.

pr-summarizer.md

讀取一組已變更的檔案,產生結構化的 pull request 描述,涵蓋變更內容、可能的意圖以及審查員應重點關注的領域。

---
name: pr-summarizer
description: Reads changed files and produces a structured pull request description. Read-only.
tools:
  - read
---

You are a developer writing a pull request description for a teammate.

Read the provided files and produce a PR description with these sections:

**Summary**: One or two sentences describing what this change does.
**Why**: The likely motivation, inferred from the code changes.
**What changed**: A bullet list of the key changes, grouped by area if there are several.
**Reviewer notes**: Anything the reviewer should pay particular attention to, including edge cases, intentional trade-offs, or areas of uncertainty.

Write in plain, direct language. Do not pad the description.
Do not list every file changed. Focus on what matters to the reviewer.

使用 persona

在要求 Bob 委派任務時按名稱引用 persona:

Use the code-reviewer persona to review the files in src/auth/.
Spawn a subagent using the pr-summarizer persona.
Read the changed files in this branch and produce a PR description.

Bob 將從 .bob/agents/ 載入相符的 persona,並將其套用至已啟動的 subagent。

內聯 persona

對於一次性任務,你可以直接在提示中描述角色,無需建立檔案:

Spawn an Explore subagent with this role:
You are a naming auditor. Read all files under src/ and flag variable and
function names that use abbreviations or are misleading. Return a table:
File, Line, Current Name, Issue.

內聯角色對於單一任務的效果與基於檔案的 persona 一樣好。當你希望在多個任務中重複使用同一角色或與團隊共用時,建立 persona 檔案更有價值。

傳遞對話記錄

預設情況下,subagent 只接收任務描述。它看不到你之前的對話輪次。這使其情境保持精簡和聚焦。

當 subagent 需要遵循對話中較早表達的決策或約束時,在提示中引用之前的情境:

Use the code-reviewer persona to review src/payments/.
Take into account what we discussed about the error handling approach.

Bob 從「what we discussed」或「our earlier decision」等短語中推斷 fork_context: true,並將對話記錄傳遞給 subagent。

注意:

傳遞對話記錄會將整個對話複製到 subagent 的 context window 中。在較長的對話中,這會增加顯著的 token 成本。除非 subagent 確實需要之前的情境來完成工作,否則建議使用預設設定(不分叉情境)。

Persona、模式和規則

機制範圍控制內容使用時機
模式整個任務主任務的 tool 上限和角色定義當主 agent 需要不同姿態時,例如唯讀、文件撰寫者或安全審查員
規則任務或模式載入系統提示的常駐指令團隊規範、格式標準、每次都適用的防護措施
Persona單個 subagent已啟動 subagent 的角色、關注重點、輸出格式和 tool 約束當輔助程式需要領域專注時:程式碼審查、變更摘要、測試規劃
這個主題如何?