Feature Request: Allow Claude to manage git worktrees within project boundaries

Resolved πŸ’¬ 6 comments Opened Jun 17, 2025 by web3dev1337 Closed Dec 30, 2025

πŸ› οΈ Feature Request: Support for Git Worktrees in Claude Code

πŸ“Œ Summary

Claude Code currently enforces strict directory navigation limits for security, which prevents the use of git worktree workflows. This limits productivity for developers using parallel feature development strategies.

---

πŸ” Current Behavior

When attempting to use git worktree, Claude throws the following error:

ERROR: cd to '../ProjectName-feature' was blocked. For security, Claude Code may only change directories to child directories of the original working directory (/path/to/project) for this session.

---

πŸ’‘ Proposed Solution

Introduce a configuration option to allow safe navigation to sibling git worktree directories. For example:

.claude/config.json

{
  "permissions": {
    "allowGitWorktreeNavigation": true,
    "worktreePattern": "../{projectName}-*"
  }
}

Claude should:

  • Detect valid git worktrees from git worktree list
  • Permit cd into these verified directories
  • Allow switching between worktrees belonging to the same repo

---

βœ… Use Case

# From within the main project dir
git worktree add ../MyProject-feature1 -b feature/feature1
git worktree add ../MyProject-feature2 -b feature/feature2

Claude should support:

  • Creating new worktrees
  • Navigating between them
  • Performing operations like edits, commits, and codegen in each

---

πŸš€ Benefits

  • Parallel Feature Dev: Work across multiple features at once
  • Isolated Environments: Separate node_modules, venvs, etc.
  • Clean Git Histories: Feature branches are neatly organized
  • Deeper Claude Integration: Claude could manage the full worktree lifecycle

---

πŸ” Security Considerations

  • Allow only verified git worktree dirs (via git worktree list)
  • Require explicit opt-in via .claude/config.json
  • Limit access to sibling directories matching a defined pattern

---

πŸ” Alternative Solutions

If directory navigation can't be loosened:

  • Provide a claude worktree command to spawn new sessions in worktrees
  • Add internal commands to create/switch/manage worktrees
  • Introduce a higher-level project workspace model that groups worktrees

---

πŸ“Ž Related

  • #1052 – Field Notes: Git Worktree Pattern

---

πŸ™ Final Note

Supporting git worktree would meaningfully boost Claude Code’s developer experience and flexibilityβ€”without compromising security when opt-in restrictions are applied.

View original on GitHub β†—

This issue has 6 comments on GitHub. Read the full discussion on GitHub β†—