← 2.1.5 Test tested · runtime-test

CLAUDE_CODE_TMPDIR — runtime test

Hands-on runtime battle-test of CLAUDE_CODE_TMPDIR. Result: PASS.

CLAUDE_CODE_TMPDIR is an environment variable that overrides the default temporary directory where Claude Code stores session-local files like scratchpads and large output artifacts.

How It Works

Claude Code normally stores temp files in the system's default /tmp directory under a hierarchical structure: claude/{project-path}/{session-id}/scratchpad/. Setting CLAUDE_CODE_TMPDIR=/path/to/custom/dir redirects this entire subtree to the custom location while preserving the internal directory layout.

The variable accepts an absolute path and requires no additional configuration. When set, Claude creates its standard claude/ prefix subdirectory within the custom location, followed by the same project-path-based nesting and session segregation.

What the Test Found

Runtime test on 2026-01-16 (version 2.1.5 features on 2.1.9 runtime) verified the mechanism by setting CLAUDE_CODE_TMPDIR=/tmp/custom-claude-tmp and running a simple Claude Code invocation. Result: PASS.

The custom directory received the complete standard structure:

/tmp/custom-claude-tmp/
└── claude/
    └── -Users-ryanhunter-projects-claude-claude-feature-demos/
        └── {session-id}/
            └── scratchpad/

Scratchpad and large output persistence both integrate cleanly with the custom tmpdir. No failures or data loss observed across session restarts.

Why It Matters

This enables targeted temp storage for performance, compliance, and operational constraints. Common applications: ramdisk/tmpfs mounting for latency-critical sessions; Docker volume persistence across container restarts; NFS or cluster shared-filesystem placement; quota-constrained environments where /tmp lacks capacity; and security isolation of temporary artifacts in regulated systems.

Caveats

The feature is orthogonal to other Claude Code configuration—it does not interact with session disabling or background task controls. Custom directory must exist and be writable before invocation; Claude does not create the parent path. Permissions follow standard POSIX rules.

Primary source
⎘ 2.1.5/tests/01-tmpdir-env-var/TEST-RESULTS.mdverbatim from the corpus

Test Results: CLAUDE_CODE_TMPDIR

Feature: Added CLAUDE_CODE_TMPDIR environment variable to override the temp directory used for internal temp files

Tested: 2026-01-16 Version: 2.1.5 features on 2.1.9

Test

mkdir -p /tmp/custom-claude-tmp
CLAUDE_CODE_TMPDIR=/tmp/custom-claude-tmp claude -p "say hi"
ls -laR /tmp/custom-claude-tmp/

Result: PASS

Claude created its standard temp structure in the custom directory:

/tmp/custom-claude-tmp/
└── claude/
    └── -Users-ryanhunter-projects-claude-claude-feature-demos/
        └── {session-id}/
            └── scratchpad/

The structure mirrors the default temp directory layout:

  • claude/ prefix
  • Project path (with slashes replaced)
  • Session UUID
  • scratchpad subdirectory

Use Cases

  1. Ramdisk/tmpfs - Point to fast storage for performance
  2. Docker volumes - Persist temp files across container restarts
  3. Shared filesystem - Custom temp location in NFS/cluster environments
  4. Debugging - Isolate temp files for inspection
  5. Quota constraints - Use different partition if /tmp has quota
  6. Security - Isolate temp files in specific location

Interaction with Other Features

  • Works with scratchpad (scratchpad created inside custom tmpdir)
  • Works with large output persistence (would write to custom location)
  • Compatible with DISABLE_BACKGROUND_TASKS (orthogonal)

Notes

Simple, focused env var. Does exactly what it says.

Status: PASS

Evidence & receipt
◇ ed25519 receipt
idtest_7b138bcebf5267eddecf9f33
alged25519
pubkey9b87705613b1e2fd064d57fa75a6b679d2856ceafad6b1daa8f982493871b6dd
sig264152f5063d2dccb60ac5f184d8c2c1ac9fb64f0251fec8be0b8a9ed47516bf2c0e801f6fde5655aaeb3e820736b3dcb5961f8039d753f0e625c3d26b0e6d08

Signed with an ed25519 key held off the repo. Anyone can verify against the published public key; nobody without the secret key can forge it. Click verify: it recomputes the signature in your browser. The signature proves integrity and authorship of this exact content — not a third-party timestamp or that the underlying claim is objectively true. signedAt is when the @f3/attest pipeline ran, not when the work happened; the evidence refs carry the source dates.

Connected