Preflight Checklist
What's Wrong?
Bug: Claude Code leaves tmpclaude-*-cwd temporary files in working directory
Description
Claude Code creates temporary files named tmpclaude-{hash}-cwd in the current working directory during normal operation but fails to clean them up after execution completes. These files accumulate over time and require manual deletion.
Steps to Reproduce
- Use Claude Code normally with bash operations in a project directory
- After multiple sessions/operations, check the working directory
- Find multiple
tmpclaude-*-cwd files remaining in the directory
Expected Behavior
Temporary files created by Claude Code should be automatically cleaned up when:
- The operation completes successfully
- The operation fails/errors
- The Claude Code session ends
Temporary files should ideally be created in the system's temp directory (e.g., /tmp on Unix, %TEMP% on Windows) rather than the working directory.
Actual Behavior
Files like tmpclaude-448e-cwd, tmpclaude-8b98-cwd, etc. are left in the working directory and persist indefinitely. The files contain the working directory path.
Example file content:
/c/Users/dravo/Desktop/ASGARD/GitHub repo/JSUR-ASGARD/asgard
Impact
- Clutters the working directory with unnecessary files
- Risk of accidentally committing these files to version control
- Requires manual cleanup after each session
- Unprofessional when working in shared repositories
Environment
- OS: Windows (win32)
- Claude Code Model: claude-sonnet-4-5-20250929
- Project Type: Git repository
- Date Observed: January 2026
Workaround
Added the following to .gitignore:
# Claude Code temporary files
tmpclaude-*-cwd
claudetmp*
Manual deletion required:
Suggested Fix
- Use system temp directory instead of working directory for temporary files
- Implement proper cleanup in finally blocks or exit handlers
- Add a cleanup routine that runs on session end
- Consider using language-specific temp file utilities that auto-delete (e.g., Python's
tempfile.TemporaryFile())
Additional Context
This issue has been occurring consistently across multiple sessions. In one session, 5 temporary files were found accumulated over time.
What Should Happen?
..there should be no temp files left behind?
Error Messages/Logs
Steps to Reproduce
I just run claude normally, tried reloading claude, rebooting etc.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.5
Claude Code Version
2.1.5
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
No response
Preflight Checklist
What's Wrong?
Bug: Claude Code leaves
tmpclaude-*-cwdtemporary files in working directoryDescription
Claude Code creates temporary files named
tmpclaude-{hash}-cwdin the current working directory during normal operation but fails to clean them up after execution completes. These files accumulate over time and require manual deletion.Steps to Reproduce
tmpclaude-*-cwdfiles remaining in the directoryExpected Behavior
Temporary files created by Claude Code should be automatically cleaned up when:
Temporary files should ideally be created in the system's temp directory (e.g.,
/tmpon Unix,%TEMP%on Windows) rather than the working directory.Actual Behavior
Files like
tmpclaude-448e-cwd,tmpclaude-8b98-cwd, etc. are left in the working directory and persist indefinitely. The files contain the working directory path.Example file content:
Impact
Environment
Workaround
Added the following to
.gitignore:Manual deletion required:
rm tmpclaude-*-cwdSuggested Fix
tempfile.TemporaryFile())Additional Context
This issue has been occurring consistently across multiple sessions. In one session, 5 temporary files were found accumulated over time.
What Should Happen?
..there should be no temp files left behind?
Error Messages/Logs
Steps to Reproduce
I just run claude normally, tried reloading claude, rebooting etc.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.5
Claude Code Version
2.1.5
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
No response