claude-code - 💡(How to fix) Fix Background session: $CLAUDE_JOB_DIR writes trigger "sensitive file" prompt with non-persistent allow-list

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Background sessions instruct the agent to write temporary files to $CLAUDE_JOB_DIR (= ~/.claude/jobs/<uuid>/). However, Claude Code marks ~/.claude/ as a sensitive directory, so every write to $CLAUDE_JOB_DIR triggers a "sensitive file" permission prompt.

The "Yes, and always allow access to <uuid>/" option is tied to the specific UUID of that session, so the next background job (with a new UUID) prompts again. Users see the same dialog every session, with no way to permanently allow it.

Root Cause

Background sessions instruct the agent to write temporary files to $CLAUDE_JOB_DIR (= ~/.claude/jobs/<uuid>/). However, Claude Code marks ~/.claude/ as a sensitive directory, so every write to $CLAUDE_JOB_DIR triggers a "sensitive file" permission prompt.

The "Yes, and always allow access to <uuid>/" option is tied to the specific UUID of that session, so the next background job (with a new UUID) prompts again. Users see the same dialog every session, with no way to permanently allow it.

Fix Action

Workaround

Add to ~/.claude/settings.json allow list:

"Write(/Users/<you>/.claude/jobs/**)"

This works but treats the symptom. The underlying issue is the inconsistency between "use this dir" and "this dir is sensitive."

Code Example

"Write(/Users/<you>/.claude/jobs/**)"
RAW_BUFFERClick to expand / collapse

Description

Background sessions instruct the agent to write temporary files to $CLAUDE_JOB_DIR (= ~/.claude/jobs/<uuid>/). However, Claude Code marks ~/.claude/ as a sensitive directory, so every write to $CLAUDE_JOB_DIR triggers a "sensitive file" permission prompt.

The "Yes, and always allow access to <uuid>/" option is tied to the specific UUID of that session, so the next background job (with a new UUID) prompts again. Users see the same dialog every session, with no way to permanently allow it.

Repro

  1. Run a long-running bash command in a background session; the agent wraps it with > $CLAUDE_JOB_DIR/foo.log 2>&1
  2. Observe: "Claude requested permissions to edit /Users/<you>/.claude/jobs/<uuid>/foo.log which is a sensitive file"
  3. Choose option 2 "Yes, and always allow access to <uuid>/"
  4. Trigger another background job -- new UUID, dialog appears again

Internal contradiction

The system prompt for background sessions explicitly says:

Use $CLAUDE_JOB_DIR (/Users/<you>/.claude/jobs/<uuid>) for any temporary files (scripts, query files, intermediate outputs) instead of /tmp -- parallel bg jobs share /tmp and clobber each other's files.

But the same Claude Code marks writes to ~/.claude/ as sensitive. The agent is told to write to a path that then triggers a permission prompt every time.

Proposed fix

Option 1 (preferred): Treat ~/.claude/jobs/** as a trusted write target by default (not sensitive). It is Claude Code's own designated temp space for background jobs -- not user config.

Option 2: Expose a stable non-UUID path (e.g. ~/.claude/jobs/current/ symlink pointing at the current UUID) so allow-list entries persist across sessions.

Option 3: When the agent writes to $CLAUDE_JOB_DIR, treat it as a trusted self-write (the path came from the harness itself).

Workaround

Add to ~/.claude/settings.json allow list:

"Write(/Users/<you>/.claude/jobs/**)"

This works but treats the symptom. The underlying issue is the inconsistency between "use this dir" and "this dir is sensitive."

Environment

  • Claude Code version: 2.1.142
  • OS: macOS Darwin 25.5.0

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING