[BUG] `nul` file created in project directory on Windows

Resolved 💬 3 comments Opened Jan 9, 2026 by dobalmania Closed Jan 12, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

### Description
On Windows, Claude Code creates a nul file in the project root directory. This appears to happen when tools like Glob are executed. The file is repeatedly created during normal usage.

This issue does not occur on Linux, suggesting that somewhere in the code, a /dev/null redirect is being handled incorrectly on Windows - creating a literal nul file instead of using the Windows NUL device.

### Environment

  • OS: Windows 11 (10.0.26200.7462)
  • Claude Code version: (your version here)

### Steps to Reproduce

  1. Open Claude Code in a Windows project directory
  2. Use any tool that triggers file operations (e.g., Glob)
  3. Check the project root - a nul file appears

### Expected Behavior
No nul file should be created. On Windows, output to null should go to the NUL device, not create a file.

### Actual Behavior
A nul file is created in the project directory. Since nul is a reserved name in Windows, it requires special handling to delete:
del ?\C:\path\to\project\nul

### Workaround
Added a PostToolUse hook to automatically delete the file:
```json
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "powershell -Command \"if (Test-Path 'D:\\path\\to\\project\\nul') { Remove-Item -Path '\\\\?\\D:\\path\\to\\project\\nul' -Force -ErrorAction SilentlyContinue }\""
}
]
}
]
}
}

What Should Happen?

On Windows, when Claude Code needs to redirect output to null, it should:

  1. Use the Windows NUL device (e.g., command > NUL 2>&1) instead of creating a file
  2. Or properly handle the /dev/null path by translating it to the Windows equivalent
  3. No physical nul file should ever be created in the user's project directory

The behavior should match Linux/macOS where no such file is created.

Error Messages/Logs

Steps to Reproduce

  1. Open Claude Code on Windows
  2. Navigate to any project directory
  3. Run any command that uses the Glob tool (e.g., ask Claude to "find all .cpp files")
  4. Check the project root directory
  5. A nul file (0 bytes) will be created

Alternatively:

  1. Simply use Claude Code normally on Windows for a few minutes
  2. The nul file appears after various tool executions

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.1

Claude Code Version

2.1.1

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

### Additional Information

Observation:

  • The nul file is created specifically when tools like Glob, Grep, or Read are executed
  • The file is 0 bytes in size
  • On Linux, the same operations do not create any file
  • The issue appears to be related to how stderr/stdout redirection is handled on Windows

Workaround:
I created a PostToolUse hook in .claude/settings.local.json to automatically delete the file after each tool execution:

```json
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "powershell -Command \"if (Test-Path 'D:\\path\\to\\project\\nul') { Remove-Item -Path '\\\\?\\D:\\path\\to\\project\\nul' -Force -ErrorAction SilentlyContinue }\""
}
]
}
]
}
}

Note:
Since nul is a reserved filename in Windows, standard delete commands don't work. The \\?\ prefix is required to delete the file:
del \\?\D:\path\to\project\nul

Possible Cause:
Somewhere in the codebase, there may be a shell command using 2>nul or >nul redirection that is being executed in a non-Windows-native shell (like Git Bash or WSL), causing it to create a literal file instead of redirecting to the Windows NUL device.

View original on GitHub ↗

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