[FEATURE] Support CLAUDE_TMPDIR environment variable for custom temporary directory

Resolved 💬 3 comments Opened Jan 16, 2026 by jup999 Closed Jan 20, 2026

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

Claude Code uses a hardcoded path /tmp/claude for its sandbox temporary directory. On shared Linux systems with multiple users, this causes permission conflicts:

EACCES: permission denied, mkdir '/tmp/claude/-home-username-project'

If another user created /tmp/claude first, subsequent users cannot use Claude Code's Bash tool at all until the directory ownership is fixed (requires sudo).

Security Concern
The /tmp/claude directory and its subdirectories are created with world-readable permissions (drwxrwxr-x). This means any user on the system can browse other users' Claude Code temporary directories and see potentially sensitive project paths and contents:

$ ls -la /tmp/claude/
drwxrwxr-x 8 other_user other_user 4096 Jan 14 10:57 .
drwxrwxr-x 2 other_user other_user 40 Jan 13 08:18 -home-other_user-project-name
drwxrwxr-x 2 other_user other_user 40 Jan 12 14:22 -home-other_user-secret-client-project
...

Even if the ownership issue is fixed, the world-readable permissions expose user activity to all other users on the system.

Recommendation: If /tmp/claude must be shared, use chmod 1770 (sticky bit + no world access) instead of 1777, so only the owning group can access subdirectories.

Proposed Solution

Add support for a CLAUDE_TMPDIR environment variable that allows users to specify a custom temporary directory location, e.g.:

```bash
export CLAUDE_TMPDIR="$HOME/.claude/tmp"
claude

If not set, fall back to the current /tmp/claude behavior.

This would allow each user to have their own private temporary directory with appropriate permissions.

Alternatives Considered

  • Using system TMPDIR: Not ideal as it may conflict with other applications
  • Fixing /tmp/claude permissions: Requires sudo, which users on shared systems often don't have
  • Setting permissions to 1770: Better than 1777, but still requires coordination between users and initial sudo access

Environment

  • OS: Linux (shared multi-user system)
  • Claude Code version: 2.1.9

Additional Context

This is a common issue on enterprise/university shared systems where multiple developers use Claude Code on the same machine.

Alternative Solutions

_No response_

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

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