Skip to content

source-control: worktree skill's git worktree add/remove run through Bash, which the 2.1.323 sandbox refuses as read-only #17901

Closed

Description

@kyle-sexton

Refs: #15693

Split from the changelog release issue(s) above under the owner's decision of 2026-11-21 (melodic-software/architecture#148): one issue per handoff row, rows that edit the same file grouped.

Route: lane work. Basis: correctness: the skill fails for sandboxed sessions.

Problem

Row 14 of #15693 (key changelog:2.1.323..2.1.323:adopt:plugins/source-control/skills/worktree/SKILL.md). Required sentence: the worktree skill creates and removes worktrees with git worktree add/remove through the Bash tool. The macOS/Linux sandbox now refuses these as read-only, as it does commits in a worktree the session was not started in or given. The skill needs a route that works with the sandbox on.

On main the word "sandbox" appears nowhere under plugins/source-control/skills/worktree/. The create path runs plugins/source-control/scripts/worktree-create.sh (git worktree add), and context/cleanup.md runs git worktree remove. The sandboxing page still said, when filed, that writes to the shared .git are allowed in a linked worktree (docs-lag).

Done when

  • A probe on current Claude Code with the sandbox on records which of create, remove and commit fail, and the owner picks the route (native EnterWorktree/ExitWorktree, an excludedCommands entry, or a documented sandbox-off requirement).
  • The worktree skill states the chosen route for sandboxed sessions, with a pointer and recheck trigger.

Activity

  1. added
    needs-triage
    on Nov 21, 2026
  2. github-actions commented on Nov 21, 2026

    @github-actions
    Contributor

    Size: Small
    Complexity: Medium
    Uncertainty: Knowable
    Flags: intent
    Blocked by: none
    Blast radius: the source-control worktree skill (SKILL.md, context/cleanup.md, possibly scripts/worktree-create.sh) and every sandboxed session that creates or removes worktrees.
    Reversible: yes; revert the doc or skill edit.
    Open questions:

    1. Which route should the worktree skill take for sandboxed sessions: native EnterWorktree/ExitWorktree, an excludedCommands entry, or a documented sandbox-off requirement? The issue lists all three and picks none.
      RECOMMENDED: native EnterWorktree/ExitWorktree. Basis: it needs no sandbox exemption and no weakened sandbox; confirm with the probe of create, remove and commit under the sandbox. Related: source-control: ExitWorktree remove no longer deletes another running session's worktree (2.1.330) #17829 covers ExitWorktree remove behavior on 2.1.330.
      To answer, post a comment that starts with this line:
    **Decision recorded.** <answer>
    

    I read this as a bug: the worktree skill's git worktree add/remove through Bash fail under the 2.1.323 sandbox, and the skill says nothing about the sandbox. The sandbox-on probe is a separate step that may not run in this lane. No merged pull request that fixes this turned up.

    Automated triage. A maintainer reviews it.

  3. added
    needs-owner-decision
    on Nov 21, 2026
  4. melodic-automation-lanes commented on Nov 21, 2026

    @melodic-automation-lanes
    Contributor

    The triage verdict left this issue at needs-owner-decision:

    • flagged: intent
    • held by needs-owner-decision
    • no lanes App verdict comment shows whether an earlier verdict was flagged

    Reason: intent

  5. melodic-automation-lanes commented on Nov 21, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: The worktree skill states a sandbox-compatible route for creating, removing and committing in worktrees, most likely the native EnterWorktree/ExitWorktree tools, with a pointer and recheck trigger.

    Related work

    Open questions

    1. Which route should the worktree skill take for sandboxed sessions: native EnterWorktree/ExitWorktree, an excludedCommands entry, or a documented sandbox-off requirement?
      RECOMMENDED: Native EnterWorktree/ExitWorktree for create and enter, since it needs no sandbox exemption. Basis: plugins/source-control/CHANGELOG.md:5332 (skill already routes to the built-in tools, but never passes action remove)
    2. Removal: the skill never passes ExitWorktree action remove and cleanup runs git worktree remove through Bash. Which sandbox-compatible route should cleanup take, given #​17829 reports ExitWorktree remove misbehaving on 2.1.330?
      RECOMMENDED: Document that cleanup removal needs an excludedCommands entry for git worktree remove, until #​17829 is resolved, then recheck. Basis: judgment
    3. The first done-when item needs a probe of create, remove and commit with the sandbox on, and no unattended run can do that. Who runs it, and may the work proceed on documented assumptions instead?
      RECOMMENDED: The owner runs the probe on current Claude Code and records the results in the issue; the lane then writes the skill text from them. Basis: judgment
    4. What recheck trigger should the skill state?
      RECOMMENDED: Recheck when the sandboxing docs page changes its statement on writes to the shared .git in a linked worktree, or on each Claude Code release that touches the sandbox. Basis: judgment

    Sources read

    • refine-data/context.json: issue 17901 body and triage, no owner decision comment
    • plugins/source-control/CHANGELOG.md:5332: worktree skill routes to built-in EnterWorktree and ExitWorktree, never passing action remove, removal stays with cleanup
    • plugins/source-control/CHANGELOG.md:4853: worktree create skips EnterWorktree with no user present
    • plugins/source-control/.claude-plugin/plugin.json:106: hooks cover raw Bash git worktree add

    To answer, post a comment that starts with this line:

    **Decision recorded.** <answer>
    

    Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.

  6. added this to the After zero milestone on Nov 22, 2026
  7. added
    session-owned
    and removed
    needs-owner-decision
    on Nov 23, 2026
  8. removed this from the After zero milestone on Nov 23, 2026
  9. kyle-sexton commented on Nov 23, 2026

    @kyle-sexton
    MemberAuthor

    Probe for done-when 1, Claude Code 2.1.330 on Linux (WSL2), 2026-11-22 ~9:00 PM EST.

    Method: headless claude -p sessions run under dontAsk mode, one command each. Every run reported permission_denials: [] and no unsandboxed call. Sandbox on: sandbox {enabled: true, autoAllowBashIfSandboxed: true, allowUnsandboxedCommands: false}. Control: the same settings with the sandbox off. The worktrees were made outside the session's working directory, where the worktree skill puts them.

    Operation (session working directory) Sandbox off Sandbox on
    git worktree add <root>/x -b b (main checkout) ok fails: fatal: could not create directory of '.git/worktrees/...': Read-only file system (exit 128), and the new branch is left behind
    git worktree remove <root>/x (main checkout) ok fails: error: failed to delete '<root>/x': Read-only file system (exit 255)
    git -C <worktree> commit --allow-empty (main checkout) ok fails: fatal: Unable to create '.../.git/worktrees/.../index.lock': Read-only file system
    git commit --allow-empty (session started in the linked worktree) ok ok
    Native EnterWorktree, Bash commit, ExitWorktree remove (main checkout) not run all ok; removing a worktree that has commits asks for discard_changes: true

    Current docs (sandboxing, read 2026-11-22): "when the working directory is a linked git worktree, the sandbox also allows writes to the main repository's shared .git directory so commands such as git commit can update refs and the index." The probe agrees: a commit works only when the session's working directory is that worktree.

    A side finding not specific to worktrees: on this host, a signed commit fails in every sandboxed session (the SSH signing helper needs WSL interop, which the sandbox turns off).

    Evidence favors the native EnterWorktree/ExitWorktree route. Choosing the route is the owner's step in done-when 1; the owner question is open.

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

    needs-triagesession-owned

    Type

    Fields

    Work status

    needs-owner-decision

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions