Worktree分離によるクロスモデル・エージェントオーケストレーション
ブラインド分岐検証と自動学習を搭載
curl -fsSL https://raw.githubusercontent.com/project820/be-my-butler/main/install.sh | bash
すべてのアーキテクチャ上の決定は、これらの譲れない原則に基づいています。
git worktreeを取得。共有状態なし。index.lockの競合なし。真のファイルシステムレベルの分離。.bmb/とCLAUDE.mdのみを読み取ります。コードには一切触れません。コンテキスト保護が最優先 — Leadがボトルネックです。session-prep.mdが次のセッションの状態を保存。セッション間のコンテキストが保持されます。作業が本当に失われることはありません。councilとverifyは読み取り専用。--full-autoの乱用はもうありません。9つの専門エージェント、それぞれ明確な役割と厳格な境界を持ちます。ブレインストーミングからプロダクションレディなコードまで。
graph TB User["👤 User"] Lead["🎯 Lead
Opus · Orchestrator"] Consultant["💬 Consultant
Sonnet · Persistent"] Architect["📐 Architect
Opus · Council"] Executor["⚙️ Executor
Opus · Backend"] Frontend["🎨 Frontend
Opus · UI"] Tester["🧪 Tester
Opus · Blind"] Verifier["✅ Verifier
Opus · Blind"] Simplifier["🧹 Simplifier
Opus · Cleanup"] Writer["📝 Writer
Sonnet · Docs"] BMB[".bmb/
Handoffs · Artifacts"] CrossModel["🌐 Cross-Model
Codex / Gemini"] User <-->|"brainstorm
approve"| Lead Lead <-->|"SendMessage
bidirectional"| Consultant Lead -->|"briefing"| Architect Architect <-->|"council
debate"| CrossModel Lead -->|"plan-to-exec"| Executor Lead -->|"plan-to-exec"| Frontend Lead -->|"test request"| Tester Tester -.->|"blind wall"| CrossModel Lead -->|"verify request"| Verifier Verifier -.->|"blind wall"| CrossModel Lead -->|"simplify"| Simplifier Lead -->|"write docs"| Writer Architect -->|"writes"| BMB Executor -->|"writes"| BMB Frontend -->|"writes"| BMB Tester -->|"writes"| BMB Verifier -->|"writes"| BMB Lead -->|"reads only"| BMB classDef opus fill:#1a1030,stroke:#7c3aed,stroke-width:2px,color:#a78bfa classDef sonnet fill:#0a2015,stroke:#16a34a,stroke-width:2px,color:#22c55e classDef cross fill:#1a1500,stroke:#d97706,stroke-width:2px,color:#f59e0b classDef user fill:#0a1628,stroke:#3b82f6,stroke-width:2px,color:#60a5fa classDef storage fill:#111827,stroke:#1e3a5f,stroke-width:2px,color:#8494a7 class Lead,Architect,Executor,Frontend,Tester,Verifier,Simplifier opus class Consultant,Writer sonnet class CrossModel cross class User user class BMB storage
.bmb/のみ読み取り。コードは一切書かない。薄い指揮者。analytics.dbをクエリし、Bird’s Law重大度(critical/warn/info)でイベントを分類、pattern_countsのプロモーション候補を特定。ユーザーの意図からプロダクションレディなコードまで。各ステップをクリックして詳細を確認。
bmb_learn PRAISE。MODIFY → bmb_learn CORRECTION + 更新。NO → キャンセル。
bmb_learn MISTAKE + ユーザーにエスカレーション。
plan-to-exec.mdを読み取り。クロスモデルTesterはbriefing.mdを読み取り。異なるフレーミング、別々のworktree、別々のタイムアウト。互いの結果を読むことはありません。
bmb_learn MISTAKE + 分類されたループバックをトリガー。
bmb_learn MISTAKE + リバート + オリジナルで続行。
analytics.dbをクエリ。Bird’s Law重大度(critical / warn / info)でイベントを分類。pattern_countsをクロスリファレンスし、CLAUDE.mdプロモーション対象の再発障害(2回以上)を検出。analyst-report.mdを作成(3〜5分のタイムアウト、タイムアウト時はパイプライン続行)。
bmb_learn PRAISE。再発回数2以上をチェック → CLAUDE.mdプロモーションを提案。Gitコミット/プッシュ。FTS5インデックス作成。次のセッション用にsession-prep.mdを生成。
flowchart TD S1["1. Setup
tmux, session, learnings"] S2["2. Brainstorm + Consultant
min 2 rounds"] S3{"3. User Approval"} S4["4. Architecture Council
2-4 debate rounds"] S5["5. Execution
worktree-isolated"] S55["5.5 Merge Worktrees"] S6["6. Blind Testing
divergent framing"] S7["7. Blind Verification
divergent framing"] S8{"8. Reconciliation"} S9["9. Simplify + Re-verify"] S10["10. Docs Update"] S105["10.5 Retrospective Analysis
Bird's Law severity"] S11["11. Cleanup + Session Prep"] S1 --> S2 S2 --> S3 S3 -->|"YES"| S4 S3 -->|"MODIFY"| S2 S3 -->|"NO"| CANCEL["Cancel"] S4 -->|"skip: bugfix/infra"| S5 S4 --> S5 subgraph parallel ["Parallel Worktrees"] direction LR EX["Executor"] FE["Frontend
if detected"] end S5 --> parallel parallel --> S55 S55 --> S6 S6 --> S7 S7 --> S8 S8 -->|"PASS"| S9 S8 -->|"IMPL fail"| S5 S8 -->|"ARCH fail"| S4 S8 -->|"REQ fail"| S2 S8 -->|"ENV fail"| S1 S8 -->|"TEST fail"| S6 S9 --> S10 S10 --> S105 S105 --> S11 classDef decision fill:#1a1500,stroke:#d97706,color:#f59e0b classDef cancel fill:#2a0a0a,stroke:#ef4444,color:#ef4444 classDef step fill:#111827,stroke:#1e3a5f,color:#e8edf5 classDef parallel fill:#0a1628,stroke:#3b82f6,color:#60a5fa classDef analyst fill:#0a2010,stroke:#22c55e,color:#4ade80 class S3,S8 decision class CANCEL cancel class S1,S2,S4,S5,S55,S6,S7,S9,S10,S11 step class EX,FE parallel class S105 analyst
アーティファクトが.bmb/ディレクトリを通じてエージェント間でどのように流れるか。Leadはコードに一切触れず、サマリーのみ読み取ります。
flowchart LR User["👤 User"] Lead["🎯 Lead"] Brief["📋 briefing.md"] Arch["📐 Architect"] Plan["📄 plan-to-exec.md"] ExFe["⚙️ Executor
🎨 Frontend"] Merge["🔀 Merge"] Test["🧪 Tester
blind"] Verify["✅ Verifier
blind"] Recon["⚖️ Reconcile"] Simp["🧹 Simplifier"] Write["📝 Writer"] Output["✨ Output"] User -->|"intent"| Lead Lead -->|"brainstorm"| Brief Brief -->|"briefing"| Arch Arch -->|"council"| Plan Plan -->|"instructions"| ExFe ExFe -->|"worktrees"| Merge Merge -->|"merged code"| Test Merge -->|"merged code"| Verify Test -->|"test-summary"| Recon Verify -->|"verify-summary"| Recon Recon -->|"PASS"| Simp Simp -->|"cleaned"| Write Write --> Output classDef artifact fill:#1a2234,stroke:#3b82f6,color:#60a5fa classDef agent fill:#111827,stroke:#1e3a5f,color:#e8edf5 class Brief,Plan artifact class User,Lead,Arch,ExFe,Merge,Test,Verify,Recon,Simp,Write,Output agent
gantt
title Consultant Monitoring (Steps 2–11)
dateFormat X
axisFormat %s
section Brainstorm
Bidirectional with Lead :active, 0, 2
section Approval
Monitor user decision :1, 3
section Council
Observe debate rounds :2, 4
section Execution
Track progress via feed file :3, 6
section Testing
Monitor blind test results :5, 7
section Verification
Monitor blind verify results :6, 8
section Reconciliation
Observe failure classification :7, 9
section Simplify
Track re-verify outcome :8, 10
section Docs
Validate doc consistency :9, 11
section Cleanup
Final session summary :10, 12
結果に対してブラインドなだけでなく、問題のフレーミングが分岐。ワークスペースレベルのブラインド・クロスモデル検証。
すべての並列エージェントが独自のgit worktreeを取得。共有状態なし、index.lockの競合なし、真のファイルシステム分離。
gantt
title Worktree Lifecycle per Pipeline Run
dateFormat X
axisFormat Step %s
section Executor
Create worktree :e1, 4, 5
Work in worktree :e2, 5, 6
Merge to main :crit, e3, 6, 7
section Frontend
Create worktree :f1, 4, 5
Work in worktree :f2, 5, 6
Merge to main :crit, f3, 6, 7
section Tester-Claude
Create worktree :tc1, 6, 7
Run tests :tc2, 7, 8
Cleanup :tc3, 8, 9
section Tester-Cross
Create worktree :tx1, 6, 7
Run tests :tx2, 7, 8
Cleanup :tx3, 8, 9
section Verifier-Claude
Create worktree :vc1, 7, 8
Verify :vc2, 8, 9
Cleanup :vc3, 9, 10
section Verifier-Cross
Create worktree :vx1, 7, 8
Verify :vx2, 8, 9
Cleanup :vx3, 9, 10
Council討論はClaude ↔ Codex/Geminiのファイル交換を使用。プロファイルベースの権限で必要な場所を読み取り専用に維持。
sequenceDiagram participant A as Architect
(Claude Opus) participant F as Council Files
(.bmb/council/) participant X as Cross-Model
(Codex / Gemini) Note over A,X: Round 1 — Initial Proposals A->>F: Write claude-proposal.md X->>F: Write cross-proposal.md Note over A,X: Round 2 — Critique A->>F: Read cross-proposal.md A->>F: Write claude-critique.md X->>F: Read claude-proposal.md X->>F: Write cross-critique.md Note over A,X: Round 3 — Synthesis (optional) A->>F: Read cross-critique.md A->>F: Write claude-synthesis.md X->>F: Read claude-critique.md X->>F: Write cross-synthesis.md Note over A,X: Round 4 — Final Decision A->>F: Read all files A->>F: Write plan-to-exec.md ✅ Note right of X: Cross-Model uses
--profile read-only
councilとverifyプロファイル: クロスモデルはコードを読み取り、.bmb/にのみ書き込み可能。本番への書き込みなし。testとexec-assistプロファイル: クロスモデルはworktreeスコープ内でテストとヘルパーコードを書き込み可能。bmb-config.shで設定可能。独立したデッドライン追跡。Leadのコンテキストウィンドウは共有リソースです。3つのレイヤーにより、容量の50%を超えないことを保証します。
.compressed/*.summary.mdのみ読み取り(最大300トークン)。生のアーティファクトは紛争時のみアクセス。.tool-cache/にキャッシュ。サマリーのみ保持: "Modified: auth.ts (47 lines)"、"PASS: 12, FAIL: 0"。ミス、修正、成功が自動的に記録されます。過去の落とし穴が、すべてのプロジェクトの将来のセッションに注入されます。
.bmb/learnings.md — 学習ごとに1行、時系列で追記。ステップ1でこのプロジェクト用に読み込み。~/.claude/bmb-system/learnings-global.md — 同じ形式 + [project_name]タグ。すべてのBMBプロジェクト間で共有。6つのタスクタイプ、それぞれ最適化されたパイプラインパスを持ちます。Consultantはレシピに関係なく常に存在します。
4つのスラッシュコマンドがBMBの機能をさまざまなスケールで提供 — フルパイプラインからフォーカスされたブレインストーミングまで。
flowchart LR
Setup["/BMB-setup\n⚙️ Config"]
BMB["/BMB\n🔧 Full Pipeline"]
Brainstorm["/BMB-brainstorm\n💡 Ideation"]
Refactoring["/BMB-refactoring\n🔄 Code Quality"]
Setup -->|"prerequisite"| BMB
Setup -->|"prerequisite"| Brainstorm
Setup -->|"prerequisite"| Refactoring
Brainstorm -.->|"feeds into"| BMB
Refactoring -.->|"standalone"| BMB
style Setup fill:#111827,stroke:#22c55e,color:#e8edf5
style BMB fill:#111827,stroke:#3b82f6,color:#e8edf5,stroke-width:3px
style Brainstorm fill:#111827,stroke:#22d3ee,color:#e8edf5
style Refactoring fill:#111827,stroke:#a78bfa,color:#e8edf5
| フェーズ | /BMB | /BMB-brainstorm | /BMB-refactoring |
|---|---|---|---|
| セットアップ / 設定 | ✓ | ✓ | — |
| Consultantセッション | ✓ | ✓ | — |
| ブレインストーム / 分析 | ✓ | ✓ | ✓ 並列 |
| Council討論 | ✓ | — | ✓ 統合 |
| アーキテクチャ計画 | ✓ | — | — |
| 実行(Worktree) | ✓ | — | ✓ |
| テスト | ✓ | — | — |
| 検証(ブラインド) | ✓ | — | ✓ レビュー |
| 修正サイクル | ✓ | — | ✓ |
| 簡素化 | ✓ | — | — |
| マージ / クリーンアップ | ✓ | ✓ サマリー | ✓ |
パイプラインは決してブロックしません。すべての障害モードに定義されたフォールバックがあります。
| シナリオ | 動作 |
|---|---|
| クロスモデル利用不可(Council) | ソロ設計(Claude単体)、セッションログに記録 |
| クロスモデル利用不可(テスト) | Claude単体のテスト結果、照合に記録 |
| クロスモデル利用不可(検証) | Claude単体の検証、照合に記録 |
| Claude Testerタイムアウト | タイムアウトをログ、クロスモデルの結果で続行 |
| クロスモデルタイムアウト | Claude単体の結果で続行 |
| マージコンフリクト | bmb_learn MISTAKE + ユーザーにエスカレーション |
| Simplifierがテストを壊す | bmb_learn MISTAKE + リバート + オリジナルで続行 |
| Telegram環境変数未設定 | 通知をサイレントスキップ |
| knowledge.dbが存在しない | インデックス/検索をスキップ |
| フロントエンド未検出 | Frontendエージェントをスキップ、Executorのみ |
.bmb/ディレクトリはすべてのパイプラインアーティファクトの唯一の情報源です。