@ autocomplete generates incorrect relative paths when cwd is subdirectory of git root

Resolved 💬 1 comment Opened Jan 14, 2026 by jeremyjbarth Closed Jan 14, 2026

Description

When using @ file autocomplete in Claude Code, if the current working directory is a subdirectory of the git root, the autocomplete generates incorrect relative paths.

Steps to Reproduce

  1. Have a git repository with a nested structure (e.g., a monorepo where work happens in a subdirectory)
  2. Start Claude Code from a subdirectory of the git root
  3. Create a file in a path relative to the cwd, e.g., issues/foo/INVESTIGATION.md
  4. Type @ and start typing the filename to trigger autocomplete

Expected Behavior

The autocomplete should show the correct relative path from the current working directory:

issues/foo/INVESTIGATION.md

Actual Behavior

The autocomplete shows an incorrect path with ../ prefix:

../issues/foo/INVESTIGATION.md

This path is wrong—it would look for issues/ at the git root level rather than in the cwd.

Environment

  • pwd: /path/to/repo/subdir (a subdirectory of git root)
  • git root: /path/to/repo
  • File location: /path/to/repo/subdir/issues/foo/INVESTIGATION.md

Analysis

Claude Code appears to use the git root as the project root for file indexing. When generating autocomplete suggestions, it seems to miscalculate the relative path from the user's actual cwd when cwd ≠ git root.

The file path from git root is subdir/issues/foo/INVESTIGATION.md, but the autocomplete strips the subdir/ prefix and adds ../ instead—as if confusing which directory level the user is at.

Context

This was observed in a git worktree setup where:

  • The worktree root contains the .git file
  • Work happens in a subdirectory (omar/) of the worktree
  • There was also a .claude symlink at the worktree root pointing to omar/.claude, though removing it did not change the behavior

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗