[BUG] Large file mention hangs claude code
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 1.0.6
- Operating System: macOS 15.5
- Terminal: Terminal
Bug Description
If you ask claude to ls -lah big_file.db (eg. a sqlite db thats ~20 GB), it will run the command, and after when its composing its answer, it locks up fully, ignoring keyboard interrupts and more. Investigating via sudo fs_usage -w -f filesys {pid} shows that claude gets stuck reading the file into memory. By watching htop, its possible to see that the data gets loaded into RAM + gets pushed into Swap (if its more than the RAM on the machine) causing the whole system to get stuck and slow.
I've tried not giving claude Read permission on the file, but this seems to be a "separate" permission system?, i tried adding the file to .claudeignore, but it fails there too. Not sure how to prevent it actually loading the full large file into RAM...
Note, extra scary, is that this seems to be true even if the folder is in a separate directory. Eg. "loc/path1/big_file.db" and then claude in "loc/path2/" ask claude from this to "ls -lah loc/path1/big_file.db" -> command runs, then afterwards, it reads the actual file into memory. I feel like claude shouldn't be loading files into memory outside of its scope, especially when the only command i gave it permission to run is "ls".
Steps to Reproduce
- Generate a large Sqlite db (~30 GB, just run a quick command insert into a table to fill up quickly)
- Ask claude to
ls -lah {large_db}.db-> it will ask for permission, say yes - Watch the terminal lock up and everything freeze (even ignoring ctrl+c commands, etc.)
Expected Behavior
Not lock up ever. Even if it wants to hash the file or something, it shouldn't try on such a large file or it should do it in the background.
Actual Behavior
It locks up, and the whole claude code freezes.
Workaround
I'm trying to use claude to investigate the file, but if it ever sees the filepath (eg. in the text in or text out from a command) it will lock up. So, to avoid it I set an environment variable, and then ask claude to only refrence the talbe by ENV var
⏺ I'll list the tables in the database file specified by the DB_PATH environment variable.
⏺ Bash(sqlite3 "$DB_PATH" ".tables")…
since this no longer sees the database file path anwyhere, it no longer tries to load it into memory, and it does not freeze.