Windows: Reserved filename 'nul' created instead of redirecting to null device

Resolved 💬 4 comments Opened Feb 5, 2026 by Ergonetpl Closed Mar 8, 2026

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

  1. A command executed by Claude Code redirected output to nul
  2. Instead of discarding the output (as intended), a file named nul was created
  3. 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:

  1. Always use /dev/null for output redirection (Git Bash correctly translates this to the Windows null device)
  2. Never use bare nul which gets interpreted as a literal filename in MSYS/Git Bash environments
  3. Consider adding a check/lint rule to prevent redirections to nul in 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

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗