Windows: Reserved filename 'nul' created instead of redirecting to null device
Bug Report: Windows Reserved Filename 'nul' Created
Submitted to: https://github.com/anthropics/claude-code/issues
Bug Description
On Windows, Claude Code can create a file literally named nul instead of properly redirecting output to the Windows null device. This happens when bash commands attempt to discard output by redirecting to nul.
Environment
- OS: Windows 10/11
- Shell: Git Bash / MSYS2 (bundled with Claude Code)
- Working Directory:
C:\claude
What Happened
- A command executed by Claude Code redirected output to
nul - Instead of discarding the output (as intended), a file named
nulwas created - The file contained:
INFO: Could not find files for the given pattern(s).
Why This Is Problematic
NUL is a reserved device name on Windows (along with CON, PRN, AUX, COM1-9, LPT1-9). Creating files with these names:
- Can be difficult or impossible to delete via Windows Explorer
- May cause issues with backup software, antivirus scanners, and sync tools
- Can confuse Windows applications that expect these to be device names
- Creates edge cases in file system operations
Root Cause
Cross-platform shell confusion:
| Context | Correct Null Device |
|---------|---------------------|
| Windows CMD | NUL |
| PowerShell | $null |
| Git Bash/MSYS | /dev/null |
| Bare nul in Git Bash | Creates a file named "nul" |
When Git Bash encounters nul (not /dev/null), it treats it as a regular filename rather than the null device.
Suggested Fix
In bash contexts on Windows, Claude Code should:
- Always use
/dev/nullfor output redirection (Git Bash correctly translates this to the Windows null device) - Never use bare
nulwhich gets interpreted as a literal filename in MSYS/Git Bash environments - Consider adding a check/lint rule to prevent redirections to
nulin bash commands
Workaround
Users can delete the problematic file using:
rm -f "C:/path/to/nul"
Evidence
File details from the affected system:
-rw-r--r-- 1 user 1049089 54 Jan 22 15:19 C:\claude\nul
file type: ASCII text, with CRLF line terminators
contents: "INFO: Could not find files for the given pattern(s)."
---
Reported via Claude Code on 2026-02-05
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗