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

Status Fixed / completed
Maintainer reply None cached
Activity 3 comments · opened Feb 7, 2026 · 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 ↗

3 Comments

github-actions[bot] · 8 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/4928
  2. https://github.com/anthropics/claude-code/issues/17886
  3. https://github.com/anthropics/claude-code/issues/23343

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

SenaDev2023 · 8 months ago

Tried different scripts (PowerShell, CMD), looked into the NUL device, even considered using Python and Robocopy, but actually worked was just Shift + Delete. Appreciate the help, y’all!
For anyone curious, here’s what I was experimenting with before finding the simpler fix:

# Deep clean of build artifacts
gulp clean

# Remove the temporary and distribution folders manually to be certain
Remove-Item -Path "./temp" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "./dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "./lib" -Recurse -Force -ErrorAction SilentlyContinue

# Final nuke  'nul' file if it still appears in git status
Remove-Item -LiteralPath "\\?\C:\code\acme dir\nul" -Force -ErrorAction SilentlyContinue

git status
git status --porcelain
git ls-files | Select-String -Pattern "^nul$"
git rm -f --ignore-unmatch nul
git status --porcelain
git update-index --force-remove nul
git status --porcelain
Remove-Item .git\index -Force
git reset
github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.