[BUG] Harness tells the model to save scripts and outputs to the scratchpad, which macOS wipes at reboot; no setting to relocate or disable it
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
The harness instructs the model to save scripts and outputs to the session scratchpad. On macOS the scratchpad is under /private/tmp, which is cleared at every reboot. Work the user intended to keep is lost without warning. The instruction cannot be relocated or disabled, and CLAUDE.md instructions do not override it because it says "always".
Sources in the 2.1.283 bundle:
- System prompt, environment section, sent with every request:
> Scratchpad directory: <path> — always use it for temporary files (intermediate results, scripts, outputs that don't belong in the project) instead of /tmp or other system temp directories [...] Only use /tmp if the user explicitly asks.
- The same sentence is re-sent in a mid-session "Environment update" when the scratchpad path changes.
- Coordinator/worker context: "Use this for durable cross-worker knowledge". The directory is not durable.
- Artifact tool description: files are placed "in its scratchpad directory when the system prompt lists one and the person names no other location".
The line is gated by tengu_scratch || isArtifactToolEligible(). Setting "enableArtifact": false in settings.json removes it: confirmed mid-session, when the harness sent "The scratchpad directory announced earlier is no longer available; use it no further." The only way to stop the instruction is therefore to give up artifacts.
What Should Happen?
- A setting to relocate the scratchpad (accepting a path relative to the working directory, e.g.
./temporary) or to turn the instruction off. - The instruction should state that the scratchpad is erased on reboot and that files worth keeping belong in the project.
- User instructions on where to save files should take precedence over this default.
- A single documented setting for where Claude saves temporary and intermediate files (e.g.
"temporaryDirectory": "./temporary"), applied consistently to the system prompt, the scratchpad, the Artifact tool, sandboxed Bash$TMPDIRand subagents. At present the only reliable safeguard is a user-writtenPreToolUsehook that parses every Bash command, file write and MCP call to deny writes to/tmp,/var/foldersand the scratchpad. Users should not need one.
Error Messages/Logs
None. The loss is silent.
Steps to Reproduce
- On macOS, start
claudein any project with artifacts enabled. - Ask for an analysis script and a plot without naming a location.
- The files are written to
/private/tmp/claude-<uid>/<project>/<session>/scratchpad/. - Reboot. The files are gone.
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.283 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
zsh
Additional Information
Related: #92166, #88773, #89878, #97128, #93746; #78687 and #78475 (closed as stale).