@-file search does not index files in nested git repositories
@-file search does not index files in nested git repositories
Description
The @-file autocomplete search does not show files inside nested git repositories, even when respectGitignore: false is set in settings. Only the directory name of the nested repo appears in suggestions, but no files within it.
This might be a regression introduced in v2.0.72 with the "3x faster git repositories" optimization (CHANGELOG). Users in #14566 reported this issue started in v2.0.72.
Related issues: #8672, #14566
Verified Root Cause
We tested this by creating two identical directories side-by-side:
test-with-git/- contains.git/directory (initialized git repo)test-without-git/- regular directory without.git/
Both directories contain identical test-file.txt files.
Result:
@test-without-git/test-file.txt✅ appears in @ search@test-with-git/test-file.txt❌ does NOT appear in @ search
This confirms that the presence of a .git directory causes Claude Code to treat the directory as a boundary and exclude its contents from file suggestions.
Current Behavior
When using @ to search for files:
- Files in the main repository: ✅ Visible
- Files in gitignored directories (e.g.,
notes/): ✅ Visible (withrespectGitignore: false) - Files in nested git repos (e.g.,
repos/backend/pom.xml): ❌ Not visible - Directory names of nested repos (e.g.,
repos/backend): ✅ Visible, but can't see contents
Expected Behavior
The @-file search should index and show files inside nested git repositories, allowing users to search across their entire workspace regardless of git repository boundaries.
Reproduction Steps
- Create a project structure with nested git repos:
project/
├── .git/
├── CLAUDE.md
├── notes/ # gitignored directory
│ └── daily.md
└── repos/ # contains nested git repos
└── backend/ # separate git repo with .git/
├── .git/
└── pom.xml
- Set
respectGitignore: falsein.claude/settings.json - Start Claude Code and type
@repos/backend/pom - Observe: No results found, even though
pom.xmlexists in that directory - Type
@repos/backend/ - Observe: Only directory paths are shown, no actual files within the nested repo
Environment
- Claude Code Version: 2.1.20
- Platform: macOS (Darwin 24.6.0)
- Installation: Homebrew
- Project Structure: Monorepo with nested git repositories (~10k files in nested repos)
Additional Context
Current Workaround
Using a custom fileSuggestion script in settings:
{
"fileSuggestion": {
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/file-suggestion.sh"
}
}
This works but requires maintaining custom scripts for file discovery.
Why This Matters
Many development workflows use nested git repositories for:
- Monorepos with multiple service repos checked out in subdirectories
- Development environments where multiple related projects are organized together
- Documentation repos alongside code repos
The current behavior forces users to either:
- Use custom scripts (complex, maintenance burden)
- Navigate to each nested repo separately (poor UX)
- Use Glob/Grep tools instead of @ search (slower workflow)
Suggested Solution
If this is a regression from the v2.0.72 optimization, restore the pre-v2.0.72 behavior where nested git repos were indexed.
Alternatively, add a setting like indexNestedRepos: true to allow @-file search to traverse nested git repositories, or extend respectGitignore: false to also treat nested repos as regular directories.
Screenshots
Image showing the replication in the experiment
<img width="1413" height="307" alt="Image" src="https://github.com/user-attachments/assets/ebb9507d-f298-4482-9a22-f54313ebc9ea" />
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗