本文へ移動
cccskills
無料GitHub で公開

work-milestone

Executes a groomed milestone with parallel kage-bunshin sessions in isolated worktrees. Use when a milestone has been groomed and /groom-milestone has produced a dispatch plan. Reads the dispatch plan, creates an integration branch, spawns one kage-bunshin (independent claude -p process) per wave item in its own worktree — each session is a full orchestrator with the Agent tool. Sequentially merges worktree branches, relays wave discoveries to subsequent waves, then lands the integration branch to main. Takes a milestone number as argument.

インストール方法を見る

含まれるファイル(3)

  • SKILL.md17.0 KB
  • references/merge-queue-protocol.md5.6 KB
  • references/worktree-worker-protocol.md7.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

/work-milestone

Execute a groomed milestone. Reads the dispatch plan produced by /groom-milestone, creates an integration branch, spawns parallel kage-bunshin sessions (independent claude -p processes) per wave — each in its own worktree with full orchestrator capabilities (Agent tool, all MCP servers). Sequentially merges their branches and lands the integration branch to main when all waves complete.

Entry Conditions

  • Milestone number provided as argument
  • Dispatch plan exists and readable via dispatch_read(milestone_number=N)
  • All items in dispatch plan are groomed (groomed: true)
  • Backlog MCP and SAM MCP responding
  • Clean git state on main (if dirty, run plugins/development-harness/scripts/prepare_clean_worktree.sh {integration-branch} and accept/reject the stash prompt)

Run /groom-milestone {N} first if the dispatch plan is missing or stale.

Main Workflow

The diagram's plan queries and ledger-row outcome checks apply to items with SAM plans. For items without one, use the text-only branch of Agent Result Handling in place of those checks for outcomes and unresolved scope; keep the milestone setup, execution and merge gates.

flowchart TD
    Start(["Input: milestone number N"]) --> LoadPlan["Step 1: Load Dispatch Plan<br>Call dispatch_read(milestone_number=N)<br>Output: waves, conflict groups, quality gates"]

    LoadPlan --> Validate{"Step 2: Validate Plan<br>Plan found?<br>All items still open?<br>Observable: dispatch_read result + backlog_list_issues(milestone=N)"}

    Validate -->|"Plan missing"| Block1(["BLOCKED — run /groom-milestone {N}"])
    Validate -->|"Items changed since groom"| Regroom["Re-run /groom-milestone {N}"]
    Validate -->|"Plan valid"| CreateBranch
    Regroom --> LoadPlan

    CreateBranch["Step 3: Create Integration Branch<br>github_branches create (GitHub backend only)<br>Fallback (beads backend): git checkout -b milestone/{N}-{slug} origin/main<br>Branch: milestone/{N}-{slug} — when backend=beads, N is the beads ID (e.g. bd-a3f8)<br>Switch to integration branch locally.<br>Run prepare_clean_worktree.sh before any worktree add."]

    CreateBranch --> FetchItems["Step 3b: Fetch All Items Once<br>Call backlog_view once per issue in the dispatch plan.<br>Store results in context keyed by issue number.<br>DO NOT call backlog_view again for any issue<br>already fetched this session."]

    FetchItems --> WaveLoop["Step 4: Wave Dispatch Loop<br>Read next wave from dispatch plan"]

    WaveLoop --> WaveItems{"Wave has items?"}
    WaveItems -->|"No waves remain"| Land

    WaveItems -->|"Yes"| CreateWorktrees["Step 5a: Create Worktrees<br>For each item in wave:<br>git worktree add worktrees/{slug}<br>from integration branch"]

    CreateWorktrees --> WriteLocks["Step 5b: Write Lock Files<br>For each worktree:<br>Write .claude/kage-bunshin.lock<br>(prevents recursive spawning)"]

    WriteLocks --> SpawnSessions["Step 5c: Spawn Kage-Bunshin Sessions<br>For each worktree: cd into it, then:<br>claude -p --model {model} [--effort {level}]<br>--permission-mode auto --output-format json<br>'Load /dh:work-backlog-item #{issue}'<br>Each session is a FULL orchestrator —<br>has the Agent tool, all MCP.<br>All sessions launch as background processes."]

    SpawnSessions --> WaitReturn["Step 6: Wait for All Sessions<br>Poll PIDs for exit.<br>Read result JSON from each<br>/tmp/kb-work-{issue}.json"]

    WaitReturn --> CheckResults{"Step 6a: Any sessions failed?"}
    CheckResults -->|"All succeeded"| ParseResults
    CheckResults -->|"Some failed"| InvestigateFail{"Fixable?"}
    InvestigateFail -->|"Yes"| FixRetry["Fix and re-spawn<br>failed item only"]
    FixRetry --> WaitReturn
    InvestigateFail -->|"No"| SkipFailed["Skip failed item<br>Log to output"]
    SkipFailed --> ParseResults

    ParseResults["Step 6b: Read Outcomes<br>plan status --plan-address {plan_ref} per item<br>for each task's status and result.<br>Extract BRANCH, FILES_CHANGED, COMMITS, NOTES<br>from the report body in each result JSON."]

    ParseResults --> MergeLoop["Step 6b: Merge Worktree Branches<br>Sequential merge into integration branch.<br>One at a time, in return order."]

    MergeLoop --> MergeResult{"Any merge conflicts?"}
    MergeResult -->|"All clean"| WaveComplete
    MergeResult -->|"Trivial/Medium conflict"| Resolve["Auto-resolve or spawn<br>conflict-resolution agent"]
    Resolve --> ResolveGates{"Resolution gates pass?"}
    ResolveGates -->|"Yes"| WaveComplete
    ResolveGates -->|"No"| EscalateConflict["Create backlog item<br>for conflict resolution.<br>Add to milestone."]

    MergeResult -->|"Heavy conflict (3+ files)"| EscalateConflict

    WaveComplete["Step 6c: Wave Complete<br>All branches merged.<br>Delete worktree branches."]

    WaveComplete --> DiscoveryRelay["Step 6d: Discovery Relay<br>Build relay document from agent outputs.<br>Include FILES_CHANGED, COMMITS, NOTES<br>in next wave agent prompts."]

    DiscoveryRelay --> PartialCheck{"Any task rows blocked or failed<br>on the ledger?"}
    PartialCheck -->|"Yes"| HandlePartial["Create backlog items for<br>blocked tasks. Add to milestone."]
    PartialCheck -->|"No"| NextWaveCheck

    HandlePartial --> NextWaveCheck{"More waves?"}
    NextWaveCheck -->|"Yes"| WaveLoop
    NextWaveCheck -->|"No"| Land

    Land["Step 8: Land Integration Branch<br>Run full quality gate suite<br>pre_merge + post_merge"]

    Land --> FinalResult{"Gates pass?"}
    FinalResult -->|"Fail"| FinalFix["Spawn fix agent in worktree<br>on integration branch."]
    FinalFix --> Land

    FinalResult -->|"Pass"| MergeMain["Step 9: Merge to Main<br>git switch main<br>git merge --no-ff milestone/{N}-{slug}<br>git push origin main"]

    MergeMain --> Complete["Step 10: Complete Milestone<br>/complete-milestone {N}.<br>Delete integration branch.<br>Print pending auto-stash reminder(s)."]

    Complete --> Done(["Exit: milestone complete"])

Step 3a: Prepare Clean Worktree Source State

Before Step 5 creates any worktree, run:

PREP="plugins/development-harness/scripts/prepare_clean_worktree.sh"
"$PREP" "${INTEGRATION_BRANCH}"

Behavior:

  • If git status --porcelain is clean, continue silently.
  • If dirty, prompt exactly: Stash uncommitted changes? [y/N].
  • On y, stash with message dh-auto-stash: pre-run {integration-branch} and record the stash ref in ~/.dh/projects/{slug}/context/auto-stashes.json keyed by integration branch name.
  • On N (or Enter), halt the run with a clear instruction to stash or commit manually before re-invoking /work-milestone.

Step 3b: Fetch All Items Once (Before Any Wave)

Before entering the wave dispatch loop, call backlog_view once per issue listed across all waves in the dispatch plan. Store each result in context keyed by issue number.

Use the already-fetched data for all subsequent references — wave loop iterations, discovery relay construction, result reporting. If an item's state genuinely changes (e.g., after a backlog_update call), replace the cached value with a single new backlog_view call for that issue only.

Pass the fetched data (title, AC, description) into spawned session prompts directly rather than having each spawned session re-fetch — see Step 5c prompt construction.

Dispatch Step (Step 5 Detail)

All items in a wave are independent by construction (guaranteed non-overlapping by the conflict group analysis in the dispatch plan). Each item gets its own worktree and its own kage-bunshin session — an independent claude -p process with full orchestrator capabilities.

Worktree + Session Setup Per Item

Use the kage-bunshin spawn script — it handles worktree creation, .venv/node_modules symlinking, lock file writing, and process launch:

SPAWN="plugins/development-harness/skills/kage-bunshin/scripts/spawn.py"
MODEL="${MODEL:-sonnet}"
PIDS=()
SPAWN_INFO=()

for ISSUE in "${WAVE_ISSUES[@]}"; do
  OUTPUT=$($SPAWN --worktree \
    --branch "${INTEGRATION_BRANCH}" \
    --name "work-item-${ISSUE}" \
    --model "${MODEL}" \
    "Load /dh:work-backlog-item #${ISSUE}. Execute the full work flow. \
     You are in a worktree on integration branch ${INTEGRATION_BRANCH}. \
     Use MCP tools for plan artifact discovery — plan/ files are in the root worktree. \
     Prior wave context: ${DISCOVERY_RELAY}")
  PIDS+=($(echo "$OUTPUT" | python3 -c "import sys,json; print(json.load(sys.stdin)['pid'])"))
  SPAWN_INFO+=("$OUTPUT")
done

What the Spawned Session Gets

Via the prompt:

  • Issue number (from dispatch plan wave item)
  • Integration branch name (from dispatch plan)
  • Discovery relay content from prior waves (orchestrator-accumulated, empty for wave 1)
  • Instruction to use MCP for artifact discovery

Via capability inheritance (automatic):

  • All MCP servers (backlog, SAM, artifact registry)
  • All skills (including /dh:work-backlog-item which it loads and executes)
  • All agent types (it CAN and WILL spawn sub-agents as needed)
  • Full tool access (Agent, Read, Write, Edit, Bash, etc.)

Via self-discovery (the session does this itself):

  • Groomed description and acceptance criteria — via backlog_view(selector="#{issue}")
  • Plan artifacts — via artifact_list(item_id={issue}) then artifact_read(...)
  • SAM task plan — via sam_plan if a plan exists
  • Skills to load — from skills field in SAM task metadata

Monitoring and Result Collection

# Wait for all sessions in the wave to exit
for i in "${!PIDS[@]}"; do
  wait "${PIDS[$i]}"
  EXIT_CODE=$?
  INFO="${SPAWN_INFO[$i]}"
  RESULT_FILE=$(echo "$INFO" | python3 -c "import sys,json; print(json.load(sys.stdin)['result_file'])")

  if [ $EXIT_CODE -eq 0 ] && [ -s "$RESULT_FILE" ]; then
    echo "$(python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('result','')[:200])" < "$RESULT_FILE")"
  else
    ERROR_FILE=$(echo "$INFO" | python3 -c "import sys,json; print(json.load(sys.stdin)['error_file'])")
    echo "FAILED (exit ${EXIT_CODE}): $(tail -5 "$ERROR_FILE")"
  fi
done

Model Selection

The --model flag on the kage-bunshin controls the spawned session's orchestrator model only. Sub-agents spawned inside that session use their own model per their agent frontmatter definition.

Recommended: --model sonnet for spawned sessions (configurable via dispatch_spawn model parameter). Use --effort to tune reasoning depth independently of model selection.

Step 10 Reminder: Pending Auto-Stashes

After milestone completion, check ~/.dh/projects/{slug}/context/auto-stashes.json. If there is a stash ref for the integration branch, print:

Auto-stash ref {ref} pending; run 'git stash pop {ref}' to restore.

Agent Result Handling

Before interpreting a returned response, load dh:subagent-contract. When self-discovery found a SAM plan, query plan status --plan-address {plan_ref} first and branch on the durable rows; use the returned report as evidence for judging them. The diagram below applies to that branch.

When no SAM plan exists, skip the plan query and judge the report against the item's acceptance criteria and quality gates. Apply the contract's nonledger status rules: use completed work and its evidence to judge what can be merged, and carry any unmet scope into a backlog item with the observed failure or blocker and the action needed to proceed. Escalate when no acceptable work can be recovered. A text-only response does not imply an attempt was closed.

flowchart TD
    Result(["Agent returned"]) --> Read["plan status --plan-address {plan_ref}"]
    Read --> Status{"Task rows for this item"}
    Status -->|"All complete"| Merge["Proceed to merge"]
    Status -->|"Some complete, some blocked or failed"| Partial["Merge completed work.<br>Create backlog item for the blocked or failed tasks,<br>carrying each row's note.<br>Add to current milestone."]
    Status -->|"None complete, or STATUS: BLOCKED with no finish recorded"| Failure["Log failure context.<br>Escalate to user:<br>item title, error, agent output summary."]

Discovery Relay Between Waves

After all wave agents return, the orchestrator builds a relay document from their completion reports. This is injected as discovery_relay_content in the next wave's agent prompts.

## Prior Wave Results

### Wave 1 Results

#### Item: #{issue1} — {title1}
- Status: {from plan rows when present; otherwise the judged item criteria and unresolved scope}
- Files changed: {file_list}
- Key commits:
  - {hash}: {message}
- Design notes: {notes_if_any}

#### Item: #{issue2} — {title2}
- Status: {from plan rows when present; otherwise the judged item criteria and unresolved scope}
- Files changed: {file_list}
- Key commits:
  - {hash}: {message}

Items in the same wave are guaranteed non-overlapping by the dispatch plan's conflict group analysis. The relay provides cross-wave awareness for items with depends_on relationships or shared conflict groups.

For milestones with 5+ waves, cap the relay at the most recent 3 waves.

Merge Conflict Classification

Conflict scopeClassificationAction
0 filesCleanMerge immediately
1-2 files — whitespace or adjacent additionsTrivialAuto-resolve, run gates
1-2 files — same function edited differentlyMediumSpawn conflict-resolution agent
1-2 files — file restructured by both worktreesHeavyCreate backlog item for conflict resolution
3+ filesHeavyAbort merge, create backlog item

Conflict resolution agent receives both branches' diffs and resolves in-place on the integration branch. No PRs are created for worktree branches — they are local-only, never pushed to origin.

Tools Used

ToolPurpose
dispatch_read(milestone_number=N)Read dispatch plan via MCP
dispatch_wave_startRegister wave + items in dispatch state DB before spawning (Step 5)
dispatch_spawnBackground MCP task that launches parallel kage-bunshin sessions for a wave (Step 5c)
dispatch_wave_statusPoll wave progress and detect stale PIDs (Step 6)
dispatch_item_statusCalled by spawned sessions to record completion or failure
git worktree addCreate isolated worktree per wave item
claude -p (kage-bunshin)Spawn independent orchestrator session per item — has the Agent tool, all MCP
backlog_viewRead item description, AC, design decisions (used by spawned sessions)
artifact_listDiscover plan artifacts registered for an issue (used by spawned sessions)
artifact_readRead plan artifact content from root worktree via MCP (used by spawned sessions)
sam_planRead SAM task plan for an item (used by spawned sessions)
sam_planCheck whether item has a SAM plan (used by spawned sessions)
github_branches createCreate integration branch (GitHub backend only — use git checkout -b when backend=beads)
github_branches mergeMerge worktree branch into integration branch (GitHub backend only — use git merge when backend=beads)
github_branches deleteDelete integration branch after landing (GitHub backend only — use git branch -d when backend=beads)
run_quality_gatesExecute gate commands from dispatch plan
backlog_list_issues(milestone=N)Validate plan against current item state

Error Conditions

  • Dispatch plan missing: BLOCKED — direct to /groom-milestone {N}
  • Items changed since groom: re-run /groom-milestone {N} to regenerate plan
  • Backlog MCP unavailable: PROCESS ERROR — report with exact error text
  • SAM MCP unavailable: PROCESS ERROR — report with exact error text
  • Integration branch already exists: check for stale branch (no commits in 7+ days) — offer to delete and recreate, or resume
  • Kage-bunshin session exited non-zero: read error log, investigate if fixable, re-spawn if yes, skip item if no
  • Item's plan has blocked or failed task rows after its session returned: create backlog items for those tasks carrying each row's note, add to milestone, continue with other items
  • All quality gates fail on integration branch: escalate to user before landing
  • Main diverged during milestone work: rebase integration branch onto main before landing

References

  • Worktree Worker Protocol — full worker lifecycle: setup, direct task execution, quality gates, completion report format, blocker handling, skill loading
  • Merge Queue Protocol — merge slot lifecycle, conflict classification, conflict-resolution agent, quality gate commands

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Add automated documentation updater to any Claude skill. Creates a Python sync script that downloads upstream docs, processes markdown for AI consumption, and maintains local cache with configurable refresh. Collects template variables, then delegates implementation through 5-phase workflow. Use when adding auto-updating reference documentation to plugins or skills.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月12日 更新

SAM-style feature initiation workflow — discovery through codebase analysis, architecture spec, task decomposition, validation, and context manifest. Use when a user asks to add a feature, plan a feature, or convert an idea into an executable SAM plan.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月12日 更新

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月12日 更新

Browser automation for AI agents using the agent-browser CLI and Playwright. Use when navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, logging into sites, or automating any browser task. Triggers on "open a website", "fill out a form", "click a button", "scrape data", "test this web app", "automate browser actions", or any programmatic web interaction request.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月12日 更新

Runs the description-drift experiment — spawns all Claude Code agents simultaneously to collect self-reported capabilities, then compares them against static frontmatter descriptions to reveal how reliable orchestrator routing based on descriptions actually is. Use when measuring description drift across the agent fleet, re-running the capability collection experiment, analyzing a specific agent's self-reported capabilities, or auditing whether frontmatter descriptions accurately reflect agent behavior.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月12日 更新

Create or adapt Claude Code agent definitions. Use when creating an agent, changing subagent configuration, selecting agent scope, or designing a specialized delegation role.

日本語の概要は準備中です。原文の説明を表示しています。

Jamie-BitFlight/claude_skills672026年10月12日 更新

Jamie-BitFlight のスキルをすべて見る

このスキルの問題を報告する