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)")
}This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗