Troubleshooting Claude Code Memory Errors: Context Window Full & Forgotten Sessions

Fix common Claude Code memory issues — context window full warnings, forgotten conversations, truncated responses, and lost context. Practical solutions for daily use.

·9 min read

The Symptoms

You're deep in a Claude Code session and it starts acting weird:

> Symptom 1: Claude says "I don't have access to that file" — even though you discussed it 10 messages ago > > Symptom 2: Responses get short and generic — "That looks like it could be improved" > > Symptom 3: You see Context limit: 87% or similar in the status bar > > Symptom 4: Claude starts making mistakes on things it previously showed it understood

These are all symptoms of hitting Claude Code's memory/context constraints. Here's how to diagnose and fix each one.

---

Error 1: "Context Window Full" Warning

This is the most visible memory issue. Claude Code shows a context usage bar, and when it's near full, performance degrades.

Quick Fix: Start a Fresh Session

The fastest solution is always the simplest:

# Exit current session
# (Ctrl+C or type /exit)

# Start a new session claude

A fresh session gives you a full 200K token context window.

Better Fix: Use Project Context Files

Instead of relying on conversation memory, offload context to files:

# Write what Claude needs to know to a file
cat > .claude/current-task.md << 'EOF'

Current Task

Building user authentication system.

What's Done

- Login form component (src/components/LoginForm.tsx) - Auth API route (src/app/api/auth/login/route.ts)

What's Needed

- Password reset flow - Session management with JWT

Key Decisions

- JWT stored in httpOnly cookies, not localStorage - Token expiry: 24 hours - Refresh token: 7 days EOF

Then in a new session:

> @.claude/current-task.md Continue with the password reset flow

This approach is far more efficient than keeping everything in conversation memory — you get back a full context window while retaining all critical task knowledge.

Long-Term Fix: Write a CLAUDE.md

For project-wide knowledge that shouldn't require resets:

# .claude/CLAUDE.md

Project

E-commerce Next.js app with Stripe

Architecture

- App Router, TypeScript, Prisma/PostgreSQL - Components in src/components/, grouped by feature - API routes in src/app/api/ - All database queries use Prisma client

Commands

- dev: npm run dev - test: npm test - build: npm run build

External Links: - Claude Code Settings & Config — configure project context - CLAUDE.md Documentation — reference for all settings

---

Error 2: Claude Forgets What We Discussed

This happens when the context window fills up and earlier messages get truncated. Claude doesn't stop working — it just loses the beginning of your conversation.

How to Tell If Context Was Truncated

Look for these signs: - Claude says "based on what you've shown me" instead of recalling specifics - It re-asks questions you already answered - It suggests solutions you already rejected

Fix: Keep a Decision Log

Create a running log of decisions made during a session:

# In your Claude Code session, periodically ask:
> Write the key decisions we've made to .claude/session-log.md

Or use a hook to auto-save decisions (see Claude Code Hooks Guide).

Fix: Session Bookmarks

For long sessions, create checkpoint files:

# Save the current state
cat > .claude/checkpoint-001.md << 'EOF'

Checkpoint 1

- Files created: [...] - Decisions made: [...] - Next steps: [...] EOF

# Continue working... # When context gets full, start fresh and load checkpoint

> 💡 Pro tip: Make a habit of typing /save checkpoint-name periodically in long sessions. It forces you and Claude to agree on what's been done.

---

Error 3: Claude Can't Find Files It Created

This is frustrating — Claude literally just wrote a file but can't "find" it in context.

Why This Happens

Claude Code sees files through two mechanisms: 1. Conversation memory — remembers discussions about files 2. File system reads — reads actual files on demand

If a file was created earlier and the conversation truncated that memory, Claude can't recall its contents. But the file still exists on disk.

Fix: Always Confirm File Writes

When Claude says "I created the file," verify it:

# Check the file exists
ls -la src/components/LoginForm.tsx
# Expected: -rw-r--r-- 1 user user 2342 May 11 14:30

# Check the content cat src/components/LoginForm.tsx | head -5

Fix: Use @ References

Instead of trusting Claude's memory, use file references:

@src/components/LoginForm.tsx — add error handling to this

Claude reads the file fresh and has full access to it, regardless of conversation history.

---

Error 4: "Too Much Code" Warning

When you paste a large file or ask Claude to review an entire codebase, you might see messages about "there's a lot of code here."

Fix: Targeted Requests

Instead of:

> Review all files in the project for security issues

Try:

> @src/api/route.ts check for SQL injection vulnerabilities in this file
> @src/middleware.ts verify the authentication logic

Fix: Use Grep First

Find the relevant code before asking Claude to read it:

# Find all places that handle user input
grep -rn "req.body\|req.query\|input" src/ --include="*.ts" | head -20

Then ask Claude about specific results:

> The file src/api/users.ts handles user input on line 45, 78, and 112. Review these three handlers.

---

Error 5: Session Crashes or Hangs

If Claude Code crashes or freezes mid-session, you may lose all in-session context.

Prevention: Auto-Save Hook

Set up a hook that periodically saves session state:

// .claude/settings.json
{
  "hooks": {
    "postMessage": "cat .claude/session-log.md > .claude/session-backup.md"
  }
}

This saves your session log after every message. If the session crashes, start a new session and reference the backup.

Recovery After Crash

# Read the backup to catch up
cat .claude/session-backup.md

# Start new session with context from backup claude

# In the new session: > @.claude/session-backup.md Continue where we left off

External Links: - Claude Code Hooks Reference — official hook API docs - Claude Code Hooks Automation Guide — detailed hook examples

---

Error 6: Claude Doesn't Remember Project Structure

If you've been working on a project for weeks, Claude in a fresh session may not know its structure.

Fix: Index Your Project

Create a file that maps your project structure:

# Generate a project index
find src/ -type f -name ".ts" -o -name ".tsx" | sort > .claude/project-index.md

Or include in CLAUDE.md:

# .claude/CLAUDE.md

Project Structure

- src/app/ — Next.js App Router pages - src/components/ — Shared UI components - src/lib/ — Utility functions and shared logic - src/types/ — TypeScript type definitions - prisma/ — Database schema and migrations

---

Quick Reference: Memory Error Fixes

| Symptom | Root Cause | Quick Fix | Permanent Fix | |---------|-----------|-----------|---------------| | Context window full | Too many messages | Start new session | Use CLAUDE.md + decision log | | Forgets early discussion | Message truncation | /save and reload | Periodic checkpoints | | Can't find files | Conversation lost reference | Use @filepath | Verify file writes | | "Too much code" | Large context load | Break into targeted questions | Use grep to find relevant code | | Session crash | System/network issue | Start new + load backup | Auto-save hooks |

---

Prevention: Build a Memory-Friendly Workflow

The best fix is preventing memory issues before they happen:

1. Set up CLAUDE.md — 5 minutes upfront saves hours of repeating yourself 2. Use @file references — instead of pasting code into chat 3. Write decisions to files — don't trust conversation memory 4. Start fresh per task — one feature = one session 5. Use checkpoints — for long, multi-session tasks 6. Run /compact — if available in your version, this summarizes old context

Related Articles: - Claude Code Memory Systems Explained — understand the architecture - Claude Code Hooks Automation Guide — automate memory management - 7 Ways to Speed Up Claude Code — keep sessions fast

Ad Unit Placeholder

Related Articles