claude-code - 💡(How to fix) Fix [BUG] --no-session-persistence leaks ai-title stub to ~/.claude/projects [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#52555Fetched 2026-04-24 06:04:02
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×1renamed ×1

--no-session-persistence is documented as "sessions will not be saved to disk and cannot be resumed (only works with --print)", but the ai-title writer still writes a stub file to ~/.claude/projects/<encoded-cwd>/<uuid>.jsonl.

Root Cause

--no-session-persistence is documented as "sessions will not be saved to disk and cannot be resumed (only works with --print)", but the ai-title writer still writes a stub file to ~/.claude/projects/<encoded-cwd>/<uuid>.jsonl.

Code Example

PROJ_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|-|g')"
ls "$PROJ_DIR" > /tmp/before.txt 2>/dev/null

claude -p --no-session-persistence "Get the weather"

ls "$PROJ_DIR" > /tmp/after.txt
diff /tmp/before.txt /tmp/after.txt

---

{"type":"ai-title","aiTitle":"<generated title>","sessionId":"<uuid>"}
RAW_BUFFERClick to expand / collapse

Summary

--no-session-persistence is documented as "sessions will not be saved to disk and cannot be resumed (only works with --print)", but the ai-title writer still writes a stub file to ~/.claude/projects/<encoded-cwd>/<uuid>.jsonl.

Reproducer

PROJ_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|-|g')"
ls "$PROJ_DIR" > /tmp/before.txt 2>/dev/null

claude -p --no-session-persistence "Get the weather"

ls "$PROJ_DIR" > /tmp/after.txt
diff /tmp/before.txt /tmp/after.txt

Same behavior under --print.

A new <uuid>.jsonl appears (~120 bytes) containing a single line:

{"type":"ai-title","aiTitle":"<generated title>","sessionId":"<uuid>"}

The conversation transcript itself is correctly suppressed — only the ai-title writer ignores the flag.

Expected

No file written under ~/.claude/projects/… when --no-session-persistence is set.

Impact

Tools that fan out many --print subprocesses (e.g. multi-agent review runners) accumulate dozens of ~120-byte stub files per invocation, cluttering the session picker and ~/.claude/projects.

Environment

  • claude --version: 2.1.118
  • macOS 24.6.0 (Darwin)

extent analysis

TL;DR

The --no-session-persistence flag is not being respected by the ai-title writer, resulting in unwanted stub files being written to disk.

Guidance

  • Verify that the --no-session-persistence flag is correctly passed to the ai-title writer component.
  • Investigate the ai-title writer's implementation to determine why it ignores the --no-session-persistence flag.
  • Consider modifying the ai-title writer to respect the --no-session-persistence flag, or implement a workaround to clean up the generated stub files.
  • Review the documentation for --no-session-persistence to ensure it accurately reflects the current behavior.

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

The issue appears to be specific to the ai-title writer component and its interaction with the --no-session-persistence flag. The provided reproducer script can be used to verify the issue.

Recommendation

Apply a workaround, such as cleaning up the generated stub files, until the ai-title writer is modified to respect the --no-session-persistence flag. This is because the current behavior is not aligned with the documented expectations.

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