Skip to content

Name the Shared Stash as a Cross-Worktree Hazard in the Worktree Isolation Rule #2896

Closed

Description

@ptr727

Problem

git stash keeps one stash list per repository, in refs/stash, and every worktree of that repository shares it. A git stash pop in one worktree pops the newest entry, which can belong to a task in another worktree.

Constructed sequence, two worktrees of one repository:

  1. Worktree A runs git stash push, parking an edit to a.py.
  2. Worktree B runs git stash push, parking an edit to b.py.
  3. Worktree A runs git stash pop, and its tree receives B's b.py edit, since that entry is newest.
  4. Worktree B later pops A's a.py edit into its own tree.

Neither the repo-worktree skill nor GOVERNANCE.md "Repository Boundaries and Write Safety" names the stash. Both say a worktree isolates a task. A reader reasonably takes that to cover every git state the task touches.

Impact

Parallel lanes in worktrees of one repository cross stashes silently. The receiving tree gains a foreign edit, which a blanket or careless add would commit. The owning tree loses its parked work unless the work was already committed. Both failures are the cross-task contamination that worktree isolation exists to prevent.

Suggested fix

State in the repo-worktree skill, as part of the isolation rule, that the stash is shared per repository and never per worktree, so a task in a worktree does not use git stash. It commits work in progress on its own branch or copies a file to a scratch directory of its own instead. Consider whether GOVERNANCE.md "Repository Boundaries and Write Safety" names it alongside the blanket add and the hard reset as an operation that crosses the task boundary.

🤖 Generated with Claude Code

Activity

  1. added
    documentation
    on Oct 12, 2026
  2. added a commit that references this issue on Oct 12, 2026
    94f220f
  3. added a commit that references this issue on Oct 12, 2026
    444f3cb
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

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions