Skip to content

Sandbox blocks Git write ops on worktree workspaces — allow worktree-linked paths without trust_mode #3355

Description

@linletian

Background

I use Git worktrees to organize my projects. My workspace looks like:

~/Projects/main-repo/              ← main repo
~/Projects/main-repo-wt/feat-x/    ← worktree workspace (created via git worktree add)

A worktree .git is just a pointer file:

gitdir: /Users/xxx/Projects/main-repo/.git/worktrees/feat-x/

The actual Git metadata (index, refs, objects, HEAD) lives inside the main repo, NOT inside the worktree workspace directory.

The problem

When I open this worktree directory in codewhale Agent mode, all Git write operations fail:

fatal: Unable to create .../index.lock: Operation not permitted

The reason is straightforward: codewhale sandbox only allows writes within the workspace directory, but the worktree Git metadata is at an external path (/Users/xxx/Projects/main-repo/.git/), so everything gets blocked.

Reads work fine — git status, git diff, git log all work through the structured tools, which means codewhale CAN read the external .git paths. Only writes are blocked.

Current workarounds

Either switch to YOLO mode (which implies trust_mode=true, granting blanket write access to all external paths), or quit codewhale and run git commands manually in a separate terminal. Neither is great. YOLO mode opens up write access everywhere, which feels unsafe. Switching to a terminal breaks the codewhale workflow.

What I hope for

Let codewhale handle Git write operations in worktree workspaces without enabling trust_mode.

Each worktree has two natural path pointers that codewhale can already read:

  1. Worktree metadata dir: the .git file contains gitdir: .../main-repo/.git/worktrees/<name>/
  2. Shared Git dir: the commondir file inside the metadata dir (content is ../.. or similar) resolves to the main repo .git/ directory

Just whitelist these two paths for writes. No other external paths need to be touched. The risk is minimal — these are just the same repository Git metadata directories. This is much safer than the blanket trust_mode=true.

Environment

  • macOS Sequoia
  • codewhale v0.8.58
  • Git worktree, Agent mode

To reproduce

git worktree add ~/worktree-dir feature-branch
# Open ~/worktree-dir in codewhale Agent mode
git add -A
# fatal: Unable to create '.../index.lock': Operation not permitted

Would love to see codewhale handle worktree-linked external paths so Git operations work smoothly in Agent mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestv0.8.64Targeting v0.8.64

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions