@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

View original on GitHub ↗

7 Comments

github-actions[bot] · 8 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/14399
  2. https://github.com/anthropics/claude-code/issues/14481
  3. https://github.com/anthropics/claude-code/issues/11902

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

fatihaziz · 7 months ago

i face the same issue, and why nobody notices it?

tylerschoppe · 7 months ago

I am experiencing this issue outside of a worktree when working in a project within a monorepo

anasiri · 7 months ago

Same issue here

duckSquirrelPilot · 7 months ago

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).

RazeBerry · 6 months ago

Same issue here.

davethegut · 5 months ago

I am still running into this issue...