Skip to content

bug(worktree): ../worktrees/ is one namespace shared by every sibling repo, and lookup globs on issue number alone #900

Closed as not planned

Description

@admarble

Summary

../worktrees/ is a single namespace shared by every sibling repository, and the skills resolve worktrees inside it by globbing on issue number alone. A glob written for issue #9 in one project can therefore resolve into a different project's worktree.

The directory is derived from the parent of the git root (src/lib/workflow/worktree-manager.ts:615):

const worktreesDir = path.join(path.dirname(gitRoot), "worktrees");

and identically in the shell path (scripts/new-feature.sh:103):

WORKTREE_DIR="../worktrees/${BRANCH_NAME}"

So every repo under ~/Projects/ writes into one ~/Projects/worktrees/feature/ tree. new-feature.sh:404 already acknowledges this for the npm cache ("../worktrees/ is shared by every repo (#847)") — the consequence for worktree resolution was never followed through.

The skills then look up by issue number, not by repo:

  • .claude/skills/fullsolve/SKILL.md:366 — export SEQUANT_WORKTREE=../worktrees/feature/<issue-number>-*/
  • .claude/skills/exec/SKILL.md:483 — "check if ../worktrees/ contains a directory for this issue"

Issue numbers are per-repo and collide constantly.

Evidence

~/Projects/worktrees/feature/ today, resolved via git rev-parse --git-common-dir per entry:

directory owning repo
9-create-solve-sequence-real-terminal-footage-with-p sequant-demo-video
10-create-result-and-cta-sequences-3-30-5-00 sequant-demo-video
35-qa-final-cross-browser-and-mobile-review portfolio-2025
125-onboarding-flow-ai-program-generation workout
145-sheet-save-load-named-campaigns ad-motion
578-seo-expand-city-coverage-to-20-cities matcha-maps

Five repos, one flat namespace. ai-devtools-weekly was working issues #9 and #10 on 2026-08-05; ../worktrees/feature/9-* and 10-* from that repo glob straight onto sequant-demo-video's directories.

A second reason the path name is not identity: ~/Projects/worktrees/feature/578-seo-expand-city-coverage-to-20-cities currently has feature/578-city-expansion-clean checked out. The directory slug and the branch it holds have already diverged, so a glob match tells you nothing about which branch you land on.

Creation is not the exposed surface — git worktree add onto an existing foreign path fails loudly. Resolution is: an issue-number glob silently returns a live directory belonging to another project.

Same class as #881 (parallel-group marker filename was global across projects), fixed there by scoping the name per project. This is the worktree-path instance of the same defect.

Impact

Acceptance Criteria

  • AC-1: Worktree lookup in the skills resolves through git worktree list in the current repository, never by globbing ../worktrees/feature/<issue-number>-*.
  • AC-2: /exec's standalone "check if ../worktrees/ contains a directory for this issue" step is replaced by the repo-scoped lookup from AC-1.
  • AC-3: A resolved worktree path that is absent from the current repo's git worktree list is rejected with a named error rather than used.
  • AC-4: Lookup selects on the branch (feature/<issue-number>-* as reported by git worktree list), not on the directory slug, so a directory whose name has diverged from its branch cannot be mis-selected.
  • AC-5: Both skill mirrors (.claude/skills/, templates/skills/) carry identical changes.
  • AC-6: A regression test creates a foreign worktree directory matching the issue-number glob and asserts the lookup does not select it, with a recorded mutation result per CLAUDE.md.

Non-Goals

  • Not relaying out ../worktrees/ into per-project subdirectories. That would strand every existing worktree on disk and is not required: scoping resolution to the current repo closes the failure mode. Worth revisiting separately if the flat namespace causes trouble elsewhere.
  • Not changing worktree-manager.ts's creation path, which is already repo-correct.

Relationship to #899

The /exec guard proposed in #899 (AC-4: halt when SEQUANT_WORKTREE is absent from git worktree list) neutralizes most of this hazard as a side effect, since it rejects a foreign path before use. This issue is the general fix — it also covers the standalone /exec path, where no orchestrator sets SEQUANT_WORKTREE at all. If the companion lands first, this one shrinks to AC-2 and AC-4.

Activity

  1. added
    bug
    on Aug 6, 2026
  2. admarble commented on Aug 6, 2026

    @admarble
    ContributorAuthor

    Consolidated into #899 — same two files (fullsolve/SKILL.md, exec/SKILL.md), same two mirrors, one PR. Splitting them would have put two PRs on the same files for no benefit.

    Everything here is carried over, nothing dropped:

  3. added a commit that references this issue on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions