Windows: Temp directories and `nul` files not cleaned up

Resolved 💬 9 comments Opened Jan 12, 2026 by KvFxKaido Closed Feb 15, 2026

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:

  1. tmpclaude-*-cwd directories - Working directories created for subagents that aren't deleted after the agent completes
  2. nul files - 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

  1. Use Claude Code on Windows with subagents (Task tool)
  2. After several sessions, check for orphaned directories:

``powershell
Get-ChildItem -Recurse -Directory -Filter 'tmpclaude-*'
``

  1. Check for nul files:

``powershell
Get-ChildItem -Recurse -Filter 'nul'
``

Observed Behavior

After normal usage, I found:

  • 42 tmpclaude-*-cwd directories scattered across project trees
  • Multiple nul files 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 nul files should be created (suspect this is a /dev/null -> nul cross-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 work
  • rd /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 /MIR empty 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).

View original on GitHub ↗

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