Claude Code creates tmp/attachments folder in project directory on every session start

Open 💬 3 comments Opened Jan 29, 2026 by gitsacha

Summary

Claude Code automatically creates an empty tmp/attachments/ directory in the current working directory every time a new session starts. This clutters project directories with unwanted folders that need to be gitignored.

Environment

  • Claude Code version: 2.1.23 (behavior started around v2.1.16-2.1.18)
  • OS: macOS 14.x (Sonoma)
  • Shell: zsh

Steps to Reproduce

  1. Navigate to any directory: cd /path/to/any/project
  2. Start Claude Code: claude
  3. Check the directory: ls -la tmp/

Result: Empty tmp/attachments/ folder is created automatically.

Evidence

The folder is created before the session file exists (25 seconds before in my testing), confirming it happens during Claude Code's initialization phase:

tmp/attachments created: 16:23:33
session.jsonl created:   16:23:58

Affected Directories

Every directory where Claude Code has been started gets this folder:

/project-a/tmp/attachments/
/project-b/tmp/attachments/
/project-c/tmp/attachments/
... (14+ projects in my case)

Investigation Results

Exhaustively verified this is NOT caused by:

  • ❌ Any Claude Code hooks (SessionStart, PreToolUse, etc.)
  • ❌ Plugin hooks (superpowers, official plugins)
  • ❌ MCP servers
  • ❌ User shell configuration (.zshrc)
  • ❌ Claude Desktop app
  • ❌ Any configuration files

The string tmp/attachments does not exist in any config or hook file - this behavior is hardcoded in the Claude Code binary.

Expected Behavior

Either:

  1. Don't create this folder if it's not actively needed
  2. Create it in the scratchpad directory (/private/tmp/claude-{uid}/...) instead of polluting project directories
  3. Provide an environment variable (e.g., CLAUDE_CODE_DISABLE_LOCAL_TMP=1) to opt out

Current Workaround

Add to global gitignore:

echo "tmp/" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Questions

  1. What is this folder intended for? (It's always empty)
  2. Why is it created in $CWD instead of the scratchpad at /private/tmp/claude/?
  3. Can we get an option to disable or relocate this behavior?

Related

  • CLAUDE_CODE_TMPDIR env var exists but doesn't seem to affect this behavior
  • Scratchpad directory uses different path: /private/tmp/claude-{uid}/{session}/scratchpad/

---

Keywords for searchability: tmp folder, attachments directory, unwanted files, project pollution, gitignore, temporary directory, session start, initialization

View original on GitHub ↗

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