Fix: Claude Code Creates Unwanted "nul" File on Windows
Error message
[BUG] file named nul created on windows
Diagnosis
If you run Claude Code on Windows and find a file named "nul" appearing in your project directory, you have encountered a cross-platform compatibility bug. The Claude Code CLI, when executing certain commands, attempts to redirect output to the Unix-style null device (/dev/null). On Windows, this path is not recognized as a special device; instead, the operating system interprets nul as a literal filename and creates a regular file. The exact error is not a crash message but the presence of this file, which can be difficult to delete using normal Windows methods. The most common cause, as reported in the GitHub issue, is incorrect handling of null device redirection in the CLI's command execution logic for Windows systems.
What Causes This Error
Unix-style null redirection in Windows context
The root cause, as identified in the GitHub issue (anthropics/claude-code#4928), is that Claude Code uses Unix-style shell syntax for redirecting output to the null device. On Unix-like systems (Linux, macOS), the command >/dev/null discards standard output by sending it to a special device file. On Windows, the equivalent syntax is >nul (without a leading slash). When Claude Code executes a command that includes >/dev/null, Windows sees /dev/null as a file path. Since the directory dev does not exist under the root, Windows creates a file named nul in the current working directory. This happens because the Windows command processor (CMD or PowerShell) treats nul as a literal filename when it appears as part of a longer path, rather than recognizing it as the null device.
Intermittent behavior
The bug is described as "sometimes created" in the issue report. This intermittency likely depends on which specific command paths or error handling routines within the CLI trigger the redirection. For example, commands that suppress output during background operations, logging, or error suppression may be more likely to use /dev/null. Commands that do not use any output redirection will not trigger the bug. The version reported with this issue is Claude CLI version 1.0.62, but the underlying problem may exist in other versions that share the same cross-platform command execution code.
Difficulty of deletion
A secondary problem reported by users is that the created nul file cannot be deleted through normal Windows methods. This is because nul is a reserved device name in Windows (along with CON, PRN, AUX, COM1 through COM9, and LPT1 through LPT9). When Windows encounters a file named nul, it attempts to treat it as the null device rather than a regular file, causing delete operations to fail or behave unexpectedly. Standard File Explorer deletion, del nul in CMD, or Remove-Item nul in PowerShell will not work because the system intercepts the name.
How to Fix It

Solution 1: Delete the "nul" file using the \?\ prefix (community-reported fix)
This solution comes from a comment by GitHub user rweijnen on the issue thread, which received 36 reactions from other users confirming it works. The fix uses a Windows path syntax that bypasses the reserved name handling.
Step 1: Open a Command Prompt or PowerShell window.
Step 2: Navigate to the directory containing the "nul" file.
cd C:\path\to\your\project
Replace C:\path\to\your\project with the actual path where the file appeared.
Step 3: Delete the file using the \?\ prefix.
In Command Prompt:
del \\\?\C:\path\to\your\project\nul
In PowerShell:
Remove-Item -LiteralPath "\\?\C:\path\to\your\project\nul"
The \\?\ prefix tells Windows to bypass all path normalization and reserved name checks. This allows you to delete a file that would otherwise be treated as the null device. The path must be an absolute path; relative paths will not work with this prefix.
Step 4: Verify the file is gone.
dir nul
If the file was successfully deleted, you should see "File Not Found" or an error message indicating the file does not exist. If you still see the file, double-check that you used the full absolute path and the correct prefix syntax.
Why this works: The \\?\ prefix is a Windows API feature that disables string parsing and passes the path directly to the file system. This bypasses the special handling that Windows applies to reserved device names like nul. Without this prefix, any attempt to access a file named nul is intercepted by the Windows kernel and redirected to the null device.
Solution 2: Use a third-party file manager or boot-time deletion (community-reported workaround)
If the \\?\ prefix method does not work for you, or if you prefer a graphical approach, you can use a file manager that does not rely on the Windows shell for file operations.
Option A: Use 7-Zip File Manager.
- Install 7-Zip if you do not already have it.
- Open 7-Zip File Manager from the Start menu.
- Navigate to the directory containing the
nulfile. - Select the
nulfile and press the Delete key, or right-click and select Delete.
7-Zip File Manager uses its own file system access routines that may bypass the reserved name handling.
Option B: Delete at boot time.
- Restart your computer.
- Before Windows fully loads, press F8 (or the appropriate key for your system) to enter Safe Mode.
- In Safe Mode, navigate to the file and delete it using standard methods.
Safe Mode loads a minimal set of drivers and may not enforce the same reserved name restrictions.
Option C: Use a Linux live USB or WSL.
If you have Windows Subsystem for Linux (WSL) installed, you can access the Windows file system from within WSL and delete the file using Linux commands, which do not treat nul as a special name.
rm /mnt/c/path/to/your/project/nul
Replace /mnt/c/path/to/your/project/ with the WSL path to your Windows directory.
Solution 3: Prevent Claude Code from creating the file (workaround)
While waiting for an official fix from Anthropic, you can reduce the likelihood of the bug occurring by adjusting how you use Claude Code on Windows.
Option A: Use WSL (Windows Subsystem for Linux).
The official documentation recommends WSL for Windows users. According to the Quickstart guide, "WSL setups do not need Git for Windows" and provide a more Unix-like environment. If you run Claude Code inside WSL, the shell is a Linux shell (Bash), and /dev/null works correctly. This completely avoids the bug.
To set up WSL:
- Install WSL from the Microsoft Store or by running
wsl --installin an administrator PowerShell. - Open WSL and install Claude Code using the Linux installation command:
curl -fsSL https://claude.ai/install.sh | bash
- Run Claude Code from within the WSL terminal.
Option B: Use Git for Windows with Bash tool.
The official documentation states: "Git for Windows is recommended on native Windows so Claude Code can use the Bash tool. If Git for Windows is not installed, Claude Code uses PowerShell as the shell tool instead." Using Git Bash may reduce the frequency of the bug because Git Bash handles path translation differently, though it is not a guaranteed fix.
Option C: Monitor your working directory.
After each Claude Code session, check your project directory for the nul file. If it appears, delete it immediately using Solution 1 before it causes further issues. You can automate this check with a simple script:
# PowerShell script to check and delete nul file
$nulPath = Join-Path -Path (Get-Location) -ChildPath "nul"
if (Test-Path -LiteralPath $nulPath) {
Remove-Item -LiteralPath "\\?\$nulPath" -Force
Write-Host "Deleted rogue nul file."
}
Solution 4: Downgrade or wait for a fix (community suggestion)
The bug was reported against Claude CLI version 1.0.62. If you are using this version and the bug is frequent, you may consider:
- Checking for a newer version that may have fixed the issue. Run
claude --versionto see your current version. Run the native installer again to get the latest version, as native installations auto-update in the background. - If you installed via WinGet, run
winget upgrade Anthropic.ClaudeCodeto get the latest version. - If you installed via Homebrew, run
brew upgrade claude-codeorbrew upgrade claude-code@latest.
If a newer version does not fix the issue, report the bug to Anthropic through the GitHub issue tracker (https://github.com/anthropics/claude-code/issues) or through the official support channels mentioned in the documentation.
If Nothing Works
If none of the deletion methods work, and you cannot delete the nul file, you have the following escalation paths:
1. Anthropic Documentation and Support.
The official documentation provides a troubleshooting section: "Troubleshoot installation to match the error to a fix and for alternative install methods." While this is specifically about installation issues, the same support channels apply. You can:
- Type
/helpinside a Claude Code session for in-session support. - Visit the documentation at https://docs.anthropic.com/en/docs/claude-code/overview.
- Join the Anthropic Discord community for tips and support, as mentioned in the Quickstart guide.
2. GitHub Issue Tracker.
The bug was reported at https://github.com/anthropics/claude-code/issues/4928. You can:
- Add a comment to the existing issue with your environment details (Windows version, Claude CLI version, terminal type).
- Open a new issue if your problem is different.
- Upvote the existing issue to increase its priority.
3. Workaround: Use a different surface.
If the terminal CLI continues to cause problems on Windows, consider using one of the other surfaces mentioned in the overview:
- VS Code extension: Install the Claude Code extension from the VS Code marketplace. It provides inline diffs, @-mentions, and conversation history directly in your editor. This may use different code paths that avoid the bug.
- Desktop app: Available for Windows (x64 and ARM64). After installing, launch Claude, sign in, and click the Code tab. The desktop app may handle file operations differently.
- Web interface: Run Claude Code at claude.ai/code with no local setup. This completely avoids the local file system issue.
- JetBrains plugin: Available for IntelliJ IDEA, PyCharm, WebStorm, and other JetBrains IDEs. Requires the CLI to be installed separately, but may provide a different execution environment.
4. Use Remote Control or Cloud sessions.
If you need to run Claude Code on Windows but want to avoid the local file system bug, you can:
- Use
claude --cloudto start a task on Anthropic-managed infrastructure, then continue from your mobile device or another browser. - Use the web interface at claude.ai/code for tasks that do not require local file access.
- Schedule recurring tasks using Routines, which run on Anthropic-managed infrastructure and do not touch your local file system.
How to Prevent It
Use WSL (Windows Subsystem for Linux)
The most reliable prevention method, as recommended by the official documentation, is to run Claude Code inside WSL. WSL provides a full Linux kernel interface, so /dev/null works correctly and no nul file is created. The Quickstart guide explicitly states that WSL setups do not need Git for Windows, indicating that WSL is a first-class supported environment for Claude Code on Windows.
Install Git for Windows
If you must run Claude Code natively on Windows, install Git for Windows. The documentation states: "Git for Windows is recommended on native Windows so Claude Code can use the Bash tool." Git Bash provides a more Unix-compatible shell environment that may handle path translation more correctly than PowerShell. While this is not a guaranteed fix for the nul file bug, it reduces the likelihood by providing a shell that understands Unix-style redirection.
Keep Claude Code updated
Ensure you are running the latest version of Claude Code. The bug was reported against version 1.0.62, and future versions may include a fix. The update method depends on your installation method:
- Native install: Auto-updates in the background. To force an update, re-run the install script.
- WinGet: Run
winget upgrade Anthropic.ClaudeCodeperiodically. - Homebrew: Run
brew upgrade claude-codeorbrew upgrade claude-code@latest.
Avoid commands that may trigger the bug
Until a fix is released, you can minimize the risk by:
- Avoiding commands that explicitly suppress output, such as those using
>/dev/nullor2>/dev/nullin your prompts. - Using the
-pflag for one-off queries instead of interactive mode when possible, as this may use different code paths. - Running Claude Code in a directory where you do not mind a stray file appearing, such as a temporary directory, and then moving your project files after the session.
Monitor and automate cleanup
Set up a scheduled task or startup script that checks for and deletes any rogue nul files in your project directories. Use the \\?\ prefix method in the script to ensure deletion works. This is a reactive measure, but it prevents the file from accumulating and causing confusion.
Summary
The "nul" file creation bug on Windows is a cross-platform compatibility issue where Claude Code uses Unix-style /dev/null redirection instead of Windows-style >nul. The file is difficult to delete because nul is a reserved device name in Windows. The primary fix is to delete the file using the \\?\ prefix in the path, as reported by the community. The best prevention is to run Claude Code inside WSL, which avoids the bug entirely. If you must run natively, keep your installation updated and monitor for the file. Anthropic is aware of the issue through the GitHub issue tracker, and a permanent fix may be included in a future release.
The #1 Claude Newsletter
The most important claude updates, guides, and fixes — one weekly email.
No spam, unsubscribe anytime. Privacy policy
Related Error Solutions
Keep exploring Claude
Claude resources
Latest AI answers
Skip the manual work
Ready-made AI workflows and automation templates — import and run instead of building from scratch.