Skip to content

Commit 7f3b8c9

Browse files
jpicklykclaude
andauthored
docs: switch git workflow from local-first squash to PR-per-feature (#93)
The local-first squash flow caused history divergence between local main and origin/main at every release — local had N individual commits while GitHub had 1 squash commit, requiring reset --hard to recover. PR-per-feature keeps local main always tracking origin/main via fast-forward pulls. Updated: implement skill (Steps 2, 6, worktree lifecycle, batch processing), CLAUDE.md, and integration guide docs. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 20b1864 commit 7f3b8c9

4 files changed

Lines changed: 41 additions & 55 deletions

File tree

.claude/skills/implement/SKILL.md

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,20 @@ git pull origin main --tags
6565
```
6666

6767
**If NOT using worktree isolation** (orchestrator implements directly or dispatches
68-
a single non-isolated agent), create a local working branch:
68+
a single non-isolated agent), create a working branch:
6969

7070
```bash
7171
git checkout -b <branch-name>
7272
```
7373

74-
This branch stays local — it will be squash-merged into local `main` after
75-
review, not pushed directly to origin. See Step 6 for the squash-merge flow.
74+
This branch will be pushed to origin and merged via GitHub PR after review.
75+
See Step 6 for the PR workflow.
7676

7777
**If using worktree isolation**, skip branch creation — each worktree agent gets
7878
its own isolated branch automatically. See Worktree Isolation below. Worktree
79-
branches are also local-only and get squash-merged into `main` after review.
79+
branches are pushed and merged via PR after review.
8080

81-
**Branch naming** (for local working branches):
81+
**Branch naming:**
8282
- `feat/<short-description>` — feature-implementation / feature-task items
8383
- `fix/<short-description>` — bug-fix items
8484
- `fix/<grouped-description>` — batch of related bug fixes
@@ -254,11 +254,10 @@ from. Automatically retrying hides these signals.
254254

255255
---
256256

257-
## Step 6 — Commit and Squash-Merge to Main
257+
## Step 6 — Commit and Push PR
258258

259-
After review passes, commit the changes and squash-merge into local `main`.
260-
PRs to GitHub are batched — multiple completed items accumulate on local `main`
261-
before a single PR is created.
259+
After review passes, commit the changes, push the branch, and create a GitHub PR.
260+
Each feature or logical unit of work gets its own PR — no batching on local `main`.
262261

263262
### Commit on the working branch
264263

@@ -268,7 +267,7 @@ git -C <worktree-path> add <specific-files>
268267
git -C <worktree-path> commit -m "..."
269268
```
270269

271-
**If NOT using worktree isolation**, commit on the local working branch as normal.
270+
**If NOT using worktree isolation**, commit on the working branch as normal.
272271

273272
Stage only the files related to the implementation. Do not stage unrelated changes
274273
that happen to be in the working tree.
@@ -288,31 +287,18 @@ EOF
288287
**Commit types:** `feat` for features, `fix` for bugs, `refactor` for tech debt,
289288
`perf` for performance, `test` for test-only changes, `chore` for maintenance.
290289

291-
### Squash-merge into local main
290+
### Push and create PR
292291

293-
After committing on the working branch (or worktree branch), squash-merge into
294-
local `main`:
292+
Push the branch to origin and create a PR:
295293

294+
**If using worktree isolation**, push the worktree branch:
296295
```bash
297-
git checkout main
298-
git merge --squash <branch-name> # or: git merge --squash <worktree-branch>
299-
git commit -m "<type>(<scope>): <description>"
300-
git branch -D <branch-name> # delete the local working branch
296+
git -C <worktree-path> push -u origin <worktree-branch>
301297
```
302298

303-
For worktree branches, use the branch name returned by the Agent tool. The
304-
worktree directory is cleaned up automatically after the branch is deleted.
305-
306-
Local `main` now has the squashed change. Repeat for more items — they accumulate.
307-
308-
### Push and PR (batched)
309-
310-
When ready to publish one or more accumulated changes to GitHub, create a PR
311-
branch from local `main`:
312-
299+
**If NOT using worktree isolation**, push the working branch:
313300
```bash
314-
git checkout -b <pr-branch-name> # e.g., feat/batch-validation-improvements
315-
git push -u origin <pr-branch-name>
301+
git push -u origin <branch-name>
316302
```
317303

318304
Create the PR:
@@ -340,18 +326,16 @@ EOF
340326
)"
341327
```
342328

343-
After the GitHub PR is merged, sync local main:
329+
### After the PR is merged
330+
331+
Sync local main and clean up:
344332
```bash
345333
git checkout main
346334
git pull origin main
347-
git reset --hard origin/main # prevent drift from squash + merge commit divergence
348-
git branch -D <pr-branch-name> # delete the local PR branch
335+
git branch -D <branch-name>
349336
```
350337

351-
**When to create a PR** — use judgment:
352-
- After completing a logical unit of work (a feature, a batch of fixes)
353-
- When local `main` has accumulated enough changes to warrant publishing
354-
- The user may explicitly request a PR at any point
338+
Local `main` always tracks `origin/main` — no divergence, no `reset --hard` needed.
355339

356340
### Advance to terminal
357341

@@ -373,13 +357,12 @@ When processing multiple items autonomously:
373357
2. **Parallel execution** — use worktree isolation for independent work streams.
374358
Sequential execution for items with dependency edges between them.
375359
3. **Per-item pipeline** — each worktree goes through Steps 4-6 independently:
376-
implementation → capture worktree metadata → simplify → review (in worktree) → squash-merge to main
360+
implementation → capture worktree metadata → simplify → review (in worktree) → push and PR
377361
4. **Track all worktrees** — maintain a table mapping item UUID → worktree path →
378-
branch → status (implementing / reviewing / squash-merged / failed)
379-
5. **Squash-merge each** — after review passes, squash-merge each worktree branch
380-
into local `main`. Run the full test suite after each merge to catch integration issues.
381-
6. **Report at the end** — summarize items completed, any review failures, and whether
382-
a PR to GitHub is ready
362+
branch → status (implementing / reviewing / PR created / failed)
363+
5. **PR each** — after review passes, push each worktree branch to origin and create
364+
a GitHub PR. Run the full test suite before pushing to catch integration issues.
365+
6. **Report at the end** — summarize items completed, any review failures, and PR URLs
383366

384367
If any item in the batch hits a review failure, continue processing other items
385368
and report all failures together at the end.
@@ -427,8 +410,8 @@ orchestrator after all agents return.
427410

428411
### Worktree lifecycle
429412

430-
Review happens in the worktree. After review passes, squash-merge into local
431-
`main` — do NOT push worktree branches to origin.
413+
Review happens in the worktree. After review passes, push the worktree branch
414+
to origin and create a GitHub PR.
432415

433416
```
434417
1. Orchestrator dispatches agent with isolation: "worktree"
@@ -438,8 +421,9 @@ Review happens in the worktree. After review passes, squash-merge into local
438421
5. Orchestrator spot-checks diffs: git -C <worktree-path> diff main --stat
439422
6. Orchestrator runs /simplify in the worktree (or dispatches agent to do so)
440423
7. Review agent dispatched INTO the worktree (reads files and runs tests there)
441-
8. After review passes: squash-merge worktree branch into local main
442-
9. Worktrees with no changes are automatically cleaned up
424+
8. After review passes: push worktree branch to origin and create PR
425+
9. After PR merges: git checkout main && git pull origin main
426+
10. Worktrees with no changes are automatically cleaned up
443427
```
444428

445429
### Capturing worktree metadata
@@ -461,9 +445,9 @@ When multiple agents return from parallel worktrees:
461445
2. Spot-check at least 2 diffs for insertion errors, scope violations, or
462446
unintended modifications
463447
3. Run each worktree's test suite independently (or delegate to review agents)
464-
4. Squash-merge each reviewed worktree branch into local `main` sequentially
465-
5. Run the full test suite after all merges to catch integration issues
466-
6. Delete worktree branches after successful squash-merge
448+
4. After review passes, push each worktree branch and create a PR
449+
5. Run the full test suite before pushing to catch integration issues
450+
6. Clean up local branches after PRs merge
467451

468452
### Test baseline management
469453

CLAUDE.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ Two skill systems — do not confuse them:
155155

156156
## Git Workflow
157157

158-
**Local-first squash flow** — work stays local on branches, squash-merged into `main`, batched PRs to GitHub. See the `/implement` skill for the full step-by-step process.
158+
**PR-per-feature flow**each feature or logical unit of work gets its own branch pushed to origin and merged via GitHub PR. Local `main` always tracks `origin/main`. See the `/implement` skill for the full step-by-step process.
159159

160160
- Follow conventional commits, reference issue numbers
161161
- All tests must pass before committing
162-
- Never force-push `main` — use PR branches to sync with origin
162+
- Never force-push `main`
163+
- Feature branches push to origin and merge via PR (squash merge on GitHub)
164+
- After PR merges: `git checkout main && git pull origin main && git branch -D <branch>`
163165
- Database migrations require special attention

current/docs/integration-guides/output-styles.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ When dispatching multiple implementation agents in parallel, use `isolation: "wo
107107
3. Agent returns — result includes worktree path and branch name
108108
4. Orchestrator spot-checks diff: `git -C <worktree-path> diff main --stat`
109109
5. Review agent dispatched into the same worktree path
110-
6. After review passes: squash-merge worktree branch into local `main`
111-
7. Run full test suite after each merge to catch integration issues
112-
8. Delete worktree branch
110+
6. After review passes: push worktree branch to origin and create PR
111+
7. Run full test suite before pushing to catch integration issues
112+
8. After PR merges: sync local main and clean up branch
113113

114114
### Tracking Table
115115

current/docs/integration-guides/plugin-skills-hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Commit all changes with a descriptive message. Report: (1) files changed with li
184184

185185
- Each agent owns exactly one phase — do not advance beyond it
186186
- Do NOT call `advance_item(trigger="complete")` — the orchestrator handles terminal transitions
187-
- Commit before returning — the orchestrator needs committed changes to squash-merge the branch
187+
- Commit before returning — the orchestrator needs committed changes to push and create a PR
188188

189189
---
190190

0 commit comments

Comments
 (0)