---
name: execute-group
description: |
  Run one parallel plan group produced by /generate-plan-groups. Validates
  the group hasn't drifted, runs an interactive cabinet pre-review (CP1) you
  decide on, then drives a two-workflow pipeline: mechanical parallel
  implementation + merge, an operator checkpoint, then advisory review +
  completion. Use when: "execute group", "run group", "/execute-group".
disable-model-invocation: true
argument-hint: "group label — e.g., '2026-05-30-1' (append --advisory to skip the CP1 pause)"
related:
  - type: skill
    name: generate-plan-groups
  - type: skill
    name: execute
  - type: file
    path: .claude/cabinet/checkpoint-protocol.md
    role: "The cabinet checkpoint mechanism — CP1 (interactive) and CP3 (advisory) both read it"
  - type: file
    path: .claude/workflows/execute-group-implement.js
    role: "Stage 2 — mechanical parallel implementation + sequential merge"
  - type: file
    path: .claude/workflows/execute-group-complete.js
    role: "Stage 3 — advisory CP3 + integration + completion report"
---

# /execute-group — Run a Generated Parallel Plan Group

## Purpose

`/generate-plan-groups` decides *what can run in parallel* and persists each
conflict-free group as pib-db `grp:` tags. This skill *runs one group* as a
**three-stage pipeline with operator checkpoints between stages**:

1. **Interactive CP1** (this skill, main session) — cabinet members pre-review
   the plans; *you* decide whether to proceed, drop plans, or pass overrides.
2. **Implementation workflow** (`execute-group-implement.js`) — parallel
   worktree implementation + sequential merge. Purely mechanical, no review.
3. **Review + completion workflow** (`execute-group-complete.js`) — advisory
   cabinet review of the merged diff, integration check, and completion report.

**Why this shape (and not one monolithic workflow):** an earlier design ran
CP1 and CP3 *inside* a single workflow as autonomous gates — a cabinet `stop`
halted the run or reverted a merge automatically. False positives in those
gates produced expensive halts (field evidence: a CP1 halted twice in a row,
1.6M+ tokens, on concerns the plan text already addressed). The fix:
**judgment belongs to the operator, automation stays mechanical.** CP1 is now
interactive (you see the findings and decide). CP3 is advisory (concerns are
recorded, never auto-halt/revert). The only hard, automatic gate is
**merge-delta `/validate`** — new failures relative to a baseline captured on
main before the first merge. A deterministic build check, not a judgment
call — and pre-existing main debt is reported loudly, never gated (two
consecutive groups were once gated on documented inherited debt with zero
merge-delta regressions; the manual recovery ran every time, so the delta
judgment was promoted into the gate itself).

**Why two workflows instead of direct Agent-tool spawning:** worktree agents
cannot spawn sub-agents (no Agent-tool access — empirically verified), so a
worktree agent cannot run its own checkpoints. CP1 escapes this by running at
the skill level (main session, where the Agent tool *is* available). Stages 2
and 3 are workflows because they need to spawn worktree/merge/review agents as
first-class parallel participants.

## Prerequisites

- The group must have been produced by `/generate-plan-groups` (its plans
  carry `grp:<label>`, `grp-generated:`, and `grp-hash:` tags).
- Plans must still have `## Surface Area` sections in their notes.
- The Workflow tool must be available (Stages 2 and 3 run as workflows).

## Honest ceiling — read before relying on this

- **No mid-implementation (CP2) review.** Worktree agents implement without a
  reviewer watching. CP1 reviews before, CP3 reviews after. For a plan whose
  diff is large or touches high-risk surface, run `/execute <plan>`
  individually instead — full `/execute` has the per-file-group checkpoint
  this path sacrifices for parallelism.
- **CP3 is advisory.** It surfaces concerns; it does not block completion.
  Only merge-delta `/validate` blocks (new failures vs the pre-merge
  baseline). A real problem invisible to `/validate` (e.g. a subtle
  behavioral regression) will land on main with an advisory note, not a
  revert. The operator must read the CP3 concerns in the report.
- **Inherited debt is not gated.** A failure that already existed on main
  before the group's first merge never blocks completion — it is listed
  loudly in the report's `pre_existing_debt` section instead. The gate stays
  hard for anything the group itself broke.
- **Surface area is intent, not reality.** Under-declared surface area can
  hide a semantic conflict the conflict graph missed.

## Workflow

### Step 0 — Environment precondition: the worktree-invocation contract

Running this skill from a mux/linked git worktree is the **normal case**,
not an error — do not refuse. **Read
`.claude/cabinet/worktree-invocation-contract.md` and follow it** — it
establishes the universal facts: detect a linked worktree, sync main into
it before any review or workflow, and resolve every completion artifact to
the MAIN checkout. Per-plan breadcrumbs and the Completion Report land
under `<main>/.claude/verification/` (each breadcrumb before any worktree
cleanup, the report before completion); nothing verification-critical is
written to the disposable worktree.

Two facts are specific to `/execute-group` and stay inline here — they
describe this skill's **merge model** and deliberately do NOT go in the
shared contract (they would contradict `/execute`'s no-merge model):

- **The workflows ignore your cwd by design.** Stage 2's
  `isolation: worktree` implementation agents branch from MAIN and merge
  into MAIN regardless of the invoking checkout — the invoking worktree is
  never the merge target and never receives the group's commits directly
  (it picks them up on its next `git merge main`).
- **Escape hatch — inline build.** For a small, conflict-free group you may
  skip the worktree machinery and implement the plans inline in the
  invoking checkout, then merge once. Use it when worktree overhead exceeds
  the parallelism gain; the staleness guard, CP1, and the completion-report
  contract still apply.

### Step 1 — Staleness guard (BEFORE any review or workflow)

The persisted group is a hint, not a contract. Re-validate against *current*
state:

1. **Fetch the group's plans.** Query actions whose `tags` contain
   `grp:<label>` (the argument, minus any `--advisory` flag). Use `pib_query`
   (or `node scripts/pib-db.mjs query`):
   ```sql
   SELECT a.fid, a.text, a.notes, a.tags
   FROM actions a
   WHERE a.completed = 0 AND a.deleted_at IS NULL
     AND a.tags LIKE '%grp:<label>%'
   ```

2. **Drop plans that are no longer open or lost their surface area.** Report
   each dropped plan and why.

3. **Recompute the surface-area hash and compare.** Recompute it **exactly as
   `/generate-plan-groups` did**: for every still-open plan in the group, parse
   its `## Surface Area` file/dir list, concatenate all entries across the
   group, sort, and hash. Compare to the `grp-hash:` token stored on the plans.
   - **Hash matches** → the group is current. Proceed.
   - **Hash differs** → a plan's surface area changed since grouping. **HALT:**
     > Group `<label>` has drifted since it was generated (surface areas
     > changed). Re-run `/generate-plan-groups` to regroup, then
     > `/execute-group` again.
     Do not run a stale group — the conflict-free guarantee no longer holds.

4. **Edge cases:**
   - **0 plans survive** → tell the user the group is empty (all
     drifted/closed) and stop. Do not launch any workflow.
   - **1 plan survives** → you may still run it (Stages 2/3 skip the
     group-level aggregate review for a single plan), or suggest
     `/execute <plan>` directly. Single-plan groups gain nothing from the
     parallel machinery.

### Step 2 — Select cabinet members

Select the cabinet members CP1 and CP3 will use. From
`.claude/skills/_index.json`: members whose `standingMandate` includes
`execute`, plus any whose file patterns match the group's aggregate surface
area. For each, collect `{ key, agentType, path, directive }` (`agentType` is
the registered `cabinet-<name>` subagent; `directive` is `directives.execute`
if present).

If the project has no cabinet members, skip CP1 and tell the user the run
proceeds without review (implementation + `/validate` only).

### Step 2.5 — Interactive CP1 (this skill, main session)

Spawn one Agent per selected cabinet member **in a single message** (parallel).
Each agent must read `.claude/cabinet/checkpoint-protocol.md` and
follow it, scoped to `pre-impl` (interactive CP mode) — then its own
SKILL.md at `path`, the project briefing, and the plans' full notes. Each returns this verdict shape (note the **required
`addressed_by_plan`** field — CP1 only):

```
CP1_VERDICT_SCHEMA:
{
  "cabinet_member": "name",
  "addressed_by_plan": ["risks the plan already handles — enumerate FIRST"],
  "verdict": "continue" | "pause" | "stop",
  "concerns": [
    { "description": "...", "evidence": "...", "severity": "blocking" | "advisory" }
  ]
}
```

`addressed_by_plan` is required to force plan-first review: the agent must
enumerate what the plan already covers *before* raising concerns. A concern
the plan explicitly handles must not be raised — this is the discipline whose
absence caused the false-positive halts.

**Present findings to the operator severity-first**, not verdict-first:
1. **Blocking concerns** (any `severity: blocking`) — listed first, with
   member + evidence.
2. **Advisory concerns** — next.
3. **Addressed-by-plan** — collapsed to a one-line count ("12 risks the plans
   already cover") unless the operator asks to expand.

Then **the operator decides** — this is the checkpoint, not an automatic gate:
- If any agent returned `stop` or raised a blocking concern:
  > A cabinet member recommends stopping: [concern]. Proceed anyway, drop the
  > affected plan from this run, or abort?
- Otherwise summarize and ask: **"Launch implementation?"**

Capture the operator's response as:
- `operatorOverrides`: an array of free-text directives to pass into the
  implementation agents (e.g. "skip plan X", "watch the migration ordering").
  Empty array if none.
- `cp1Findings`: the structured CP1 verdicts (recorded in the final report).

**`--advisory` flag:** if the argument includes `--advisory`, still run the
CP1 agents and record `cp1Findings`, but **skip the operator pause** — print
the severity-first summary and proceed straight to Stage 2 with no overrides.
Use this for low-risk groups where you trust the plans.

**All CP1 agents errored:** if every agent failed to return a verdict, do not
silently proceed. Warn:
> Cabinet review failed (no agent returned a verdict). Proceed without review
> or abort?

### Step 3a — Launch the Implementation workflow (Stage 2)

Invoke the Workflow tool:

- **script:** `.claude/workflows/execute-group-implement.js`
- **args:**
  ```json
  {
    "label": "<label>",
    "plans": [{ "fid": "...", "text": "...", "notes": "...", "surfaceArea": "..." }],
    "operatorOverrides": ["...optional operator directives from CP1..."],
    "knownDebt": ["...optional: operator-blessed pre-existing /validate failures from CP1 — fallback baseline used ONLY if the workflow's own baseline capture fails..."]
  }
  ```
  Pass `plans`, `operatorOverrides`, and `knownDebt` as real JSON (not
  stringified).

The workflow captures a `/validate` baseline on main **before the first
merge** (the inherited-debt reference for the delta gate), then returns a
structured result: `{ label, plans_implemented, validate_baseline, per_plan,
merged, loose_ends }`. **Present it plainly:**
> N of M plans merged. [list any failed/parked/noop plans and their reasons
> from `loose_ends`; if `validate_baseline.failures` is non-empty, say "K
> pre-existing /validate failure(s) on main — inherited debt, not gated"].

Then **operator checkpoint:** "Continue to review + completion?" Wait for
confirmation before Stage 3. If nothing merged, say so and ask whether to stop
(Stage 3 has nothing to review).

### Step 3b — Launch the Review + Completion workflow (Stage 3)

Invoke the Workflow tool:

- **script:** `.claude/workflows/execute-group-complete.js`
- **args:**
  ```json
  {
    "label": "<label>",
    "mergedPlans": [ ...the `merged` array from Stage 2's result... ],
    "implPerPlan": [ ...the `per_plan` array from Stage 2's result (all plans, not just merged)... ],
    "validateBaseline": { ...the `validate_baseline` object from Stage 2's result — REQUIRED for delta-gate semantics; omitting it degrades the gate to absolute... },
    "cabinetMembers": [{ "key": "...", "agentType": "cabinet-...", "path": "...", "directive": "..." }],
    "cp1Findings": [ ...the CP1 verdicts captured in Step 2.5... ],
    "checkpointProtocolPath": ".claude/cabinet/checkpoint-protocol.md",
    "briefingPath": ".claude/cabinet/_briefing.md"
  }
  ```

The workflow runs advisory CP3 over the aggregate diff, the integration check
(merge-delta `/validate` against `validateBaseline` + breadcrumb audit), and
completion (it writes the Completion Report to the **MAIN checkout's**
`.claude/verification/group-<label>-report.json` **before** marking plans
done, then marks merged plans done itself). It returns the Completion Report.

### Step 4 — Present the Completion Report

Present it plainly: which plans completed, the advisory CP3 concerns (call
these out — they are the operator's to weigh), the integration result, the
`pre_existing_debt` section (inherited main failures — call these out too;
they are reported, not gated, and someone should own fixing them), any new
pib-db actions created for deferred manual ACs, and the `loose_ends`. The
report on disk (in the **main checkout's** `.claude/verification/`) is also
the evidence the completion gate (`action-completion-gate.sh`) checks for
`grp:`-tagged plans — don't discard it.

If completion was gated (final `/validate` found **new** failures vs the
pre-merge baseline), report exactly which failures are new; the merged plans
are left **open** for the operator to fix and re-run. Inherited baseline
failures never gate.

#### Recovery steps for parked/failed plans

- **Merged & completed** — done.
- **Parked / failed implementation / no result** — the worktree branch (if
  any) is preserved. To retry individually with full cabinet checkpoints
  (including the per-file-group CP2 the group path skips), **strip the `grp:`
  tags first**, then run `/execute <plan>`. If you don't strip the tags, the
  completion gate blocks because the report shows the plan as not-merged.
  Strip with: `pib_update_action --tags "<non-grp-tags-only>"`.

Re-running `/generate-plan-groups` automatically replaces stale `grp:` tags on
any plans it re-groups — but only for plans it selects.

## Principles

- **Judgment to the operator, automation mechanical.** CP1 is an interactive
  decision; CP3 is advisory; merge-delta `/validate` is the only automatic
  gate — and it gates only what the group broke, never inherited debt.
- **The group is a hint, not a contract.** Always re-validate (Step 1) before
  running. Regenerate freely.
- **Operator checkpoints between stages.** You see CP1 findings before
  implementation and merge results before review+completion. Each is a real
  decision point, not a rubber stamp.
- **Sequential merges, parallel everything else.** Merges into main are
  serialized with `/validate` between them; CP1, implementation, and CP3 run
  in parallel.
- **Honest about the ceiling.** For high-risk plans, prefer individual
  `/execute`.
