The execute stage of a Change, run by the bdk:lead agent that /bdk:execute starts (and /bdk:auto-review for the fix parts of a review round) - takes the waves of the plan parts from bdk plan check, builds the parts one at a time in plan order in the main checkout through implement-part and conform-part, retries and escalates within the budget, commits each part on the Change branch, stops at the first blocked part, runs the wave check after each wave and has repair-wave repair a red one, and ...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Execute Waves?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/broneq-execute-waves)
---
name: execute-waves
description: 'The execute stage of a Change, run by the bdk:lead agent that /bdk:execute starts (and /bdk:auto-review for the fix parts of a review round) - takes the waves of the plan parts from bdk plan check, builds the parts one at a time in plan order in the main checkout through implement-part and conform-part, retries and escalates within the budget, commits each part on the Change branch, stops at the first blocked part, runs the wave check after each wave and has repair-wave repair a red one, and writes state.json and execute/result.md. Use when the bdk:lead agent is started with a prompt naming bdk:execute-waves and a Change. Not for users: /bdk:execute is the command.'
argument-hint: "<change> --run-dir <absolute path> [--parts <absolute dir>]"
user-invocable: false
allowed-tools: Bash(${CLAUDE_PLUGIN_ROOT}/bin/bdk *) Bash(mkdir -p *) Bash(git *) Read Write Grep Glob Agent
---
Current BDK configuration of this project:
!`"${CLAUDE_PLUGIN_ROOT}/bin/bdk" config show`
Arguments: $ARGUMENTS
# Execute waves
Build every part of a Change's plan in the main checkout, one part at a time: waves in order, the parts of a wave in ascending order, each part implemented, then conformed, then committed on the Change branch, then the wave checked whole. You compose; the workers build. You never write or fix product code, tests, plans or specs. You are the only writer of `state.json` and the only one who commits.
When the block above says `BDK not configured` or `BDK configuration invalid`, reply with that line and stop. If it shows the command instead of its output, run `"${CLAUDE_PLUGIN_ROOT}/bin/bdk" config show` first.
## 0. Run as `bdk:lead`
This skill runs on the `bdk:lead` agent, whose instructions start with "You are `bdk:lead`". When you are not that agent, do nothing: reply that `/bdk:execute <change>` runs the execute stage, and stop.
Done when you are `bdk:lead`.
## 1. Read the inputs
- **Change**: the first argument.
- **Parts**: `--parts <dir>` when given, an absolute directory such as the fix parts of a review round (`<run dir>/review/round-<N>/fixes/parts`); else `<run dir>/plan/parts/`. It must hold parts; otherwise stop at step 8 with the blocker `no plan: run /bdk:plan <change>` (with `--parts`: `no parts in <dir>`).
- **State file and result file**: with `--parts`, `state.json` and `result.md` in the directory that holds the parts directory (`<run dir>/review/round-<N>/fixes/`), never in the parts directory, where `bdk plan check` takes every other `.md` for a misnamed part; else `<run dir>/state.json` and `<run dir>/execute/result.md`. Never write the other pair: the plan's state stays the plan's, and `bdk run status` reads it.
- With `--parts`, a blocker this skill would send to `/bdk:plan <change>` names the part file in the parts directory instead: its author (`plan-fixes`) fixes it, through `/bdk:auto-review <change>`. A blocker that would name `/bdk:execute <change>` names `/bdk:auto-review <change>` instead: `/bdk:execute` builds plan parts only.
- **Run directory**: `--run-dir <path>`, an absolute path. Without it, take `.bdk/runs/<change>` under the path `git rev-parse --show-toplevel` prints. Run `mkdir -p <run dir>/execute`. Pass this absolute path to every worker.
- **Settings** from the configuration above, with their defaults: `policy.budgets.part-attempts` (3), `policy.escalation.model` (the most capable model; the configuration above prints its value), and `policy.escalation.effort`, `models.implementer.model`, `models.implementer.effort`, `models.conformer.model` and `models.conformer.effort` when set.
- **State**: the state file when it exists. Its schema:
```json
{"version": 1, "parts": {"01": {"status": "done", "attempts": 1}, "02": {"status": "blocked", "attempts": 3, "reason": "plan-defect: task 2 contradicts Scenario: Empty list"}}}
```
and, once a wave has started, `"waves": {"1": {"base": "<commit>", "status": "done"}}`: the Change branch's commit before the wave's first part ran, and the wave check's state (step 6).
`status` is `pending`, `done` or `blocked`; `attempts` counts every implementer run of the part, in every execute run; a wave's `reason` holds why it is blocked. Whenever this skill says "write the state", write the whole state file with every part of the parts directory, a part without an entry as `pending` with 0 attempts, and every wave it holds.
With `--parts`, add ` --parts <parts dir>` to every worker prompt below (`implement-part`, `conform-part`, `repair-wave`).
Done when you hold the Change, the parts, the run directory, the settings and the state.
## 2. Waves
Run `"${CLAUDE_PLUGIN_ROOT}/bin/bdk" plan check <parts dir> --json`. It exits 1 when it reports a problem; read the result anyway.
- A part with `wave: null`, or a `frontmatter` problem: the order of the work is unknown, or a part is not readable. Start nothing, change nothing, and go to step 8 with the blocker naming the problems and `/bdk:plan <change>`.
- Any other problem (`max-tasks`, `max-files`, `max-bytes`, `present-scenario`): note it for `Decisions taken without the user` and go on.
The order of the work: waves in ascending order, the parts of a wave in ascending id. Parts of one wave may touch the same files: each runs on the commits of the parts before it.
Done when you hold the parts in order.
## 3. Branch and tree
1. `git status --porcelain` must print nothing (ignored files never show), with one exception: the earlier work of the part that runs next. Take the first part, in order, that is not `done`; when the state records at least one attempt of it and every listed path is one of its `files`, the paths are that part's work from an earlier run: keep them, and its implementer continues from them. Otherwise, when it lists paths, stop at step 8 with the blocker `uncommitted changes: <paths>; commit or stash them, then run /bdk:execute again`.
2. The base branch: `git symbolic-ref --short refs/remotes/origin/HEAD` without its `origin/` prefix; else `main`. When `git branch --show-current` prints the base or nothing, run `git switch -c <change>`; when that branch exists already, stop at step 8 naming it. The Change's commits never land on the base.
Write the state. Done when you are on the Change's branch with a clean tree, or one holding only the kept earlier work.
## 4. Prepare the wave
Take the first wave that holds a part not `done` or whose state in `waves` is not `done`; when there is none, go to step 8. When every part of it is `done` (an earlier run ended before its wave check), go to step 6. When the state has no `waves.<n>` for it, record its base now, before any part runs: `waves.<n>` = `{"base": "<git rev-parse HEAD>", "status": "pending"}`, and write the state. Its parts not `done` are this wave's parts, in ascending order. Each part gets a fresh budget in this run: `policy.budgets.part-attempts` implementer runs.
Done when the wave's base is in the state.
## 5. Run the parts, one at a time
Take the wave's parts in ascending order. For each part, repeat until it is `done` or `blocked`:
1. **Implement.** Add 1 to its `attempts` and write the state. Start one foreground Agent call (`run_in_background: false`):
- `subagent_type: "bdk:implementer"`, prompt `Run the skill bdk:implement-part with the arguments: <change> <id> --run-dir <run dir>`;
- `model`: `policy.escalation.model` when this is the part's last run within this run's budget; else `models.implementer.model` when set; else no `model`.
- `effort`: on the part's last run, `policy.escalation.effort` when set, else `models.implementer.effort` when set; on an earlier run, `models.implementer.effort` when set; else no `effort`.
2. **Read** `<run dir>/execute/part-<id>.md`, its first line and, for a blocker, its `## Blocker` section:
- `Status: done`: the part goes to conform.
- `Status: blocker` with `Kind: plan-defect` or `Kind: environment`: mark the part `blocked` at once, with the kind and the evidence as `reason`. A retry cannot fix a plan or install a tool.
- `Status: blocker` with `Kind: other`, or no report: retry the part while its budget lasts; when spent, mark it `blocked` with the last reason.
3. **Conform.** Start one foreground Agent call (`run_in_background: false`): `subagent_type: "bdk:conformer"`, prompt `Run the skill bdk:conform-part with the arguments: <change> <id> --run-dir <run dir>`, and `model` `models.conformer.model` and `effort` `models.conformer.effort`, each when set.
4. **Read** `<run dir>/execute/conform-<id>.md`:
- `Verdict: PASS`: commit the part (below), then mark it `done`.
- `Verdict: FAIL`, or no report: retry the part while its budget lasts (the implementer reads the failed report); when spent, mark it `blocked` with the `Left` items naming tasks, or the red check, as `reason`.
5. Write the state.
**Commit a part** when its conform passed. Read `git log --oneline -10` and follow its message style (Conventional Commits when the log uses them); the message names the part, e.g. `feat(export): CSV text (part 01)`. First run `git status --porcelain`: every listed path must be one of the part's `files`; when one is not, a worker wrote outside its part: commit nothing, and stop at step 8 with the blocker naming the paths. Then run `git add -A`, then `git commit -m "<message>"`: the commit lands on the Change branch, and the next part starts from it. A worker never commits; when a report says it did, or `git log` shows a commit you did not make, stop at step 8 with the blocker naming it.
**A blocked part stops the stage.** Start no further part, not even of the same wave: the next part's `git add -A` would commit the blocked part's unfinished work as its own. Leave the blocked part's changes uncommitted in the main checkout; the next run continues from them (step 3). Go to step 8.
Done when every part of the wave is `done`, or one is `blocked`.
## 6. Wave check
Each part's own check covers the files it changed; two parts green alone can be red together, when a later one changes what an earlier one built. With every part of the wave committed on the Change branch, run:
```
"${CLAUDE_PLUGIN_ROOT}/bin/bdk" check prepare <run dir> wave-<n> --at wave --changed <base>
```
with `<base>` from `waves.<n>.base` in the state, then its lines and `bdk check record` as the preloaded `check-protocol` says. It plans the items of the `wave` point, such as the project's whole test suite, on what the wave changed. A line the host refuses to run makes the verdict `fail`, and the repair below meets it as an environment blocker.
- Verdict `pass` or `none`: mark the wave `done` and write the state.
- Verdict `fail`: start one foreground Agent call (`run_in_background: false`), `subagent_type: "bdk:implementer"`, prompt `Run the skill bdk:repair-wave with the arguments: <change> <n> --base <base> --run-dir <run dir>`, `model` `models.implementer.model` and `effort` `models.implementer.effort`, each when set. Read `<run dir>/execute/wave-<n>.md`.
- `Status: done`: `git add -A`, then `git commit -m "<message>"` in the log's style naming the wave, e.g. `fix(ledger): reconcile wave 1`; mark the wave `done` and write the state.
- Otherwise run `repair-wave` once more with `model` `policy.escalation.model` and `effort` `policy.escalation.effort` (else `models.implementer.effort`, when set), committing on `Status: done`. When it still fails, mark the wave `blocked` with the report's kind and evidence as `reason`, write the state, and leave its uncommitted changes in the main checkout for the user.
Done when the wave is `done` or `blocked`.
## 7. Next wave
When the wave check is `blocked`, do not start a later wave: later waves build on earlier ones. Go to step 8. Otherwise go back to step 4.
Done when every wave ran, or the stage stopped on a blocked part or wave.
## 8. Write the result
Write the result file, replacing an earlier one:
```markdown
Status: blocked
## Waves
- 1: 01 02; checks/wave-1.json fail, repaired: execute/wave-1.md, checks/wave-1.json pass
- 2: 03 04; no wave check, part 03 is blocked
## Parts
- 01: done, 1 attempt; execute/conform-01.md PASS; committed on add-timer
- 02: done, 2 attempts (the second on the escalation model); execute/conform-02.md PASS; committed on add-timer
- 03: blocked, 1 attempt; execute/part-03.md; its work left uncommitted in the main checkout
- 04: pending, not started: part 03 is blocked
## Blockers
- 03: plan-defect - task 2 stores minutes, Scenario: Show duration expects seconds. Fix the plan: /bdk:plan add-timer, then /bdk:execute add-timer.
## Decisions taken without the user
- plan check: max-files 02 (9 files); built as planned.
- wave 1: red wave check repaired by execute/wave-1.md, committed as `fix(timer): reconcile wave 1`.
```
- `Status: done` only when every part of the plan is `done` and committed on the Change branch, and every wave is `done`; else `Status: blocked`.
- A blocked wave is a blocker line too: `wave 1: red wave check, execute/wave-1.md`, its kind and evidence, and `/bdk:execute <change>` to retry after the fix (or `/bdk:plan <change>` for `Kind: conflict`).
- Each blocker names the command that unblocks it: `/bdk:plan <change>` for a plan defect, a conflict or a plan problem; `/bdk:setup` for an environment blocker; for checks that stay red, the report to read and `/bdk:execute <change>` to retry. A blocked part's uncommitted files in the main checkout are its work for the next run (step 3).
- Under `Decisions taken without the user`: plan problems that did not stop the stage, escalations, wave repairs.
- An empty section holds `- None.`
Done when the result exists and its first line is the status.
## 9. Reply
Reply with two lines: the result's status line and its path.