[FEATURE] Use CLAUDE_CODE_TMPDIR for Session Scratchpad
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When CLAUDE_CODE_TMPDIR environment variable is set, Claude Code should use this directory for the session-specific scratchpad instead of generating a path under /tmp/claude/....
Current Behavior
CLAUDE_CODE_TMPDIRcan be set to a custom temp directory (e.g.,/var/tmp/claude-username)- However, the session scratchpad directory is auto-generated based on the current working directory:
````
/tmp/claude/-home-www-vhosts-other-project/session-uuid/scratchpad
- Background task outputs are stored in:
````
/tmp/claude/-home-www-vhosts-other-project/tasks/
Use Case
On shared servers or systems with specific temp directory policies, administrators may want all temporary files to be stored in a consistent location (e.g., /var/tmp/ instead of /tmp/). The CLAUDE_CODE_TMPDIR variable already exists for this purpose, but the session scratchpad doesn't respect it.
Environment
- Claude Code version: (current)
- OS: Linux (Debian)
CLAUDE_CODE_TMPDIR=/var/tmp/claude-usernameis set in shell environment
Proposed Solution
When CLAUDE_CODE_TMPDIR is set, the scratchpad and task output directories should be created under this path:
/var/tmp/claude-username/session-uuid/scratchpad
/var/tmp/claude-username/tasks/
Alternative Solutions
_No response_
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗