feat(worktree): portable create-worktree.sh + Bug 1 base-ref fix (I-phase) - #300
Merged
Conversation
… base-ref fix
Implements the dual-channel worktree-create capability (verdict combo b+c) from
the 2026-05-30 R-phase. Two delivery channels share the `worktree-create-setup`
dual-pair anchor:
(b) BUILD scripts/create-worktree.sh — portable CLI/CI/agent-callable worktree
setup. Accepts <name> [<project-dir>] [<base-ref>]; mirrors the hook's
semantic check but reads CLI args instead of JSON stdin. No jq dependency.
Base-ref is configurable (explicit arg → $WORKTREE_BASE_REF → refreshed
origin/HEAD → fallback chain) — no hardcoded trunk name, per cold-QA
Finding 1.
Bug 1 fix (.claude/hooks/worktree-setup.sh): `git remote set-head origin --auto`
before the base-ref candidate loop. A stale local origin/HEAD (frozen at main,
pre the 2026-05-22 staging migration) was silently basing new worktrees on the
wrong branch. Reproduced empirically this session: origin/HEAD pointed at
origin/main; --auto corrected it to origin/staging.
Marker: swapped the hook's @cc-only-rationale → @dual-pair worktree-create-setup
(a portable equivalent now exists; dual-implementation-discipline.md §6 + patch
§6.3 / cold-QA Finding 2). First dual-channel pair in the repo.
Tests (paired-negative discipline, principle 02): create-worktree.test.ts (11
cases incl. configurable base-ref + 2 paired-negatives); worktree-setup.test.ts
gains a BUG-1 regression that fails on the unfixed hook (stale origin/HEAD →
main) and passes on the fix (→ staging).
(c) REFERENCE Superpowers `using-git-worktrees` (SSOT #65) for the AI-session
axis — unchanged; this BUILD serves the orthogonal human/CI axis.
Prior-art: docs/meta-factory/research-patches/2026-05-30-worktree-create-dual-channel.md (BUILD verdict for scripts/create-worktree.sh — BFR §3 6-layer survey, 4 candidates surveyed, no portable bash equivalent upstream) + SSOT #65 (Superpowers using-git-worktrees, ADOPT — AI-session axis only, REFERENCE here).
artyhoo
enabled auto-merge (squash)
May 30, 2026 05:16
artyhoo
added a commit
that referenced
this pull request
May 30, 2026
…te + SSOT #87 (#301) Follow-up to PR #300 (worktree-create dual-channel I-phase core). Wires the shipped capability into the discipline surfaces that point at it: - parallel-subwave-isolation.md §1: replace the raw `git worktree add ... main` block (a stale-base footgun since the 2026-05-22 staging migration — Bug 1's class) with `bash scripts/create-worktree.sh <name>`, plus a Bug 1 note on why base-ref must come from refreshed origin/HEAD, never a hard-coded branch. - meta-kickoff.template.md §4: non-CC / unwired-hook fallback now points at the portable script instead of the manual git-worktree path. - prior-art-evaluations.md: new SSOT row #87 (worktree-create dual-channel, verdict BUILD + REFERENCE #65; 4-candidate adversarial survey, T16 check, first dual-channel pair → dual-implementation-discipline.md §9 counter = 1). Closes I-phase items 4/5/7 from the worktree-create-dual-channel umbrella. Prior-art: skipped — doc-wiring only (rule/template/SSOT pointers to PR #300's already-evaluated capability), no new capability artifact in this commit.
artyhoo
added a commit
that referenced
this pull request
May 31, 2026
…acks SKILL.md dispatch matrix (parallel-build fallback) + meta-orch I-phase worktree step + references/placeholders.md DISPATCH_INSTRUCTIONS now name the portable `bash scripts/create-worktree.sh <name>` (refreshes origin/HEAD — Bug 1 fix, shipped PR #300) alongside the raw `git worktree add` manual fallback. Closes the doc residual flagged in the Bug 1 I-phase backward-check. Inline-code references only (no markdown links — dead-link checker clean). Prior-art: skipped — doc edit wiring an existing capability (scripts/create-worktree.sh, PR #300), no new capability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
I-phase for the dual-channel worktree-create capability (verdict combo b+c, R-phase merged PR #297 / patch
2026-05-30-worktree-create-dual-channel.md).scripts/create-worktree.sh— portable, CLI/CI/non-CC-agent-callable worktree setup.<name> [<project-dir>] [<base-ref>]; mirrors the CC hook's semantic check, reads CLI args instead of JSON stdin, nojqdep. Symlinksnode_modulesper the D2 workspace-optimisation pattern..claude/hooks/worktree-setup.sh—git remote set-head origin --autobefore the base-ref loop. A stale localorigin/HEAD(frozen atmain, pre the 2026-05-22 staging migration) silently based new worktrees on the wrong branch.using-git-worktrees(SSOT feat(skill-drift): multi-channel drift detection from D-AuditC-5 #65) for the AI-session axis — unchanged; BUILD serves the orthogonal human/CI axis.Cold-QA findings from the R-phase, addressed
explicit arg → $WORKTREE_BASE_REF → refreshed origin/HEAD → fallback chain. No hardcodedorigin/staging— refreshingorigin/HEADresolves to whatever the remote's actual default is (staging here,mainfor a consumer), so it's portable without knowing the name.@cc-only-rationale→@dual-pair: worktree-create-setup. A portable equivalent now exists, so@cc-only-rationaleis factually wrong (dual-implementation-discipline.md §6). This is the first dual-channel pair in the repo.Empirical evidence
Bug 1 reproduced live this session:
Tests (paired-negative discipline, principle 02)
create-worktree.test.ts— 11 cases: happy path, both symlinks, branch naming, idempotency, single-line stdout, explicit base-ref,$WORKTREE_BASE_REF, default project-dir, + 2 paired-negatives (missing name, non-existent base-ref).worktree-setup.test.ts— new BUG-1 regression building a temp repo with a deliberately-staleorigin/HEAD; fails on the unfixed hook (worktree based onmain), passes on the fix (staging).Verification
npx vitest runworktree-setup + create-worktree + check-hook-marker → 29 passedshellcheckboth scripts → cleantscerror inaudit-self/audit-ai-docs.ts:67(remark types) is unrelated and present onorigin/staging.Scope-out / notes
scripts/create-worktree.shis not shipped to consumers viainstall.sh(repo-internal dev tooling) and is outsidepackages/, so it's not a capability commit by the pre-push detector — thePrior-art:trailer is added per patch §5 mandate regardless.agents/+.claude/skills/for a@dual-paircounterpart, notscripts/. No CI gate exists for it (promotion deferred per §9), so no mechanical failure; flagging for awareness if that grep is ever promoted.