agentペルソナ
subagentの役割、フォーカス、toolアクセスを定義する再利用可能なペルソナファイルを作成します。subagentが何を確認するか、出力をどのようにフォーマットするか、何をしてはいけないかを定義します。
agentペルソナは、スポーンされたsubagentの役割と動作を設定するmarkdownファイルです。カスタムモードがメインタスクの動作を決定するのに対し、ペルソナはサブagentの動作を決定します。subagentのアイデンティティ、チェックリスト、出力フォーマット、制約を制御します。
ペルソナの仕組み
BobがsubagentをスポーンするとBobは.bob/agents/でタスクに一致する説明を持つペルソナファイルを確認します。見つかった場合、ペルソナはsubagentのモードとして読み込まれます。ロール本体はsubagentのシステムプロンプトに挿入され、ベース指示の上に積み重なります。
ペルソナはメイン会話に自動的に読み込まれません。subagentがスポーンされたときのみ有効になります。これはBobの自主的な判断によるものか、特定のタスクを委任するようBobに依頼した場合です。
ペルソナファイルのフォーマット
ペルソナファイルは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.フロントマターフィールド
| フィールド | 必須 | 型 | 目的 |
|---|---|---|---|
name | はい | string | ログで使用される識別子。.mdを除いたファイル名と一致させてください。 |
description | はい | string | Bobがペルソナをタスクに一致させるために使用します。1行のミッションステートメントとして記述してください。 |
tools | いいえ | list | subagentが使用できるtoolグループを制限します。省略するとデフォルトを継承します。 |
toolグループ
toolsフィールドはカスタムモードと同じグループを受け付けます: read、edit、command、browser、mcp。
レビュアー、プランナー、要約者などの読み取り専用ペルソナにはtools: [read]を設定して、誤った編集を防いでください。
toolsフィールドは上限であり、権限の付与ではありません。アクティブなタスクで編集権限が有効になっていない場合、ペルソナにtools: [edit]を設定しても効果はありません。ペルソナはtoolアクセスを制限することしかできず、タスクが許可する範囲を超えて拡張することはできません。
ファイルの配置場所
| 場所 | スコープ | ユースケース |
|---|---|---|
<プロジェクト>/.bob/agents/ | このプロジェクトのみ | リポジトリにコミットされるチーム共有のペルソナ |
~/.bob/agents/ | このマシンのすべてのプロジェクト | すべてのリポジトリで使用できる個人ペルソナ |
両方の場所に同じ名前のペルソナが含まれている場合、プロジェクトレベルのファイルが優先されます。
.bob/ディレクトリには、他の設定と一緒にペルソナを配置できます。
最初のペルソナを作成する
プロジェクトルートにagentsディレクトリを作成します。
mkdir -p .bob/agentsペルソナファイルを作成します。ファイル名(.mdを除く)はフロントマターのnameフィールドと一致させてください。
touch .bob/agents/code-reviewer.mdフロントマターとロール本体を追加します。構造については上記のペルソナファイルのフォーマットを参照してください。
チームが同じペルソナを共有できるようにファイルをリポジトリにコミットしてください。
ペルソナの例
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.ペルソナの使い方
BobにタスクをこういときはBobにペルソナを名前で参照してください。
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/から一致するペルソナを読み込み、スポーンされたsubagentに適用します。
インラインペルソナ
一回限りのタスクには、ファイルを作成せずにプロンプトで直接ロールを記述できます。
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.インラインロールは単一タスクではファイルベースのペルソナと同様に機能します。同じロールを複数のタスクで再利用したり、チームと共有したりする場合はペルソナファイルを作成する価値があります。
会話履歴を渡す
デフォルトでは、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にコピーされます。長い会話ではトークンコストが大幅に増加します。subagentが前のコンテキストを本当に必要とする場合を除き、デフォルト(コンテキストをフォークしない)を優先してください。
ペルソナ、モード、ルール
| メカニズム | スコープ | 制御対象 | 使用タイミング |
|---|---|---|---|
| モード | タスク全体 | メインタスクのtool上限とロール定義 | メインagentが異なる姿勢を必要とする場合(読み取り専用、docsライター、セキュリティレビュアーなど) |
| ルール | タスクまたはモード | システムプロンプトに読み込まれる常時指示 | チームの規約、フォーマット標準、常に適用されるガードレール |
| ペルソナ | 1つのsubagent | スポーンされたsubagentのロール、フォーカス、出力フォーマット、tool制約 | ヘルパーがドメインフォーカスを必要とする場合(コードレビュー、変更の要約、テスト計画など) |