@file reference autocomplete shows incorrect relative paths in git worktrees
Status Open
Maintainer reply None cached
Activity 7 comments · opened Dec 22, 2025
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-worktrees
7 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
i face the same issue, and why nobody notices it?
I am experiencing this issue outside of a worktree when working in a project within a monorepo
Same issue here
I'm also very confused. Why is no one else running into this issue? I can only assume since it's blatant and there have been many new releases since this issue first started. I'm using a very standard setup, the only thing is that the workspace I'm using is not the git root itself. I'm getting concerned this won't be fixed because for most users it's not a problem (which I still don't understand how).
Same issue here.
I am still running into this issue...