CLAUDE_CODE_SKIP_PROMPT_HISTORY disables all transcript persistence since 2.1.77

Status Closed — not planned
Reported on v2.1.77
Maintainer reply None cached
Activity 8 comments · opened Mar 19, 2026 · closed May 6, 2026

Bug Description

<mark>CLAUDE_CODE_SKIP_PROMPT_HISTORY=1 silently disables all session transcript persistence</mark> starting in version 2.1.77.

Quick Summary

Previously (2.1.76 and earlier), this env var only controlled prompt history (up-arrow recall in <samp>history.jsonl</samp>).

The regression: Zero <samp>.jsonl</samp> transcript files are written for any session, breaking:

  • <kbd>/resume</kbd>
  • <kbd>/stats</kbd>
  • Session sharing
  • All features that depend on transcript data

---

What Changed

The Gatekeeper Method

The shouldSkipPersistence() method on the session storage class gates every call to appendEntry() and materializeSessionFile() &mdash; the two functions responsible for creating and writing to transcript <samp>.jsonl</samp> files.

The Addition

A 4th condition was added in 2.1.77 that checks CLAUDE_CODE_SKIP_PROMPT_HISTORY.

<details>
<summary><strong>Code Comparison</strong> &mdash; Before vs. After</summary>

<figure>

2.1.76 &mdash; shouldSkipPersistence():

shouldSkipPersistence() {
  let H = isEnvVarTrue(process.env.TEST_ENABLE_SESSION_PERSISTENCE);
  return getNodeEnv() === "test" && !H
    || getSettings()?.cleanupPeriodDays === 0
    || isSkipPersistence();
}

<figcaption>Three conditions: test mode, cleanupPeriodDays, and isSkipPersistence()</figcaption>
</figure>

<figure>

2.1.77+ &mdash; shouldSkipPersistence():

shouldSkipPersistence() {
  let H = isEnvVarTrue(process.env.TEST_ENABLE_SESSION_PERSISTENCE);
  return getNodeEnv() === "test" && !H
    || getSettings()?.cleanupPeriodDays === 0
    || isSkipPersistence()
    || isEnvVarTrue(process.env.CLAUDE_CODE_SKIP_PROMPT_HISTORY);  // <-- NEW
}

<figcaption><mark>Fourth condition added</mark>: CLAUDE_CODE_SKIP_PROMPT_HISTORY now gates all persistence</figcaption>
</figure>

</details>

The Effect

Result: If CLAUDE_CODE_SKIP_PROMPT_HISTORY is set to any truthy value ("1", "true", "yes"), <mark>no transcript files are created or written to</mark>. Both appendEntry() and materializeSessionFile() bail out immediately when shouldSkipPersistence() returns true.

---

How It Breaks

Original Purpose

The CLAUDE_CODE_SKIP_PROMPT_HISTORY env var was introduced to let users disable prompt history recall (the <kbd>&uarr;</kbd> up-arrow feature that writes to <samp>history.jsonl</samp>).

Independent Implementation

That behavior is handled by a completely separate function which checks the same env var independently:

<figure>

function writePromptHistoryEntry(H) {
  if (isEnvVarTrue(process.env.CLAUDE_CODE_SKIP_PROMPT_HISTORY)) return;
  // ... writes to history.jsonl
}

<figcaption>Prompt history check is independent &mdash; does not need shouldSkipPersistence() gate</figcaption>
</figure>

What Users Expected vs. What Happened

Users who set this env var expected it to only disable prompt history, as the name implies.

Instead, starting in 2.1.77, it also disables:

| Feature | How it breaks |
|:--------|:-------------|
| Session transcripts | No <samp>.jsonl</samp> file created &mdash; materializeSessionFile() returns early |
| <kbd>/resume</kbd> | No transcript to resume from |
| <kbd>/stats</kbd> | Sessions missing from activity data |
| Session sharing | No transcript to upload |
| Context window compaction | Compaction snapshots not persisted |

---

Impact

Silent Data Loss

No error, warning, or log message is emitted. Sessions appear to work normally but produce no persistent record.

Retroactive

Every session since upgrading to 2.1.77 has zero transcript data. There is no way to recover these transcripts.

Mislabeled Env Var

The env var name says <q>skip prompt history</q> but now controls <strong>all persistence</strong>. Users have no reason to expect this side effect.

---

Steps to Reproduce

1. Configure the env var

Set CLAUDE_CODE_SKIP_PROMPT_HISTORY to "1" in <samp>~/.claude/settings.json</samp>:

<figure>

{
  "env": {
    "CLAUDE_CODE_SKIP_PROMPT_HISTORY": "1"
  }
}

<figcaption>Configuration that triggers the bug</figcaption>
</figure>

2. Start a session

Start a new Claude Code session (<kbd>claude</kbd> in terminal)

3. Have a conversation

Send any message and have a conversation

4. Exit

Exit the session

5. Check for transcripts

<figure>

find ~/.claude/projects/ -name "*.jsonl" -newer /tmp/marker -type f

<figcaption>No transcript files will be found for sessions started after setting the env var</figcaption>
</figure>

6. Result

<mark>No transcript <samp>.jsonl</samp> is created for the session</mark>

---

Expected Behavior

CLAUDE_CODE_SKIP_PROMPT_HISTORY should only disable prompt history (<samp>history.jsonl</samp>), not session transcript persistence. This was the behavior in 2.1.76 and earlier.

---

Recommended Fix

[!TIP] Primary Fix: Remove isEnvVarTrue(process.env.CLAUDE_CODE_SKIP_PROMPT_HISTORY) from shouldSkipPersistence(). The prompt history function already checks this env var independently &mdash; it does not need to also gate transcript persistence.

If Dual-Purpose Behavior Is Intended

If CLAUDE_CODE_SKIP_PROMPT_HISTORY is meant to control both prompt history and session transcripts, the solution is:

  1. Rename the env var to something clear: CLAUDE_CODE_SKIP_ALL_PERSISTENCE
  2. Update documentation to explicitly state it disables both features
  3. Provide a migration notice for users who have the old env var set

This would prevent silent breakage for existing users.

---

Environment

| | Details |
|:--|:--|
| Regression introduced | 2.1.77 |
| Last working version | 2.1.76 |
| Current version tested | 2.1.79 |
| Platform | Linux (Arch) |

---

<details>
<summary><strong>Discovery Context</strong> &mdash; How this bug was found</summary>

Investigation Timeline

This bug was discovered during a forensic investigation into missing session transcripts:

  1. Timeline verification

Confirmed last working transcripts were written by 2.1.76 processes (Mar 16, 03:49&ndash;05:36)

  1. Binary comparison

Extracted and compared shouldSkipPersistence() implementation between 2.1.76 and 2.1.77 binaries

  1. Env var audit

Checked all environment variables in <samp>~/.claude/settings.json</samp>

  1. Code path tracing

Followed transcript writing from API response &rarr; recordTranscript() &rarr; insertMessageChain() &rarr; appendEntry() &rarr; gate at shouldSkipPersistence()

Root Cause Isolation

The regression was isolated to the single line addition in 2.1.77's shouldSkipPersistence() method.

</details>

View original on GitHub ↗

8 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/23710
  2. https://github.com/anthropics/claude-code/issues/18311
  3. https://github.com/anthropics/claude-code/issues/31610

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

johnzfitch · 6 months ago

Bump

gonewx · 6 months ago

I've been dealing with the same issue. Here's what I've found works:

Immediate workaround:

  1. Claude stores sessions in ~/.claude/projects/ as JSONL files
  2. You can manually back up these files before they get corrupted
  3. Use ls -la ~/.claude/projects/*/ to see your session files

Longer-term solution:
There are tools that can import and index these JSONL files, making them searchable across all your projects. Some even support "time travel" — seeing exactly what code was shown at each point in the conversation.

The key insight is: your session data is valuable, but Claude's built-in session management is fragile. External tools that index and search your local session files give you much better control.

Has anyone else found reliable ways to preserve session history?

johnzfitch · 6 months ago
Has anyone else found reliable ways to preserve session history?

Yes I use my own project claude-warden that grabs logs through Claude's OTEL pathway.

github-actions[bot] · 5 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

johnzfitch · 5 months ago

Don't close

johnzfitch · 5 months ago
Closing for now — inactive for too long. Please open a new issue if this is still relevant.

👎👇🔽⏬

github-actions[bot] · 3 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.