Cannot work with git worktrees due to directory restriction
Open 💬 9 comments Opened Jul 2, 2025 by aewing
Description
When working with git worktrees for feature development, Claude Code cannot navigate to worktree directories that are siblings to the main repository. This blocks a common development workflow.
Steps to Reproduce
- Have a main repository at
/path/to/project - Create git worktrees in
/path/to/project-worktrees/ - Start Claude Code in the main repository
- Try to navigate to worktree:
cd ../project-worktrees/feature-branch - Get error: "For security, Claude Code may only change directories to child directories of the allowed working directories"
Expected Behavior
Should be able to work with git worktrees, which are a standard git feature for isolated development.
Actual Behavior
Cannot navigate to worktree directories, making it impossible to use Claude Code with git worktrees.
Workarounds Attempted
- Adding directories via
/add-dirslash command - directories are added but navigation still blocked - Adding "../", "../project-worktrees" to ".claude/settings.json" and "./claude/settings.local.json"
- Starting from parent directory - not practical for project-specific work
Impact
This prevents using Claude Code for feature development workflows that rely on git worktrees for isolation. Worktrees are essential for:
- Working on multiple features simultaneously
- Keeping main branch clean
- Testing changes in isolation
Related Issues
- #1628 (general directory change request)
Suggested Solution
Either:
- Allow navigation to sibling directories that have been explicitly added via
/add-dir - Add specific support for git worktree directories
- Provide an explicit
/cdcommand as suggested in #1628
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗