@@ -47,24 +47,28 @@ review cleaner.
4747
4848## Step 2 — Prepare the Branch
4949
50- Sync main before any implementation begins.
50+ Sync local main before any implementation begins.
5151
5252``` bash
5353git checkout main
5454git pull origin main --tags
5555```
5656
5757** If NOT using worktree isolation** (orchestrator implements directly or dispatches
58- a single non-isolated agent), create a working branch:
58+ a single non-isolated agent), create a local working branch:
5959
6060``` bash
6161git checkout -b < branch-name>
6262```
6363
64+ This branch stays local — it will be squash-merged into local ` main ` after
65+ review, not pushed directly to origin. See Step 6 for the squash-merge flow.
66+
6467** If using worktree isolation** , skip branch creation — each worktree agent gets
65- its own isolated branch automatically. See Worktree Isolation below.
68+ its own isolated branch automatically. See Worktree Isolation below. Worktree
69+ branches are also local-only and get squash-merged into ` main ` after review.
6670
67- ** Branch naming** (for manually created branches):
71+ ** Branch naming** (for local working branches):
6872- ` feat/<short-description> ` — feature-implementation items
6973- ` fix/<short-description> ` — bug-fix items
7074- ` fix/<grouped-description> ` — batch of related bug fixes
@@ -196,20 +200,21 @@ from. Automatically retrying hides these signals.
196200
197201---
198202
199- ## Step 6 — Commit and PR
203+ ## Step 6 — Commit and Squash-Merge to Main
204+
205+ After review passes, commit the changes and squash-merge into local ` main ` .
206+ PRs to GitHub are batched — multiple completed items accumulate on local ` main `
207+ before a single PR is created.
200208
201- After review passes, commit the changes and create a PR.
209+ ### Commit on the working branch
202210
203- ** If using worktree isolation** , all commands in this step run from the worktree:
211+ ** If using worktree isolation** , commit from the worktree:
204212``` bash
205213git -C < worktree-path> add < specific-files>
206- git -C < worktree-path> commit ...
207- git -C < worktree-path> push origin < worktree-branch>
214+ git -C < worktree-path> commit -m " ..."
208215```
209216
210- ** If NOT using worktree isolation** , run from the working branch as normal.
211-
212- ### Commit
217+ ** If NOT using worktree isolation** , commit on the local working branch as normal.
213218
214219Stage only the files related to the implementation. Do not stage unrelated changes
215220that happen to be in the working tree.
@@ -229,13 +234,31 @@ EOF
229234** Commit types:** ` feat ` for features, ` fix ` for bugs, ` refactor ` for tech debt,
230235` perf ` for performance, ` test ` for test-only changes, ` chore ` for maintenance.
231236
232- For batch work with multiple items in one branch, use a single commit or logical
233- commits per item — whichever tells a clearer story in the git log.
237+ ### Squash-merge into local main
234238
235- ### Push and PR
239+ After committing on the working branch (or worktree branch), squash-merge into
240+ local ` main ` :
236241
237242``` bash
238- git push origin < branch-name>
243+ git checkout main
244+ git merge --squash < branch-name> # or: git merge --squash <worktree-branch>
245+ git commit -m " <type>(<scope>): <description>"
246+ git branch -D < branch-name> # delete the local working branch
247+ ```
248+
249+ For worktree branches, use the branch name returned by the Agent tool. The
250+ worktree directory is cleaned up automatically after the branch is deleted.
251+
252+ Local ` main ` now has the squashed change. Repeat for more items — they accumulate.
253+
254+ ### Push and PR (batched)
255+
256+ When ready to publish one or more accumulated changes to GitHub, create a PR
257+ branch from local ` main ` :
258+
259+ ``` bash
260+ git checkout -b < pr-branch-name> # e.g., feat/batch-validation-improvements
261+ git push -u origin < pr-branch-name>
239262```
240263
241264Create the PR:
263286) "
264287```
265288
289+ After the GitHub PR is merged, sync local main:
290+ ``` bash
291+ git checkout main
292+ git pull origin main
293+ git branch -D < pr-branch-name> # delete the local PR branch
294+ ```
295+
296+ ** When to create a PR** — use judgment:
297+ - After completing a logical unit of work (a feature, a batch of fixes)
298+ - When local ` main ` has accumulated enough changes to warrant publishing
299+ - The user may explicitly request a PR at any point
300+
266301### Advance to terminal
267302
268303After the PR is created:
@@ -283,11 +318,13 @@ When processing multiple items autonomously:
2833182 . ** Parallel execution** — use worktree isolation for independent work streams.
284319 Sequential execution for items with dependency edges between them.
2853203 . ** Per-item pipeline** — each worktree goes through Steps 4-6 independently:
286- implementation → capture worktree metadata → simplify → review (in worktree) → PR
321+ implementation → capture worktree metadata → simplify → review (in worktree) → squash-merge to main
2873224 . ** Track all worktrees** — maintain a table mapping item UUID → worktree path →
288- branch → status (implementing / reviewing / PR created / failed)
289- 5 . ** Report at the end** — summarize all PRs created, any items that couldn't be
290- processed, and any review failures that need user attention
323+ branch → status (implementing / reviewing / squash-merged / failed)
324+ 5 . ** Squash-merge each** — after review passes, squash-merge each worktree branch
325+ into local ` main ` . Run the full test suite after each merge to catch integration issues.
326+ 6 . ** Report at the end** — summarize items completed, any review failures, and whether
327+ a PR to GitHub is ready
291328
292329If any item in the batch hits a review failure, continue processing other items
293330and report all failures together at the end.
@@ -303,8 +340,8 @@ real branch that survives the agent's lifecycle.
303340
304341** When to use worktrees:**
305342- Parallel dispatch of multiple implementation agents (prevents file conflicts)
306- - Any implementation dispatch where you need the changes on a reviewable branch
307- - When you want the implementation agent to commit and push independently
343+ - Any implementation dispatch where you need the changes on an isolated branch
344+ - When you want the implementation agent to commit independently
308345
309346** When NOT to use worktrees:**
310347- Tasks that depend on each other's file changes (use sequential dispatch instead)
@@ -331,8 +368,8 @@ Agent(
331368
332369### Worktree lifecycle
333370
334- The worktree branch is the PR branch. Review and PR creation happen on that
335- branch — do NOT merge worktree branches back before review .
371+ Review happens in the worktree. After review passes, squash-merge into local
372+ ` main ` — do NOT push worktree branches to origin .
336373
337374```
3383751. Orchestrator dispatches agent with isolation: "worktree"
@@ -342,7 +379,7 @@ branch — do NOT merge worktree branches back before review.
3423795. Orchestrator spot-checks diffs: git -C <worktree-path> diff main --stat
3433806. Orchestrator runs /simplify in the worktree (or dispatches agent to do so)
3443817. Review agent dispatched INTO the worktree (reads files and runs tests there)
345- 8. PR created from the worktree branch
382+ 8. After review passes: squash-merge worktree branch into local main
3463839. Worktrees with no changes are automatically cleaned up
347384```
348385
@@ -355,7 +392,7 @@ When an agent returns from worktree isolation, the Agent tool result includes:
355392Record these alongside the MCP item ID. You need them for:
356393- Running ` git -C <path> diff main --name-only ` to get the changed files list
357394- Pointing the review agent at the correct directory
358- - Pushing the branch and creating the PR
395+ - Squash-merging the branch into local ` main ` after review
359396
360397### Parallel worktree validation
361398
@@ -365,11 +402,9 @@ When multiple agents return from parallel worktrees:
3654022 . Spot-check at least 2 diffs for insertion errors, scope violations, or
366403 unintended modifications
3674043 . Run each worktree's test suite independently (or delegate to review agents)
368- 4 . Each worktree branch gets its own PR — do not merge them together unless
369- the items were intentionally grouped
370-
371- If items were grouped into a single working branch (Step 2), merge reviewed
372- worktree branches into that branch sequentially AFTER review passes for each.
405+ 4 . Squash-merge each reviewed worktree branch into local ` main ` sequentially
406+ 5 . Run the full test suite after all merges to catch integration issues
407+ 6 . Delete worktree branches after successful squash-merge
373408
374409---
375410
0 commit comments