Task tool subagent spawning ignores TMPDIR, hardcodes /tmp/claude/

Resolved 💬 4 comments Opened Jan 20, 2026 by SomewhatRogue Closed Feb 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Task tool's subagent spawning doesn't respect the TMPDIR environment variable. It attempts to create directories in /tmp/claude/ regardless of TMPDIR configuration.

What Should Happen?

Subagent temp files should be created in $TMPDIR/claude/ or similar, respecting the user's configured temp directory

Error Messages/Logs

Error: EACCES: permission denied, mkdir '/tmp/claude/-home-kyle'

Steps to Reproduce

  1. Set TMPDIR to a user-writable directory (e.g., export TMPDIR=/home/myuser/.cache/claude-tmp)
  2. Have another user run Claude Code first (creates /tmp/claude/ owned by them)
  3. Attempt to spawn a subagent via the Task tool

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

 2.1.12

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Terminal.app (macOS)

Additional Information

Environment:

  • Platform: Linux (shared server with multiple users)
  • Claude Code version: Current (as of Jan 2025)

Reproduction:

  1. Set TMPDIR to a user-writable directory (e.g., export TMPDIR=/home/myuser/.cache/claude-tmp)
  2. Have another user run Claude Code first (creates /tmp/claude/ owned by them)
  3. Attempt to spawn a subagent via the Task tool

Expected behavior:
Subagent temp files should be created in $TMPDIR/claude/ or similar, respecting the user's configured temp directory.

Actual behavior:
Error: EACCES: permission denied, mkdir '/tmp/claude/-home-kyle'

Claude Code ignores TMPDIR and hardcodes /tmp/claude/, which fails when that directory is owned by another user.

Workaround:
chmod 1777 /tmp/claude/ (requires cooperation from the other user)

Impact:
Blocks subagent usage entirely on shared servers where /tmp/claude/ may be owned by another user.

View original on GitHub ↗

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