Claude Code repeatedly redirects to 'nul' on Windows, creating undeletable reserved-name files
Bug: Claude Code persistently uses nul instead of /dev/null on Windows
The Problem
On Windows, Claude Code repeatedly redirects output to nul instead of /dev/null. On Windows, nul is a reserved device name (like con, prn, aux, etc.), and writing to it as a filename creates a problematic file that is difficult to delete.
This is not a one-time mistake. The user has corrected Claude about this multiple times across sessions, and has even added an explicit rule in their CLAUDE.md:
NEVER redirect output to a file namednul,con,prn,aux,com1-com9, orlpt1-lpt9on Windows. These are reserved device names and creating them produces undeletable files. On Windows, always use/dev/null(which Git Bash and WSL translate correctly) instead ofnulfor discarding output.
Despite this rule being present in CLAUDE.md, Claude continues to make this mistake in new sessions. The user has had to repeatedly scold Claude about it, and each time Claude promises not to do it again — and then does it again.
Environment
- Platform: Windows 11 Pro (win32)
- Shell: Git Bash
- Model: Claude Opus 4.6
Expected Behavior
When running on Windows with a bash shell, Claude should use /dev/null for discarding output, never nul. Git Bash translates /dev/null correctly on Windows.
Actual Behavior
Claude uses nul to discard output (e.g., > nul 2>&1), which is a CMD convention, not a bash convention. This creates a literal file named nul in the working directory, which is a Windows reserved device name and causes problems.
Suggested Fix
This seems like it should be addressed at the system prompt or model behavior level, not just via user CLAUDE.md rules that get ignored. Possible approaches:
- System-level instruction: Add a hard rule to the system prompt for Windows environments: "Never use
nulfor output redirection. Always use/dev/null." - Shell-awareness: Since the shell is identified as
bashin the environment info, Claude should use bash conventions (/dev/null), not CMD conventions (nul). - Pre-execution check: Before executing bash commands, check for
nulredirection targets on Windows and substitute/dev/null.
Severity
This is a recurring, frustrating issue that erodes user trust. The user has explicitly stated that Claude "keeps lying" about fixing it. The CLAUDE.md rule is clear and present, yet it is not being reliably followed.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗