Windows: Temp directories and `nul` files not cleaned up
Windows: Temp directories and nul files not cleaned up
Description
On Windows, Claude Code leaves behind two types of orphaned files/directories that accumulate over time:
tmpclaude-*-cwddirectories - Working directories created for subagents that aren't deleted after the agent completesnulfiles - Empty files named "nul" appearing in various project directories
The nul files are particularly problematic because "NUL" is a reserved device name on Windows (like /dev/null on Unix). Once created, these files cannot be deleted through normal Windows operations (del, rd, Explorer, PowerShell Remove-Item, etc.).
Environment
- OS: Windows 11 (Build 26200.7462)
- Claude Code version: (latest as of 2026-01-12)
- Shell: Git Bash / PowerShell
Steps to Reproduce
- Use Claude Code on Windows with subagents (Task tool)
- After several sessions, check for orphaned directories:
``powershell``
Get-ChildItem -Recurse -Directory -Filter 'tmpclaude-*'
- Check for nul files:
``powershell``
Get-ChildItem -Recurse -Filter 'nul'
Observed Behavior
After normal usage, I found:
- 42
tmpclaude-*-cwddirectories scattered across project trees - Multiple
nulfiles in various directories
New tmpclaude-* directories appear during each session and persist after Claude Code exits.
Expected Behavior
- Subagent working directories should be cleaned up when the subagent completes or when Claude Code exits
- No
nulfiles should be created (suspect this is a/dev/null->nulcross-platform bug)
Workaround
The only reliable way to delete these on Windows is via WSL:
# Delete tmpclaude directories
wsl rm -rf /mnt/c/path/to/project/tmpclaude-*
# Delete nul files (Windows can't delete these normally)
wsl rm -f /mnt/c/path/to/nul
Standard Windows deletion methods all fail for nul files:
del \\?\C:\path\nul- doesn't workrd /s /q \\?\C:\path\nul- doesn't work- PowerShell
Remove-Item- doesn't work - .NET
[System.IO.File]::Delete()- access denied - Python
os.remove()- file not found robocopy /MIRempty folder trick - doesn't work
Suspected Cause
For the nul files: Somewhere in the codebase there may be a reference to /dev/null that isn't being translated to NUL (the Windows equivalent device). Instead of writing to the null device, it creates a literal file named "nul".
Additional Context
These files don't cause functional issues but clutter the filesystem and the nul files can prevent folder deletion entirely (e.g., can't delete a project folder containing a nul file without using WSL).
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗