[BUG] FileIndex re-indexes large non-git codebase via ripgrep causing multi-second hitches every turn
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Working with Claude Code on a large project (200k+ files), but without a git repo (we use P4). I'm seeing multi-second hitches every turn as Claude re-indexes files. On my machine this is currently taking between 7-13 seconds every turn, on a slower machine in the office here it takes 20+ seconds.
When there is a git repo, Claude reindexes once at the start of the session and then never again. I've been able to confirm this as a workaround by creating a local git repo, and after all of the files are committed, the hitch no longer occurs (confirmed times by looking at debug logs).
If I use an .ignore or .rgignore, I can reduce the number of files that ripgrep tests, but the re-indexing is still occurring every turn.
What Should Happen?
For non-git repos there should be some kind of file index cache for the and not re-scan files every turn.
Error Messages/Logs
[FileIndex] getProjectFiles called, respectGitignore=true
[FileIndex] getFilesUsingGit called
[FileIndex] not a git repo, returning null
[FileIndex] git ls-files returned null, falling back to ripgrep
[FileIndex] ripgrep: 204372 files in 12842ms
[FileIndex] cache refresh completed in 13049ms
Steps to Reproduce
- In a project with hundreds of thousands of files (ours has ~230k), open Claude Code. Do not create a git repo at that location (or above it in the file path)
- Note that Claude Code hitches on startup, and every turn afterwards
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.96
Platform
AWS Bedrock
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
[FileIndex] getProjectFiles called, respectGitignore=true
[FileIndex] getFilesUsingGit called
[FileIndex] not a git repo, returning null
[FileIndex] git ls-files returned null, falling back to ripgrep
[FileIndex] ripgrep: 211764 files in 6758ms
[FileIndex] cache refresh completed in 6992ms
[FileIndex] getProjectFiles called, respectGitignore=true
[FileIndex] not a git repo, returning null
[FileIndex] git ls-files returned null, falling back to ripgrep
[FileIndex] ripgrep: 203599 files in 6654ms
[FileIndex] cache refresh completed in 6890ms
[FileIndex] getProjectFiles called, respectGitignore=true
[FileIndex] not a git repo, returning null
[FileIndex] git ls-files returned null, falling back to ripgrep
[FileIndex] ripgrep: 202984 files in 6619ms
[FileIndex] cache refresh completed in 6853ms
[FileIndex] getProjectFiles called, respectGitignore=true
[FileIndex] not a git repo, returning null
[FileIndex] git ls-files returned null, falling back to ripgrep
[FileIndex] ripgrep: 208870 files in 6762ms
[FileIndex] cache refresh completed in 6987ms
[FileIndex] getProjectFiles called, respectGitignore=true
[FileIndex] not a git repo, returning null
[FileIndex] git ls-files returned null, falling back to ripgrep
[FileIndex] ripgrep: 201247 files in 7306ms
[FileIndex] cache refresh completed in 7537ms
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗