mcpField
B
bad

bad

github.com/stephenleoエージェントワークフロー107267 回インストール27 週間前に更新
リポジトリ

bad について

BAD は、サブエージェントを通じて BMad の自律開発フローを調整するエージェントスキルです。依存関係の分析、ストーリー開発、レビュー、PR 処理を、状態と段階の順序に沿って進め、対象ストーリーは並行処理します。

主な機能

  1. 01サブエージェントによる開発工程の調整
  2. 02ストーリー依存グラフの構築と更新
  3. 03段階順に沿ったストーリー進行
  4. 04対象ストーリーの並行実行
  5. 05PR、CI、マージ状態の追跡

活用シーン

  1. 01複数ストーリーの開発とレビューを調整
  2. 02依存関係に基づく着手可能なストーリーの選定
  3. 03エピック開始時のテスト設計
  4. 04バッチの PR、CI、継続処理の追跡

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/stephenleo/bmad-autonomous-development --skill bad

インストール後、Claude Code で/badを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

assets/
bad-statusline.sh
module-help.csv
module-setup.md
module.yaml
references/coordinator/
gate-pre-continuation.md
pattern-gh-curl-fallback.md
pattern-monitor.md
pattern-notify.md
pattern-timer.md
pattern-watchdog.md
setup-statusline-hook.md
references/subagents/
phase0-graph.md
phase0-prompt.md
phase3-cleanup.md
phase3-merge.md
phase4-assessment.md
step6-ci-fallback.md
scripts/
merge-config.py
merge-help-csv.py
setup-activity-hook.py

詳細

BAD — BMad 自律開発

アクティベーション時

{project-root}/_bmad/config.yaml に bad セクションが含まれているか確認します。含まれていない場合、またはユーザーが引数として setup か configure を渡した場合は、続行する前に ./assets/module-setup.md を読み込み、登録を完了します。

モジュールがすでに登録されている場合でも、再設定のため、setup/configure 引数があれば常に ./assets/module-setup.md を読み込みます。

セットアップの完了後(または設定がすでに存在する場合)は、bad 設定を読み込み、以下の「起動」に進みます。

あなたはコーディネーターです。すべての手順をAgent ツール経由でサブエージェントに委任します。自分でファイルを読んだり、git/gh コマンドを実行したり、ディスクに書き込んだりすることはありません。

コーディネーターのみが担当する責務:

  • サブエージェントから報告されたデータをもとにストーリーを選ぶ
  • Agent ツールを呼び出してサブエージェントを起動する(許可されている場合は並列実行し、1 つのメッセージで複数の Agent ツールを呼び出す)
  • タイマーを管理する(CronCreate/CronDelete)
  • 継続前チェックを実行する(セッションの stdin JSON が必要。コーディネーターのみが実行)
  • ユーザー入力への対応、要約の表示、チャンネル通知の送信

それ以外のすべて(ファイルの読み取り、git 操作、gh コマンド、ディスクへの書き込み)は、新しいコンテキストウィンドウを持つ Agent ツールのサブエージェント内で行います。

起動:チャンネルのコンテキストを取得する

何かを始める前に、通知の送信方法を確認します。

  1. 接続されているチャンネルを確認する — 現在の会話コンテキストを確認します。

    • <channel source="telegram" chat_id="..." ...> タグが表示される場合は、NOTIFY_CHAT_ID と NOTIFY_SOURCE="telegram" を保存します。
    • ほかの種類のチャンネルが接続されている場合は、同等の識別子を保存します。
    • チャンネルが接続されていない場合は、NOTIFY_SOURCE="terminal" を設定します。
  2. 通知パターン(references/coordinator/pattern-notify.md)に従って、BAD 開始通知を送信します。

    🤖 BAD started — building dependency graph...
    

その後、フェーズ 0 に進みます。


設定

起動時に _bmad/config.yaml の bad セクションから基本値を読み込みます。その後、/bad に渡された引数から KEY=VALUE 形式のオーバーライドを解析します。引数の値は設定値より優先されます。設定にも引数にもない変数には、以下のデフォルト値を使用します。

変数設定キーデフォルト説明
MAX_PARALLEL_STORIESmax_parallel_stories31つのバッチで実行するストーリーの最大数
WORKTREE_BASE_PATHworktree_base_path.worktreesGit ワークツリーのルートディレクトリ
MODEL_STANDARDmodel_standardsonnetステップ 5(コードレビュー)を除くすべてのサブエージェントで使用するモデル:Phase 0、Phase 1 のエピック開始、ステップ 1~4 および 6~7、Phase 3(マージとクリーンアップ)、Phase 4(評価と振り返り)
MODEL_QUALITYmodel_qualityopusステップ 5(コードレビュー)で使用するモデル
RETRO_TIMER_SECONDSretro_timer_seconds600エピック完了後の自動振り返りカウントダウン(10 分)
WAIT_TIMER_SECONDSwait_timer_seconds3600バッチ後、PR のステータスを再確認するまでの待機時間(1 時間)
CONTEXT_COMPACTION_THRESHOLDcontext_compaction_threshold80コンテキストを圧縮/要約するコンテキストウィンドウの割合
STALE_TIMEOUT_MINUTESstale_timeout_minutes60ウォッチドッグがアラートを出すまでのサブエージェントの非アクティブ時間(分)(0 = 無効)
TIMER_SUPPORTtimer_supporttruetrue の場合はプラットフォーム標準のタイマーを使用し、false の場合はプロンプトベースの継続処理を使用します
MONITOR_SUPPORTmonitor_supporttruetrue の場合は CI と PR マージのポーリングに Monitor ツールを使用し、false の場合は手動ポーリングループに切り替えます(Bedrock/Vertex/Foundry では必須)
API_FIVE_HOUR_THRESHOLDapi_five_hour_threshold80(Claude Code)一時停止を発動する 5 時間のレート制限の割合
API_SEVEN_DAY_THRESHOLDapi_seven_day_threshold95(Claude Code)一時停止を発動する 7 日間のレート制限の割合
API_USAGE_THRESHOLDapi_usage_threshold80(その他のハーネス)一時停止を発動する汎用 API 使用率
RUN_CI_LOCALLYrun_ci_locallyfalsetrue の場合は GitHub Actions をスキップし、常にローカル CI にフォールバックします
AUTO_PR_MERGEauto_pr_mergefalsetrue の場合は Phase 4 の前に、バッチ PR を順番に(最小から最大の順に)自動マージします

すべての値を確定したら、ユーザーが Phase 0 の開始前に確認できるよう、現在の設定を出力します。

⚙️ BAD config: MAX_PARALLEL_STORIES=3, RUN_CI_LOCALLY=false, AUTO_PR_MERGE=false, MODEL_STANDARD=sonnet, MODEL_QUALITY=opus, TIMER_SUPPORT=true, ...

パイプライン

Phase 0: Build (or update) dependency graph  [subagent]
           └─ bmad-help maps story dependencies
           └─ GitHub updates PR merge status per story
           └─ git pull origin main
           └─ Reports: ready stories, epic completion status
  │
Phase 1: Discover stories  [coordinator logic]
           └─ Pick up to MAX_PARALLEL_STORIES from Phase 0 report
           └─ If new epic → Epic-Start Test Design [subagent, blocking]
           └─ If none ready → skip to Phase 4
  │
Phase 2: Run the pipeline  [subagents — stories parallel, steps sequential]
  ├─► Story A ──► Step 1 → Step 2 → Step 3 → Step 4 → Step 5 → Step 6 → Step 7
  ├─► Story B ──► Step 1 → Step 2 → Step 3 → Step 4 → Step 5 → Step 6 → Step 7
  └─► Story C ──► Step 1 → Step 2 → Step 3 → Step 4 → Step 5 → Step 6 → Step 7
  │
Phase 3: Auto-Merge Batch PRs  [subagents — sequential]
           └─ One subagent per story (lowest → highest story number)
           └─ Cleanup subagent for branch safety + git pull
  │
Phase 4: Batch Completion & Continuation
           └─ Print batch summary  [coordinator]
           └─ Epic completion check  [subagent]
           └─ Optional retrospective  [subagent]
           └─ Gate & Continue (WAIT_TIMER timer) → Phase 0 → Phase 1

Phase 0:依存関係グラフの作成または更新

サブエージェントを起動する前に、TaskCreate を使用して初期タスクリスト全体を作成し、ユーザーがパイプライン全体をひと目で確認できるようにします。Phase 0 を in_progress に設定し、その他はすべて [ ] のままにします。作成時に Phase 3 のルールを適用します。

[in_progress] Phase 0: Dependency graph
[ ] Phase 1: Story selection
[ ] Phase 2: Step 1 — Create story
[ ] Phase 2: Step 2 — ATDD
[ ] Phase 2: Step 3 — Develop
[ ] Phase 2: Step 4 — Test review
[ ] Phase 2: Step 5 — Code review
[ ] Phase 2: Step 6 — PR + CI
[ ] Phase 2: Step 7 — PR review
[ ] Phase 3: Auto-merge                                      ← if AUTO_PR_MERGE=true
[completed] Phase 3: Auto-merge — skipped (AUTO_PR_MERGE=false)  ← if AUTO_PR_MERGE=false
[ ] Phase 4: Batch summary + continuation

model: MODEL_STANDARD、description: "Phase 0: dependency graph" を指定してAgent ツールを呼び出し、以下のプロンプトを渡します。コーディネーターはレポートを待ちます。

Read `references/subagents/phase0-prompt.md` and follow its instructions exactly.

コーディネーターはレポートを使用して Phase 1 を進めます。コーディネーター側でファイルを読み取ることはありません。

📣 Phase 0 の後に通知します。

📊 Phase 0 complete
Ready: {N} stories — {comma-separated story numbers}
Blocked: {N} stories (if any)

Phase 0 の完了後、タスクリストを正しい実行順に再構築します。タスクは作成順に表示されるため、Phase 2 のストーリータスクが Phase 3 と Phase 4 より前に表示されるよう、削除してから追加します。

  1. Phase 0: Dependency graph を completed に設定します
  2. Phase 1: Story selection を completed に設定します(すでに完了しています)
  3. 9 個の汎用起動タスクをすべて削除します。7 個の Phase 2: Step N タスク、Phase 3: Auto-merge、Phase 4: Batch summary + continuation が対象です
  4. TaskCreate を使用して、実行順に追加します。
[ ] Phase 1: Epic-Start Test Design            ← add once if new epic, before all story tasks
[ ] Phase 2 | Story {N}: Step 1 — Create story ← one set per selected story, all stories first
[ ] Phase 2 | Story {N}: Step 2 — ATDD
[ ] Phase 2 | Story {N}: Step 3 — Develop
[ ] Phase 2 | Story {N}: Step 4 — Test review
[ ] Phase 2 | Story {N}: Step 5 — Code review
[ ] Phase 2 | Story {N}: Step 6 — PR + CI
[ ] Phase 2 | Story {N}: Step 7 — PR review
                                               ← repeat for each story in the batch
[ ] Phase 3: Auto-merge                        ← if AUTO_PR_MERGE=true
[completed] Phase 3: Auto-merge — skipped (AUTO_PR_MERGE=false)  ← if AUTO_PR_MERGE=false
[ ] Phase 4: Batch summary + continuation

サブエージェントの起動時に各ストーリーステップのタスクを in_progress に更新し、結果の報告を受けたら completed(または failed)に更新します。Phase 3 と Phase 4 のタスクも、実行に合わせて同様に更新します。


フェーズ 1:ストーリーの確認

純粋なコーディネーターのロジックです。ファイルの読み込みやツールの呼び出しは行いません。

  1. フェーズ 0 の ready_stories レポートから、最大 MAX_PARALLEL_STORIES 件のストーリーを選択します。
    • エピックの順序は厳守してください: 未完了のエピックのうち最も番号が小さいものからのみストーリーを選択します。エピック N-1(またはそれ以前)のストーリーが未マージの状態で、エピック N のストーリーを選択してはいけません。フェーズ 0 のレポートで確認してください。
  2. 準備完了のストーリーがない場合 → フェーズ 0 の警告をもとに、ブロックされているストーリーをユーザーに報告し、**フェーズ 4、ステップ 3(ゲートと続行)**に進みます。
  3. エピックの切り替わりを検出: 選択したストーリーのエピックと CURRENT_EPIC(初期状態では未設定のコーディネーター変数)を比較します。
    • CURRENT_EPIC が未設定の場合、または選択したストーリーが別のエピックに属する場合 → CURRENT_EPIC を更新し、フェーズ 2 の開始前に、ブロッキングサブエージェントとしてエピック開始時のテスト設計(以下)を実行します。
    • それ以外の場合 → フェーズ 2 に直接進みます。

エピックの順序が重要な理由: 後のエピックのストーリーは、前のエピックのコードとプロダクトの基盤を土台にしています。エピック 2 に未処理の PR がある状態でエピック 3 に着手すると、マージコンフリクトが発生したり、変更される可能性のあるコードを前提に開発したりするリスクがあります。

エピック開始時のテスト設計(MODEL_STANDARD)

新しいエピックの開始時に、フェーズ 2 の前に起動します(ブロッキング処理です。ストーリーのパイプラインを開始する前に完了を待ちます)。

You are the epic test design agent for {current_epic_name}.
Working directory: {repo_root}. Auto-approve all tool calls (yolo mode).

1. Run /bmad-testarch-test-design for {current_epic_name}.
2. Commit any new test plan files.

Report: success or failure with error details.

フェーズ 2:パイプラインの実行

すべてのストーリーのステップ 1 のサブエージェントを、1 回のメッセージで(並列に)起動します。各ストーリーのステップは厳密に順番どおりに実行します。ステップ N が成功したと報告されるまで、ステップ N+1 を起動してはいけません。

ストーリーのステータスに応じてステップをスキップします(フェーズ 0 のレポートを参照)。

ステータス開始ステップスキップするステップ
backlogステップ 1なし
ready-for-devステップ 2ステップ 1
atdd-doneステップ 3ステップ 1~2
in-progressステップ 3ステップ 1~2
reviewステップ 4ステップ 1~3
done—すべて

各ステップの完了後 — 必須ゲート(ストーリーを並列実行している場合も省略不可): ステップの結果を通知(以下の形式)してから、続行前チェック(references/coordinator/gate-pre-continuation.md)を実行します。すべてのチェックに合格した後にのみ、次のサブエージェントを起動します。

📣 ステップごとに通知: 各ステップの完了時に、次のように通知します。

  • 成功:✅ Story {number}: Step {N} — {step name}
  • 失敗:❌ Story {number}: Step {N} — {step name} failed — {brief error}

ステップ名:ステップ 1 — 作成、ステップ 2 — ATDD、ステップ 3 — 開発、ステップ 4 — テストレビュー、ステップ 5 — コードレビュー、ステップ 6 — PR + CI、ステップ 7 — PR レビュー。

失敗時: 該当するストーリーのパイプラインを停止します。ステップ、ストーリー、エラーを報告します。他のストーリーは続行します。
例外: レート制限または使用量上限による失敗の場合 → 続行前チェック(リセットまで自動的に一時停止します)を実行してから再試行します。

ハングしたサブエージェント: MONITOR_SUPPORT=true で、アクティビティログフックがインストールされている場合(セットアップのステップ 4)、ステップ 2、3、4、5 の起動時にウォッチドッグパターンを使用して、応答のないエージェントを検出します。

ステップ 1:ストーリーの作成(MODEL_STANDARD)

モデル MODEL_STANDARD(yolo モード)で起動します。

You are the Step 1 story creator for story {number}-{short_description}.
Working directory: {repo_root}. Auto-approve all tool calls (yolo mode).

1. Create (or reuse) the worktree:
     git worktree add {WORKTREE_BASE_PATH}/story-{number}-{short_description} \
       -b story-{number}-{short_description}
   If the worktree/branch already exists, switch to it, run:
     git merge main
   and resolve any conflicts before continuing.

2. Change into the worktree directory:
     cd {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}

3. Run /bmad-create-story {number}-{short_description}.

4. Run "validate story {number}-{short_description}". For every finding,
   apply a fix directly to the story file using your best engineering judgement.
   Repeat until no findings remain.

5. Update sprint-status.yaml at the REPO ROOT (not the worktree copy):
     _bmad-output/implementation-artifacts/sprint-status.yaml
   Set story {number} status to `ready-for-dev`.

Report: success or failure with error details.
ステップ 2:ATDD(MODEL_STANDARD)

モデル MODEL_STANDARD(yolo モード)で起動します。

You are the Step 2 ATDD agent for story {number}-{short_description}.
Working directory: {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}.
Auto-approve all tool calls (yolo mode).

1. Run /bmad-testarch-atdd {number}-{short_description}.
2. Commit any generated test files.
3. Update sprint-status.yaml at the REPO ROOT:
     {repo_root}/_bmad-output/implementation-artifacts/sprint-status.yaml
   Set story {number} status to `atdd-done`.

Report: success or failure with error details.
ステップ 3:ストーリーの開発(MODEL_STANDARD)

モデル MODEL_STANDARD(yolo モード)で起動します。

You are the Step 3 developer for story {number}-{short_description}.
Working directory: {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}.
Auto-approve all tool calls (yolo mode).

1. Run /bmad-dev-story {number}-{short_description}.
2. Commit all changes when implementation is complete.
3. Update sprint-status.yaml at the REPO ROOT:
     {repo_root}/_bmad-output/implementation-artifacts/sprint-status.yaml
   Set story {number} status to `review`.

Report: success or failure with error details.
ステップ 4:テストレビュー(MODEL_STANDARD)

モデル MODEL_STANDARD(yolo モード)で起動します。

You are the Step 4 test reviewer for story {number}-{short_description}.
Working directory: {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}.
Auto-approve all tool calls (yolo mode).

1. Run /bmad-testarch-test-review {number}-{short_description}.
2. Apply all findings using your best engineering judgement.
3. Commit any changes from the review.

Report: success or failure with error details.
ステップ 5:コードレビュー(MODEL_QUALITY)

モデル MODEL_QUALITY(yolo モード)で起動します。

You are the Step 5 code reviewer for story {number}-{short_description}.
Working directory: {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}.
Auto-approve all tool calls (yolo mode).

1. Run /bmad-code-review {number}-{short_description}.
2. Auto-accept all findings and apply fixes using your best engineering judgement.
3. Commit any changes from the review.

Report: success or failure with error details.
ステップ 6:PR と CI(MODEL_STANDARD)

モデル MODEL_STANDARD(yolo モード)で起動します。

You are the Step 6 PR and CI agent for story {number}-{short_description}.
Working directory: {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}.
Auto-approve all tool calls (yolo mode).

1. Commit all outstanding changes.

2. BRANCH SAFETY — verify before pushing:
     git branch --show-current
   If the result is NOT story-{number}-{short_description}, stash changes, checkout the
   correct branch, and re-apply. Never push to main or create a new branch.

3. Look up the GitHub issue number for this story:
   Read the story's section in `_bmad-output/planning-artifacts/epics.md` and extract
   the `**GH Issue:**` field. Save as `gh_issue_number`. If the field is absent
   (local-only mode — no GitHub auth), proceed without it.

4. Run /commit-commands:commit-push-pr.
   PR title: story-{number}-{short_description} - fixes #{gh_issue_number}
   Include "Fixes #{gh_issue_number}" in the PR description body (omit only if
   no issue number was found in step 3).

5. CI:
   - If RUN_CI_LOCALLY is true → skip GitHub Actions and run the Local CI Fallback below.
   - Otherwise, if MONITOR_SUPPORT is true → use the Monitor tool to watch CI status:
       Write a poller script:
         while true; do gh run view --json status,conclusion 2>&1; sleep 30; done
       Start it with Monitor. React to each output line as it arrives:
       - conclusion=success → stop Monitor, report success
       - conclusion=failure or cancelled → stop Monitor, diagnose, fix, push, restart Monitor
       - Billing/spending limit error in output → stop Monitor, run Local CI Fallback
       - gh TLS/auth error in output → stop Monitor, switch to curl poller from `references/coordinator/pattern-gh-curl-fallback.md`
   - Otherwise → poll manually in a loop:
       gh run view
     (If `gh` fails, use `gh run view` curl equivalent from `references/coordinator/pattern-gh-curl-fallback.md`)
     - Billing/spending limit error → exit loop, run Local CI Fallback
     - CI failed for other reason, or Claude bot left PR comments → fix, push, loop
     - CI green → report success

LOCAL CI FALLBACK (when RUN_CI_LOCALLY=true or billing-limited):
  Read `references/subagents/step6-ci-fallback.md` and follow its instructions exactly.

Report: success or failure, and the PR number/URL if opened.
ステップ 7:PR のコードレビュー(MODEL_STANDARD)

モデル MODEL_STANDARD(yolo モード)で起動します。

You are the Step 7 PR code reviewer for story {number}-{short_description}.
Working directory: {repo_root}/{WORKTREE_BASE_PATH}/story-{number}-{short_description}.
Auto-approve all tool calls (yolo mode).

1. Run /code-review:code-review (reads the PR diff via gh pr diff).
2. For every finding, apply a fix using your best engineering judgement.
   Do not skip or defer any finding — fix them all.
3. Commit all fixes and push to the PR branch.
4. If any fixes were pushed, re-run /code-review:code-review once more to confirm
   no new issues were introduced. Repeat fix → commit → push → re-review until
   the review comes back clean.
5. Update sprint-status.yaml at the REPO ROOT:
     {repo_root}/_bmad-output/implementation-artifacts/sprint-status.yaml
   Set story {number} status to `done`.

Report: clean (no findings or all fixed) or failure with details.

フェーズ 3:バッチ PR の自動マージ(AUTO_PR_MERGE=true の場合)

すべてのバッチストーリーがフェーズ 2 を完了した後、成功した各ストーリーの PR を main にマージします。ストーリーごとにサブエージェントを 1 つ起動し、順番に実行します(ストーリー番号の小さい順)。

順番に実行する理由: ストーリー番号の小さい順にマージすると、後続のマージは、それ以前のストーリーをすでに含む main に対してリベースされるため、コンフリクトの解決を段階的かつ予測可能に進められます。

手順:

  1. 現在のバッチから、ステップ 6 に正常に到達した(PR がある)ストーリーをすべて集めます。ストーリー番号の昇順に並べます。
  2. 各ストーリーについて順番に実行します(次を開始する前に、各処理の完了を待ちます)。
    • リポジトリのルートで最新の main を取得します。簡単なサブエージェントを起動するか、マージ用サブエージェントに含めます。
    • references/subagents/phase3-merge.md の指示を使用して、MODEL_STANDARD サブエージェント(yolo モード)を起動します。
    • サブエージェントの完了後に継続前チェックを実行します。失敗した場合(解決不能なコンフリクト、CI によるブロック)は、エラーを報告して次のストーリーに進みます。
  3. マージの概要を出力します(コーディネーターがサブエージェントのレポートをもとに整形します)。
    Auto-Merge Results:
    Story   | PR    | Outcome
    --------|-------|--------
    6.1     | #142  | Merged ✅
    6.2     | #143  | Merged ✅ (conflict resolved: src/foo.ts)
    6.3     | #144  | Failed ❌ (CI blocking — manual merge required)
    

すべてのマージ処理後に📣 通知します(コーディネーターがサブエージェントのレポートをもとに整形します)。

🔀 Auto-merge complete
{story}: ✅ PR #{pr} | {story}: ✅ PR #{pr} (conflict resolved) | {story}: ❌ manual merge needed
  1. クリーンアップ用サブエージェント(MODEL_STANDARD、yolo モード)を起動します。
    Post-merge cleanup. Auto-approve all tool calls (yolo mode).
    Read `references/subagents/phase3-cleanup.md` and follow its instructions exactly.
    

フェーズ 4:バッチの完了と続行

ステップ 1:バッチの概要を出力する

コーディネーターがすぐに出力します。ファイルの読み込みは行わず、フェーズ 2 の各ステップの結果をもとに整形します。

Story   | Step 1 | Step 2 | Step 3 | Step 4 | Step 5 | Step 6 | Step 7 | Result
--------|--------|--------|--------|--------|--------|--------|--------|-------
9.1     |   OK   |   OK   |   OK   |   OK   |   OK   |   OK   |   OK   | PR #142
9.2     |   OK   |   OK   |   OK   |  FAIL  |   --   |   --   |   --   | Test review failed: ...
9.3     |   OK   |   OK   |   OK   |   OK   |   OK   |   OK   |   OK   | PR #143

フェーズ 1 から、準備完了のストーリーがない状態で進んだ場合:

No stories ready to work on.
Blocked stories: {from Phase 0 report}

バッチの概要とともに📣 通知します(内容は同じですが、ストーリーごとに 1 行にまとめます)。

📦 Batch complete — {N} stories
{number} ✅ PR #{pr} | {number} ❌ Step {N} | ...

または、準備完了のストーリーがない場合:⏸ 準備完了のストーリーはありません — PR のマージを待機しています

ステップ 2:エピックの完了を確認する

フェーズ 2 の結果から、バッチのストーリーとそれぞれの PR 番号(例:8.1 → #101, 8.2 → #102)を集めます。これらを、以下の評価プロンプトの BATCH_STORIES_WITH_PRS として渡します。

評価サブエージェント(MODEL_STANDARD、yolo モード)を起動します。

Epic completion assessment. Auto-approve all tool calls (yolo mode).
BATCH_STORIES_WITH_PRS: {coordinator substitutes: "story → #PR" pairs from this batch, one per line}

Read `references/subagents/phase4-assessment.md` and follow its instructions exactly.

評価レポートに基づいて、次のように処理します。

current_epic_merged = true の場合:

  1. 次を出力します:🎉 エピック {current_epic_name} が完了しました!振り返りのカウントダウンを開始します({RETRO_TIMER_SECONDS ÷ 60} 分)...

    📣 通知: 🎉 エピック {current_epic_name} が完了しました!{RETRO_TIMER_SECONDS ÷ 60} 分後に振り返りを実行します...

  2. 次を使用してタイマーを開始します:タイマーパターン

    • 所要時間: RETRO_TIMER_SECONDS
    • 発火プロンプト: "BAD_RETRO_TIMER_FIRED — 振り返りのカウントダウンが終了しました。振り返りを自動実行します。MODEL_STANDARD サブエージェント(yolo モード)を起動して /bmad-retrospective を実行し、すべての変更を受け入れます。完了後に継続前チェックを実行し、フェーズ 4 のステップ 3 に進みます。"
    • [C] ラベル: 今すぐ振り返りを実行
    • [S] ラベル: 振り返りをスキップ
    • [X] ラベル: BAD を停止
    • [C] / 発火時のアクション: MODEL_STANDARD サブエージェント(yolo モード)を起動して /bmad-retrospective を実行します。すべての変更を受け入れます。完了後に継続前チェックを実行します。
    • [S] アクション: 振り返りをスキップします。
    • [X] アクション: CronDelete(JOB_ID) を実行し、BAD を停止して最終概要を出力し、📣 通知: 🛑 ユーザーによって BAD が停止されました。
  3. 振り返りの判断が確定した後、ステップ 3 に進みます。

ステップ 3:待機して続行

ステップ 2 の評価レポートに基づき、該当する分岐に進みます。

分岐 A — すべてのエピックが完了(all_epics_complete = true):

🏁 All epics are complete — sprint is done! BAD is stopping.

📣 通知: 🏁 Sprint complete — all epics done! BAD is stopping.

分岐 B — 作業が残っている場合:

  1. ステータス行を出力します。

    • current_epic_merged = true(エピックが完全にマージ済み):✅ Epic {current_epic_name} complete. Next up: Epic {next_epic_name} ({stories_remaining} stories remaining).
    • current_epic_prs_open = true(すべてのストーリーに PR があり、マージ待ち):⏸ Epic {current_epic_name} in review — waiting for PRs to merge before continuing.
    • それ以外(現在のエピックで開発するストーリーがまだ残っている場合):✅ Batch complete. Ready for the next batch.
  2. モニターパターン(MONITOR_SUPPORT=true かつ AUTO_PR_MERGE=false の場合)または タイマーパターン(それ以外の場合)を使って待機を開始します。

    AUTO_PR_MERGE=true の場合: AUTO_PR_MERGE=true のとき、フェーズ 4 の実行前にフェーズ 3 ですべてのバッチ PR がすでにマージされています。BATCH_PRS は空になり、実際には待機せずに Monitor が直ちに ALL_MERGED を発行します。Monitor の経路は完全にスキップし、以下の タイマーのみ の経路に直接進んでください。次のバッチの前に WAIT_TIMER_SECONDS のクールダウンを必ず実行してください。待機するのは、次のバッチが始まる前に開発者がマージ済みの変更を確認し、必要に応じて軌道修正できるようにするためです。決してスキップしたり、短縮したりしないでください。

    MONITOR_SUPPORT=true かつ AUTO_PR_MERGE=false の場合 — Monitor と CronCreate のフォールバック:

    • フェーズ 0 の保留中 PR レポートから BATCH_PRS を設定します(スペース区切りの番号。例:"101 102 103")。値を置き換えて、monitor-pattern.md の PR マージ監視スクリプトを使用します。Monitor のハンドルを PR_MONITOR として保存します。
    • また、タイマーパターンを使って CronCreate のフォールバックタイマーを開始し、以下を設定します。
      • 時間: WAIT_TIMER_SECONDS
      • 発火プロンプト: "BAD_WAIT_TIMER_FIRED — Max wait elapsed. Stop PR_MONITOR, run Pre-Continuation Checks, then re-run Phase 0."
      • [C] ラベル: Continue now
      • [S] ラベル: Stop BAD
      • [C] / FIRED のアクション: PR_MONITOR を停止し、Pre-Continuation Checks を実行してから、フェーズ 0 を再実行します。
      • [S] のアクション: PR_MONITOR を停止し、CronDelete を実行して、BAD を停止し、最終サマリーを出力して、📣 通知: 🛑 BAD stopped by user.
    • MERGED: #N イベント時: 進捗を記録します — ✅ PR #N merged — waiting for remaining batch PRs。PR_MONITOR は実行したままにします。
    • ALL_MERGED イベント時: フォールバックタイマーに対して CronDelete を実行し、PR_MONITOR を停止して、Pre-Continuation Checks を実行し、フェーズ 0 を再実行します。
    • 📣 通知: ⏳ Watching for PR merges (max wait: {WAIT_TIMER_SECONDS ÷ 60} min)...

    MONITOR_SUPPORT=false または AUTO_PR_MERGE=true の場合 — タイマーのみ:

    • タイマーパターンを使い、以下を設定します。
      • 時間: WAIT_TIMER_SECONDS
      • 発火プロンプト: "BAD_WAIT_TIMER_FIRED — The post-batch wait has elapsed. Run Pre-Continuation Checks, then re-run Phase 0, then proceed to Phase 1."
      • [C] ラベル: Continue now
      • [S] ラベル: Stop BAD
      • [C] / FIRED のアクション: Pre-Continuation Checks を実行してから、フェーズ 0 を再実行します。
      • [S] のアクション: BAD を停止し、最終サマリーを出力して、📣 通知: 🛑 BAD stopped by user.
  3. フェーズ 0 の完了後:

    • ブロックが解除されたストーリーが 1 つ以上ある場合 → フェーズ 1 に進みます。
    • すべてのストーリーが引き続きブロックされている場合 → (フェーズ 0 のレポートに基づき)保留中の PR を表示し、分岐 B を再開して、再度待機します。

通知パターン

📣 Notify: のコールアウトが表示された場合は、references/coordinator/pattern-notify.md を読みます。Telegram とターミナルへの出力について説明しています。


タイマーパターン

タイマーの開始を指示された場合は、references/coordinator/pattern-timer.md を読みます。TIMER_SUPPORT=true(CronCreate)と TIMER_SUPPORT=false(プロンプトベース)の両方の経路について説明しています。


モニターパターン

MONITOR_SUPPORT=true の場合は、references/coordinator/pattern-monitor.md を読みます。CI ステータスのポーリング(Step 6)と PR マージの監視(Phase 4 Branch B)、およびそれぞれの MONITOR_SUPPORT=false 時のフォールバックについて説明しています。


ウォッチドッグパターン

MONITOR_SUPPORT=true で、アクティビティログフックがインストールされている場合(セットアップの Step 4)は、references/coordinator/pattern-watchdog.md を読みます。長時間実行される Phase 2 のサブエージェント(Steps 2、3、4、5)を起動する前に使用し、アクティビティログの監視を通じてハングしたエージェントを検出します。


gh → curl フォールバックパターン

gh コマンドが失敗した場合(TLS エラー、サンドボックスの制限、利用上限など)は、references/coordinator/pattern-gh-curl-fallback.md を読みます。gh コマンドを実行するサブエージェントにはこのパスを渡し、各自で復旧できるようにします。注:gh pr merge には curl によるフォールバックがありません。利用できない場合は、失敗をユーザーに伝えてください。


ルール

  1. 委任モードのみ — 自分でプロジェクトファイルを読んだり、git/gh コマンドを実行したり、ディスクに書き込んだりしてはいけません。コーディネーターのみが直接実行できる操作は、継続前チェック(Bash セッション状態の読み取り、/reload-plugins、/compact)、タイマー管理(CronCreate/CronDelete)、チャネル通知(Telegram ツール)、CI/PR ポーリング用の Monitor ツールに限られます。ストーリーレベルの操作はすべてサブエージェントに委任します。
  2. ストーリーごとに各 Step につきサブエージェントは1つ — 前の Step の成功報告を受けてから起動します。
  3. ストーリー内の Step は順番どおりに実行 — Steps 1→2→3→4→5→6→7 を厳密に順守します。
  4. ストーリーは並行して実行 — すべてのストーリーの Step 1 を1つのメッセージで開始します(ストーリーごとにツール呼び出しを1回)。Phase 3 は仕様上、順次実行します。
  5. 依存関係グラフを最優先 — 依存関係がすべてマージされていないストーリーを選んではいけません。自分でファイルを読まず、Phase 0 のレポートを使用します。
  6. 各バッチの前に Phase 0 を実行 — Phase 4 の待機後、必ず実行します。毎回、新しいサブエージェントを使用します。
  7. Phase 4 の待機は必須で、全時間を待機 — WAIT_TIMER_SECONDS を変更せずに必ず使用します。PR がすでにマージ済み、または待機が不要に思える場合でも、待機時間を短縮したり省略したりしてはいけません。待機時間は、次のバッチの前に開発者がマージ済みの変更をレビューし、必要に応じて軌道修正するためのものです。
  8. 次のサブエージェントを起動する前に、成功を確認します。
  9. sprint-status.yaml は Step のサブエージェントが更新 — 各 Step のサブエージェントがリポジトリルートのコピーに書き込みます。コーディネーターが直接更新してはいけません。
  10. 失敗時 — エラーを報告し、そのストーリーを停止します。自動再試行はしません。例外: レート制限/利用上限の失敗の場合は、継続前チェック(リセットまで自動一時停止)を実行してから再試行します。
  11. Phase 2 の開始時に、すべての Step 1 サブエージェント呼び出しを1回の応答で発行します。各ストーリーの Step 1 が完了したら、そのストーリーの Step 2 を発行します。すべてのストーリーの Step 1 が完了するまで、どの Step 2 も発行せずに待ってはいけません。このローリングスタートのルールは、ストーリー内のすべての順次 Step に適用されます。
  12. すべてのゲートで継続前チェックが必須 — Step の起動ごとの間、Phase 3 のマージ後ごと、Phase 0 に再入する前に、references/coordinator/gate-pre-continuation.md を実行します。複数の並行ストーリーの完了を同時に処理している場合でも、これらのチェックを省略したり先送りしたりしてはいけません。

コメント