@file reference autocomplete shows incorrect relative paths in git worktrees
Open 💬 7 comments Opened Dec 22, 2025 by sharmaayush358
Description
When using Claude Code from within a git worktree, the @ file reference autocomplete displays incorrect relative paths with an extra ../../ prefix that doesn't resolve to the actual file location.
Environment
- Claude Code CLI
- macOS
Reproduction Steps
# 1. Create a test repository
mkdir -p ~/test-repo && cd ~/test-repo
git init
echo "# Test Repo" > README.md
mkdir -p src/app/api-specs/orders
echo "openapi: 3.0.0" > src/app/api-specs/orders/spec.yaml
git add . && git commit -m "Initial commit"
# 2. Create a feature branch and worktree
git checkout -b feature-branch
git checkout main
mkdir -p ~/test-repo-worktrees
git worktree add ~/test-repo-worktrees/feature-branch feature-branch
# 3. Navigate to subdirectory in worktree and start Claude Code
cd ~/test-repo-worktrees/feature-branch/src/app
claude
# 4. Type: @orders/spec.yaml
Expected Behavior
Autocomplete should show ./api-specs/orders/spec.yaml or api-specs/orders/spec.yaml
Actual Behavior
Autocomplete shows ../../api-specs/orders/spec.yaml
Verification
cd ~/test-repo-worktrees/feature-branch/src/app
# This works - file exists here:
ls ./api-specs/orders/spec.yaml
# ✓ ./api-specs/orders/spec.yaml
# This fails - file does NOT exist at the path Claude Code suggests:
ls ../../api-specs/orders/spec.yaml
# ✗ No such file or directory
Analysis
The CLI appears to be computing relative paths incorrectly when the working directory is a subdirectory within a git worktree. The ../../ prefix suggests it may be calculating paths relative to the git root rather than the current working directory.
Cleanup
rm -rf ~/test-repo ~/test-repo-worktreesThis issue has 7 comments on GitHub. Read the full discussion on GitHub ↗