Worktree isolation creates worktrees in .git/modules/ for submodule repos, breaking agent permissions

Resolved 💬 3 comments Opened Apr 2, 2026 by AlexandrePh Closed Apr 6, 2026

Problem

When using isolation: "worktree" on the Agent tool in a git submodule repo, the created worktree lands inside .git/modules/<path>/.claude/worktrees/ instead of inside the project's own .claude/worktrees/ directory.

This puts the worktree outside the project's permission scope, causing agents spawned with mode: "bypassPermissions" to still be prompted for file write permissions.

Reproduction

  1. Have a repo that is a git submodule (e.g., world/tools/arpi is a submodule of world)
  2. Spawn an agent with isolation: "worktree" and mode: "bypassPermissions"
  3. The agent's worktree is created at a path like:

``
/path/to/world/.git/modules/tools/arpi/.claude/worktrees/agent-abc123
`
instead of:
`
/path/to/world/tools/arpi/.claude/worktrees/agent-abc123
``

  1. The agent is prompted for every file write despite bypassPermissions

Expected behavior

Worktrees should be created relative to the working tree of the submodule (the project root), not relative to the git dir (.git/modules/). This would keep them within the project's permission scope.

Workaround

Don't use isolation: "worktree" for submodule repos. Agents can work directly on the main branch with --no-verify for parallel execution.

Environment

  • Claude Code version: 2.1.90
  • OS: macOS (Darwin 25.3.0)
  • Git: submodule repo

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗