claude-code - 💡(How to fix) Fix Windows: background daemon keeps a directory handle after `claude rm`, blocking directory deletion

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

Steps to reproduce

  1. claude --bg ... in a throwaway dir; it moves into .claude/worktrees/<id>.
  2. claude stop <id> then claude rm <id> (worktree reported removed).
  3. Remove-Item -Recurse -Force <dir> -> fails: "because it is in use."
  4. Get-Process node shows the daemon still alive; dotnet build-server shutdown does not help. Deleting files individually succeeds, but the directory handle persists.

Fix Action

Fix / Workaround

Discovered while piloting single-terminal background dispatch (claude agents / claude --bg) for real development work on Claude Code 2.1.157.

RAW_BUFFERClick to expand / collapse

Discovered while piloting single-terminal background dispatch (claude agents / claude --bg) for real development work on Claude Code 2.1.157.

What's wrong

After stopping and removing a background session, the per-user background daemon (node process) does not promptly release the handle to the session's working directory, so deleting that directory fails with "in use" on Windows.

Steps to reproduce

  1. claude --bg ... in a throwaway dir; it moves into .claude/worktrees/<id>.
  2. claude stop <id> then claude rm <id> (worktree reported removed).
  3. Remove-Item -Recurse -Force <dir> -> fails: "because it is in use."
  4. Get-Process node shows the daemon still alive; dotnet build-server shutdown does not help. Deleting files individually succeeds, but the directory handle persists.

Expected

After claude rm, the daemon releases all handles to the removed session's directory so it can be deleted.

Actual

Directory handle persists until the daemon process exits.

Environment

  • Claude Code 2.1.157
  • Windows 11

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Windows: background daemon keeps a directory handle after `claude rm`, blocking directory deletion