Windows: NUL files created in every directory (Git Bash)

Resolved 💬 3 comments Opened Feb 7, 2026 by mazytomo Closed Feb 7, 2026

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

  1. Run Claude Code on Windows (Git Bash environment)
  2. Perform any task that involves file/directory operations
  3. Check directories with Get-ChildItem -Filter 'NUL' -Recurse

Observed behavior

  • A NUL file 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)")
}

View original on GitHub ↗

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