Windows: literal "nul" file created in working directories
Bug Description
Claude Code creates empty 0-byte files literally named nul in working directories on Windows. This appears to happen when internal commands redirect output to the Windows NUL device through a bash shell context where NUL isn't recognized as a device name — bash treats it as a literal filename instead of the null device.
These files accumulate rapidly across project directories and their subdirectories.
Impact
Files named nul on Windows cannot be deleted through normal means (Explorer, del, rm in cmd) because NUL is a reserved device name. Only PowerShell's -LiteralPath parameter or the \?\ prefix path trick can remove them. This is extremely confusing for users who discover undeletable mystery files.
Steps to Reproduce
- Use Claude Code on Windows
- Use worktrees or run bash commands in any project directory
- Observe empty 0-byte files named
nulappearing in the working directory and subdirectories
Expected Behavior
No nul files should be created. Output suppression in bash contexts should use /dev/null (which works correctly in Git Bash / MSYS2 bash on Windows), not the Windows NUL device name.
Environment
- OS: Windows 11 Pro
- Shell: Git Bash (MSYS2)
- Claude Code: Latest version
Workaround
A PostToolUse hook can be added to settings.json to clean up nul files after each Bash command:
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "powershell -ExecutionPolicy Bypass -Command \"$nul = Join-Path $env:CLAUDE_PROJECT_DIR 'nul'; if (Test-Path -LiteralPath $nul) { Remove-Item -LiteralPath $nul -Force }\"",
"timeout": 5
}
]
}
]
Existing files can be cleaned up with:
Get-ChildItem -Path '<your-project-root>' -Filter 'nul' -Recurse -ErrorAction SilentlyContinue |
Remove-Item -LiteralPath { $_.FullName } -ForceThis issue has 2 comments on GitHub. Read the full discussion on GitHub ↗