claude-code - 💡(How to fix) Fix Claude Code 2.1.119 corrupts `.claude.json` by writing GrowthBook cache strings with raw (unescaped) newlines [3 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#52894Fetched 2026-04-25 06:18:02
View on GitHub
Comments
3
Participants
2
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×4commented ×3closed ×1cross-referenced ×1

Claude Code 2.1.119 intermittently writes ~/.claude/.claude.json with raw newline bytes (0x0A) inside JSON string values, producing invalid JSON. On next launch, Claude Code self-detects the corruption, moves the file to backups/.claude.json.corrupted.<ts>, and presents a "Configuration Error — Unterminated string" dialog whose only options are "Exit and fix manually" or "Reset with default configuration" (the latter wipes all user state).

Specifically, the cachedGrowthBookFeatures.tengu_flint_harbor_prompt.prompt and .guideTemplate fields are written with literal newlines rather than \n escapes.

Error Message

Claude Code 2.1.119 intermittently writes ~/.claude/.claude.json with raw newline bytes (0x0A) inside JSON string values, producing invalid JSON. On next launch, Claude Code self-detects the corruption, moves the file to backups/.claude.json.corrupted.<ts>, and presents a "Configuration Error — Unterminated string" dialog whose only options are "Exit and fix manually" or "Reset with default configuration" (the latter wipes all user state).

Root Cause

Claude Code 2.1.119 intermittently writes ~/.claude/.claude.json with raw newline bytes (0x0A) inside JSON string values, producing invalid JSON. On next launch, Claude Code self-detects the corruption, moves the file to backups/.claude.json.corrupted.<ts>, and presents a "Configuration Error — Unterminated string" dialog whose only options are "Exit and fix manually" or "Reset with default configuration" (the latter wipes all user state).

Specifically, the cachedGrowthBookFeatures.tengu_flint_harbor_prompt.prompt and .guideTemplate fields are written with literal newlines rather than \n escapes.

Code Example

"guideTemplate": "# Welcome to [Team Name]\n\n## How We Use Claude\n\nBased on..."
                                           ^^     ^^ proper JSON escapes (backslash + n)

---

"guideTemplate": "# Welcome to [Team Name]<0x0A><0x0A>## How We Use Claude<0x0A>..."
                                           raw newline bytes, invalid JSON
RAW_BUFFERClick to expand / collapse

Summary

Claude Code 2.1.119 intermittently writes ~/.claude/.claude.json with raw newline bytes (0x0A) inside JSON string values, producing invalid JSON. On next launch, Claude Code self-detects the corruption, moves the file to backups/.claude.json.corrupted.<ts>, and presents a "Configuration Error — Unterminated string" dialog whose only options are "Exit and fix manually" or "Reset with default configuration" (the latter wipes all user state).

Specifically, the cachedGrowthBookFeatures.tengu_flint_harbor_prompt.prompt and .guideTemplate fields are written with literal newlines rather than \n escapes.

Environment

  • Claude Code: 2.1.119 (latest at time of report; released 2026-04-23)
  • Platform: Linux (Debian-based Docker container)
  • Installed via: curl -fsSL https://claude.ai/install.sh | bash
  • Node.js: 22.22.0
  • CLAUDE_CONFIG_DIR=/home/node/.claude

Byte-level evidence (same process, same file, 7 seconds apart)

Claude Code itself rotates a backup right before writing. The backup is valid; the subsequent write is corrupt.

Valid backup written by Claude Code (backup.1777041841987):

"guideTemplate": "# Welcome to [Team Name]\n\n## How We Use Claude\n\nBased on..."
                                           ^^     ^^ proper JSON escapes (backslash + n)

Corrupted write by Claude Code 7 seconds later (corrupted.1777041849186):

"guideTemplate": "# Welcome to [Team Name]<0x0A><0x0A>## How We Use Claude<0x0A>..."
                                           raw newline bytes, invalid JSON

Same file, same Claude Code process, same session. Claude Code read the value with proper \n escapes (from its own just-written backup) and wrote it back with literal newlines.

Fields affected

  • .cachedGrowthBookFeatures.tengu_flint_harbor_prompt.prompt (~4.5 KB, 60 raw newlines)
  • .cachedGrowthBookFeatures.tengu_flint_harbor_prompt.guideTemplate (~1.7 KB, 62 raw newlines)

No other fields are affected — the write path only mishandles these two multi-line strings.

Reproducibility

  • Intermittent in real sessions: corrupts roughly every other launch on one user's machine. Correlates with the GrowthBook fetch cache cycle.
  • Does NOT reproduce from a clean .claude.json: launching claude -p "ok" with CLAUDE_CONFIG_DIR pointed at an empty config dir produces a valid file, even when the feature flag IS fetched and cached. So there's an accumulated-state precondition.
  • Host vs container: On the same machine, macOS host claude 2.1.119 caches the same feature without corruption. Only the Linux container hits it. Clean-state repros inside the container also don't hit it. The specific precondition has not been isolated.

Suggested fix

The cache-write path for GrowthBook feature values appears to decode the escaped string (into a JS string with real newlines) and then write it back without re-escaping. Should use JSON.stringify end-to-end.

Impact

  • "Reset with default configuration" wipes user state. Users unfamiliar with hand-editing JSON have effectively only this option.
  • Wiped state can include MCP OAuth tokens, IDE connections, session history, tips progress, etc.

extent analysis

TL;DR

The most likely fix is to use JSON.stringify when writing the cache for GrowthBook feature values to ensure proper JSON escaping.

Guidance

  • Verify the issue by checking the ~/.claude/.claude.json file for raw newline bytes (0x0A) in the cachedGrowthBookFeatures.tengu_flint_harbor_prompt.prompt and .guideTemplate fields.
  • Inspect the cache-write path for GrowthBook feature values to confirm if it decodes the escaped string without re-escaping it before writing.
  • Consider using a debugging tool or adding logging statements to monitor the cache-write process and identify the root cause of the intermittent corruption.
  • To mitigate the issue, users can manually edit the ~/.claude/.claude.json file to replace raw newline bytes with proper JSON escapes (\n) in the affected fields.

Example

const jsonString = JSON.stringify({
  cachedGrowthBookFeatures: {
    tengu_flint_harbor_prompt: {
      prompt: "Hello\nWorld",
      guideTemplate: "## Guide\n### Template"
    }
  }
});
// Write jsonString to ~/.claude/.claude.json

Notes

The issue appears to be specific to the Linux container environment and may be related to the GrowthBook fetch cache cycle. Further investigation is needed to isolate the specific precondition that triggers the corruption.

Recommendation

Apply a workaround by manually editing the ~/.claude/.claude.json file to replace raw newline bytes with proper JSON escapes (\n) in the affected fields, until a permanent fix can be implemented using JSON.stringify in the cache-write path.

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

claude-code - 💡(How to fix) Fix Claude Code 2.1.119 corrupts `.claude.json` by writing GrowthBook cache strings with raw (unescaped) newlines [3 comments, 2 participants]