Claude Code creates tmp/attachments folder in project directory on every session start
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
- Navigate to any directory:
cd /path/to/any/project - Start Claude Code:
claude - 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:
- Don't create this folder if it's not actively needed
- Create it in the scratchpad directory (
/private/tmp/claude-{uid}/...) instead of polluting project directories - 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
- What is this folder intended for? (It's always empty)
- Why is it created in
$CWDinstead of the scratchpad at/private/tmp/claude/? - Can we get an option to disable or relocate this behavior?
Related
CLAUDE_CODE_TMPDIRenv 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
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗