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

Offen
#92,417 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:agents area:permissions enhancement platform:macos
Vorherrschende Sprache
Python
Sterne
145k
Forks
23.1k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

**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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
git
Bereich
authorization, cli
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
52/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.