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

Ouverte
#92,417 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area:agents area:permissions enhancement platform:macos
Langage dominant
Python
Étoiles
145k
Forks
23.1k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
git
Domaine
authorization, cli
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
52/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.