File search tools default to wrong directory when using git worktree

Resolved 💬 2 comments Opened Mar 1, 2026 by maplezzk Closed Mar 1, 2026

Description

When using Claude Code with a git worktree, the working directory is correctly set to the worktree path (e.g., .claude/worktrees/branch-name), but file search tools (Glob, Grep, Read) default to searching the main repository directory instead of the worktree directory.

Steps to Reproduce

  1. Create a git worktree: git worktree add .claude/worktrees/feature-branch
  2. Set the working directory to the worktree in Claude Code settings
  3. Use Glob or Grep to search for a file - it searches the main repo, not the worktree
  4. Edit a file using Read/Edit - it modifies the main repo file, not the worktree

Expected Behavior

File search tools should respect the worktree working directory setting.

Environment

  • Claude Code version: Latest
  • OS: macOS
  • Shell: zsh

Workaround

Must use absolute paths to worktree files to avoid modifying the main repository.

View original on GitHub ↗

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