[Bug] tmpclaude-*-cwd temporary files created in project directory on Windows/Git Bash
Bug Description
tmpclaude-*-cwd temporary files are incorrectly created in the project directory instead of the system temp directory or ~/.claude/.
Environment
- Claude Code version: 2.1.6
- OS: Windows 10 (Build 26200)
- Shell: Git Bash (GNU bash 5.2.37, MINGW64/MSYS2)
- uname output:
MINGW64_NT-10.0-26200 x86_64 Msys
Steps to Reproduce
- On Windows, open a terminal with Git Bash
- Navigate to any project directory
- Run
claudeto start Claude Code - Execute any command that uses the Bash tool
- Check the project directory:
ls tmpclaude-*
Expected Behavior
Temporary files should be created in one of the following locations:
- System temp directory (
$TEMPor/tmp) - Claude config directory (
~/.claude/)
Actual Behavior
Files with names like tmpclaude-75e1-cwd, tmpclaude-ecb9-cwd are created directly in the current working directory (project root).
File content example:
/d/Projects/ainovelweb
The file appears to store the current working directory path and is likely used for shell session tracking.
Observations
~/.claude/shell-snapshots/directory exists and works correctly- Only the
tmpclaude-*-cwdfiles are affected - Multiple files accumulate as new Claude Code sessions are started
- Files are small (~23 bytes) containing only the CWD path
Environment Variables (at time of issue)
TEMP: /tmp (Git Bash virtual path)
TMP: /tmp
HOME: /c/Users/ASUS
USERPROFILE: C:\Users\ASUS
CLAUDE_CODE_TMPDIR: (not set)
Workaround
Setting the CLAUDE_CODE_TMPDIR environment variable resolves the issue:
# In ~/.bashrc
export CLAUDE_CODE_TMPDIR="$HOME/.claude/tmp"
mkdir -p "$CLAUDE_CODE_TMPDIR"
Possible Root Cause (Speculation)
The issue may be related to path resolution differences between Windows native paths and Git Bash/MSYS2 Unix-style paths. The /tmp virtual path in Git Bash might not be correctly resolved by Claude Code's temp file creation logic, causing it to fall back to the current working directory.
Impact
- Pollutes project directories with temporary files
- Files may accidentally be committed to git if
.gitignoreis not updated - Multiple sessions create multiple orphaned files
Suggested Fix
Consider using ~/.claude/tmp/ as a fallback location when the system temp directory cannot be resolved correctly, or improve path resolution for MSYS2/Git Bash environments on Windows.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗