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

  1. Have a main repository at /path/to/project
  2. Create git worktrees in /path/to/project-worktrees/
  3. Start Claude Code in the main repository
  4. Try to navigate to worktree: cd ../project-worktrees/feature-branch
  5. 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-dir slash 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:

  1. Allow navigation to sibling directories that have been explicitly added via /add-dir
  2. Add specific support for git worktree directories
  3. Provide an explicit /cd command as suggested in #1628

View original on GitHub ↗

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