anthropics / anthropics/claude-code

Subagent edits in a git worktree outside the project root are treated as outside the project; additionalDirectories is the only workaround and it grants more than the worktree

オープン
#92,417 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:agents area:permissions enhancement platform:macos
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

**Setup.** A common multi-agent layout gives each subagent its own `git worktree` in a sibling directory (`../repo-wt/`), so the primary checkout is never shared. Subagents inherit the parent session's working directory and have no cwd parameter (#12748), so every `Edit`/`Write` they make in that worktree is outside the working-directory tree.

**Behaviour.** Per the permissions doc, `acceptEdits` accepts edits only for paths in the working directory or `additionalDirectories`, so in acceptEdits mode every single edit prompts, in every repo, for the whole run. In auto mode the same edits are routed to the permission classifier instead of being accepted as in-project edits, so they can still be asked about and are never auto-approved the way an in-tree edit is.

**Workarounds and what each gives up.** Moving worktrees to `.claude/worktrees/` puts a full second checkout inside the repo: tools that walk the tree scan it twice, and `git add -A` stages a `160000` gitlink unless the path is ignored. `permissions.additionalDirectories` on a shared parent is a standing blanket write grant to a whole directory tree that outlives the agent that needed it.

**Request.** Treat a git worktree of the session's own repository as inside the working directory for permission purposes. The repository identity is already available via `git rev-parse --git-common-dir`, which resolves a linked worktree and its primary checkout to the same repository. A narrower form would be an opt-in `permissions.allowRepositoryWorktrees` setting, scoped to the worktrees git itself reports for the session's repository (`git worktree list`).

**Related, none of them this:** #77069 (pre-approving EnterWorktree outside `.claude/worktrees/`), #84258 (isolation blocks `git -C `), #84906 (`.claude/worktrees/**` matched as agent config), #12748 (no cwd parameter on the Task tool).

**Version:** Claude Code 2.1.259, darwin arm64.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by tracing permission handling for acceptEdits and auto modes, then compare the session repository from `git rev-parse --git-common-dir` with worktrees reported by `git worktree list`. Treat only worktrees belonging to that repository as in-project, without broadening `additionalDirectories`; done means sibling worktree edits no longer prompt while unrelated paths still do.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git
領域
authorization, cli
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。