Feature Request: Allow Claude to manage git worktrees within project boundaries
π οΈ 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
cdinto 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 worktreedirs (viagit 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 worktreecommand 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.
This issue has 6 comments on GitHub. Read the full discussion on GitHub β