Windows: NUL files created in every directory (Git Bash)
Description
On Windows with Git Bash, Claude Code creates a file literally named NUL in virtually every directory it touches during a session. Since NUL is a reserved device name on Windows, these files cannot be deleted through normal means (Explorer, del, Remove-Item), requiring the \?\ prefix path workaround.
Environment
- OS: Windows 11
- Shell: Git Bash (via Claude Code's Bash tool)
- Claude Code: latest
Steps to reproduce
- Run Claude Code on Windows (Git Bash environment)
- Perform any task that involves file/directory operations
- Check directories with
Get-ChildItem -Filter 'NUL' -Recurse
Observed behavior
- A
NULfile is created in nearly every directory that Claude Code accesses - In one session, 1290 NUL files were found under a single parent directory
- Files are recreated every session even after deletion
- Files cannot be deleted via normal Windows tools due to the reserved device name
Expected behavior
No NUL files should be created. Output suppression should use /dev/null (Git Bash) or the actual NUL device, not create literal files.
Root cause hypothesis
Claude Code or its internal tooling likely uses > NUL style redirection (Windows convention) while running under Git Bash, where NUL is not interpreted as a device name but as a literal filename. The fix would be to use > /dev/null in Bash contexts, or ensure the redirection targets the actual null device.
Workaround
Delete using \?\ prefix to bypass reserved name parsing:
Get-ChildItem -Path . -Filter 'NUL' -File -Recurse -Force | ForEach-Object {
[System.IO.File]::Delete("\?\$($_.FullName)")
}
3 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Tried different scripts (PowerShell, CMD), looked into the NUL device, even considered using Python and Robocopy, but actually worked was just Shift + Delete. Appreciate the help, y’all!
For anyone curious, here’s what I was experimenting with before finding the simpler fix:
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.