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

Aperta
#92,417 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area:agents area:permissions enhancement platform:macos
Lingua principale
Python
Stelle
145k
Fork
23.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
git
Ambito
authorization, cli
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.