claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] tmpclaude-*-cwd temp files not cleaned up, accumulate in project folder

Open BARONFANTHE opened this issue 10 months ago • 6 comments

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?

Claude Code creates temporary files with pattern tmpclaude-XXXX-cwd in the user's current working directory (project folder). These files:

  1. Are NOT automatically cleaned up when the session ends
  2. Accumulate over time (I found 25 files after several sessions)
  3. Are placed in the project root where they can be accidentally committed to git

Each file contains only the current working directory path: /c/Projects/my-project-folder

Files found: tmpclaude-0697-cwd tmpclaude-0f7e-cwd tmpclaude-1586-cwd tmpclaude-3dd8-cwd ... (25 files total)

What Should Happen?

  1. Temp files should be stored in system temp folder (%TEMP% on Windows, /tmp on Unix) or a dedicated Claude folder (~/.claude/tmp/)
  2. Temp files should be automatically cleaned up when the session ends
  3. If cleanup fails, files should NOT be in a location where they can be accidentally committed to version control
  4. Or use a single file per project (reuse instead of creating new each session)

Error Messages/Logs

N/A - No error messages or warnings displayed. Files are created silently without any notification.

Steps to Reproduce

  1. Open PowerShell on Windows
  2. Navigate to project folder: cd C:\Projects\your-project\app
  3. Run Claude Code: claude
  4. Use Claude Code for coding tasks
  5. Check project folder: dir tmpclaude-*-cwd
  6. Observe: Multiple tmpclaude-XXXX-cwd files created

Complete timeline from my observation (all on 12/01/2026):

Time Files Created
14:07 2 files
14:08 2 files
14:09 3 files
14:29 1 file
14:33 4 files
14:34 3 files
14:56 2 files
14:57 1 file
15:37 1 file
15:38 2 files
15:53 3 files
15:54 1 file
Total 25 files

Key observations:

  • 25 files created in ~1 hour 47 minutes
  • Files created in bursts (up to 7 files within 1-2 minutes)
  • Previous Claude Code usage did not produce these files
  • All files contain only the working directory path
  • Files are not automatically cleaned up

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.1.6

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Workaround

Users need to:

  1. Manually delete: del tmpclaude-*-cwd (Windows) or rm tmpclaude-*-cwd (Unix)
  2. Add to .gitignore: tmpclaude-*-cwd

Suggested Fix

  1. Move temp file location to system temp folder or ~/.claude/
  2. Implement cleanup on session end
  3. Use a single file per project (reuse instead of creating new each session)
  4. Or eliminate the need for this file entirely if possible

Impact

  • Security risk: None (only contains path, no sensitive data)
  • UX issue: Medium (confusing, clutters project folder)
  • Potential problem: Accidental commits to git

Thank you for the great product!

BARONFANTHE avatar Jan 13 '26 10:01 BARONFANTHE

I am having the same problem. using version 2.1.6

peter-felgate avatar Jan 13 '26 10:01 peter-felgate

Image

sirventai avatar Jan 13 '26 10:01 sirventai

Same issue

christophergoltz avatar Jan 13 '26 10:01 christophergoltz

Having the same problem here. This needs urgent attention

mynk-tmr avatar Jan 13 '26 10:01 mynk-tmr

Duplicate of https://github.com/anthropics/claude-code/issues/17811

christophergoltz avatar Jan 13 '26 11:01 christophergoltz

Same issue

adrianvagner avatar Jan 13 '26 11:01 adrianvagner

I have same issue

lordguido avatar Jan 13 '26 14:01 lordguido

same issue

ercilioareias avatar Jan 13 '26 15:01 ercilioareias

2.1.6 same issue

s1495k043 avatar Jan 13 '26 15:01 s1495k043

I am facing the same issue as well. 2.1.6

rpkumar28 avatar Jan 13 '26 15:01 rpkumar28

Same. Windows, powershell. cc 2.1.6

egdw-xxigb avatar Jan 13 '26 16:01 egdw-xxigb

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Feb 27 '26 22:02 github-actions[bot]

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Mar 07 '26 14:03 github-actions[bot]