Sub-agent research artifacts written to /tmp are lost between sessions, causing redundant re-analysis
Problem
When Claude Code spawns sub-agents (via the Agent tool) to analyze a codebase, those agents often produce valuable research artifacts (architecture summaries, code analysis documents, quick reference guides). However, they write these files to /tmp, where they are:
- Invisible to future sessions — new sessions have no knowledge of these files
- Not referenced by the parent agent — even within the same session, the parent often doesn't know the files exist
- Result: identical analysis is repeated session after session, wasting significant tokens and user time
Example
Over 2 days of working on a Metabase migration project, sub-agents created 11 separate analysis files in /tmp:
/tmp/metabase_architecture.txt (Mar 11)
/tmp/metabase_project_analysis.md (Mar 11)
/tmp/QUICK_REFERENCE.md (Mar 11)
/tmp/README_ANALYSIS.md (Mar 11)
/tmp/metabase_research_summary.md (Mar 12)
/tmp/metabase_technical_details.md (Mar 12)
/tmp/metabase_codebase_analysis.md (Mar 12)
/tmp/metabase_summary.txt (Mar 12)
/tmp/legacy_metabase_summary.md (Mar 12)
/tmp/legacy_code_samples.md (Mar 12)
/tmp/QUICK_REFERENCE.txt (Mar 12)
Most of these contain overlapping content — the same codebase was re-analyzed from scratch multiple times because previous artifacts were forgotten.
Expected behavior
Sub-agent research artifacts should be:
- Written to a discoverable, project-local location (e.g.,
.claude/analysis/or.claude/cache/) — not/tmp - Discoverable by future sessions — new sessions should check for existing analysis before re-doing work
- Kept up to date — if the codebase changes, stale artifacts should be refreshed, but unchanged analysis should be reused
Current workaround
User manually copies files from /tmp into the project tree (CLAUDE.md instructions could reference them), but this defeats the purpose of automated analysis.
Root cause
The Agent tool's sub-agents have no convention or mechanism for persisting research outputs in a location that survives session boundaries. They default to /tmp because it's writable and doesn't trigger permission prompts.
Related issues
- #25292 — Temp file handling: use session-specific directories instead of /tmp (same symptom, different focus: collision vs. reusability)
- #31294 — Subagent memory system not functional (same root cause family: agents can't persist/recall knowledge)
- #31385 — Agent memory writes to unpredictable location (related: even when memory works, location is inconsistent)
- #25999 — Persistent state across context compaction (related: state persistence problem at compaction level)
Suggested solutions
- Project-local analysis cache: Sub-agents write research artifacts to
.claude/cache/(gitignored). Future sessions check this directory before re-analyzing. - Agent research memory: Extend the existing
memorysystem so research agents can store and retrieve analysis results keyed by project path + topic. - Parent-agent awareness: When a sub-agent writes a file, surface it to the parent agent so it can reference it in
CLAUDE.mdor similar persistent context.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗