[BUG] Claude Code crashes when saving project memory with "File has not been read yet" error

Status Fixed / completed
Maintainer reply None cached
Activity 3 comments · opened Jun 26, 2025 · closed Jul 20, 2025

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [x] Other: Claude CLI (Claude Code)
  • Claude CLI version: v1.0.35
  • Operating System: macOS (M4 MacBook Pro)
  • Terminal: <!-- Terminal used -->

Bug Description

Claude Code crashes with "Error: File has not been read yet. Read it first before writing to it." when using memory commands (starting with # ) in the terminal. The application terminates unexpectedly after displaying a stack trace.

Steps to Reproduce

  1. Open Claude Code in terminal
  2. Execute a memory command using the format # memory test crash!!!
  3. When prompted "Where should this memory be saved?", select either:
  • Option 1 (Project memory - ./CLAUDE.md) OR
  • Option 2 (Project memory (local) - ./CLAUDE.local.md)
  1. Wait for the "Saving project memory..." process to start
  2. Application crashes with the error stack trace

Note: Option 3 (User memory - ~/.claude/CLAUDE.md) works correctly without any issues.

Expected Behavior

The memory command should be processed successfully and project memory should be saved to the selected project memory file (./CLAUDE.md or ./CLAUDE.local.md) without crashing the application, similar to how user memory (Option 3) works correctly.

Actual Behavior

The application crashes with the following error:

Error: File has not been read yet. Read it first before writing to it.
    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1920:1009
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async I (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:622:14088)

Node.js v24.2.0

Additional Context

  • Hardware: M4 MacBook Pro
  • Node.js version: v24.2.0
  • Claude Code version: v1.0.35
  • The crash occurs specifically when using memory commands (commands starting with #)
  • Issue is isolated to project-level memory options only:
  • ❌ Option 1: ./CLAUDE.md (Project memory) - CRASHES
  • ❌ Option 2: ./CLAUDE.local.md (Project memory local) - CRASHES
  • ✅ Option 3: ~/.claude/CLAUDE.md (User memory) - WORKS CORRECTLY
  • The error suggests a file I/O issue where the application attempts to write to project memory files that haven't been read first
  • The error occurs in the memory saving functionality (Saving project memory... was displayed before crash)
  • Stack trace indicates the issue is in the CLI tool's file handling logic at line 1920
  • This appears to be a systematic issue with project-level memory file handling, while user-level memory handling works correctly
  • The bug suggests different code paths are used for project vs user memory, with the project memory path having a file read/write order issue

View original on GitHub ↗

3 Comments

jackgill · 1 year ago

Interestingly enough I encountered this error message when Claude was trying to write a README.md file for a newly-created project. The error message appeared 3 times, but Claude did not crash and was ultimately able to create the file successfully.

zekaizer · 1 year ago

It seems like the latest version has fixed it. The problem doesn't occur anymore.

github-actions[bot] · 1 year 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.