[Bug] tmpclaude-*-cwd temporary files created in project directory on Windows/Git Bash

Resolved 💬 6 comments Opened Jan 13, 2026 by naiy123 Closed Feb 14, 2026

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

  1. On Windows, open a terminal with Git Bash
  2. Navigate to any project directory
  3. Run claude to start Claude Code
  4. Execute any command that uses the Bash tool
  5. Check the project directory: ls tmpclaude-*

Expected Behavior

Temporary files should be created in one of the following locations:

  • System temp directory ($TEMP or /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-*-cwd files 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 .gitignore is 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.

View original on GitHub ↗

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