DEV Community

decker
decker

Posted on

Claude Code keeps forgetting your project context? Here are 3 fixes that actually work

Every developer using Claude Code hits the same wall: you spend 30 minutes building context, explaining your project structure, walking through the codebase... and then the session ends. Next time? Start from zero.

I've been using Claude Code daily for the past 2 months, and I've tried pretty much every approach to solve this. Here's what actually works.

The Problem

Claude Code sessions are stateless. Each new session starts fresh — no memory of your previous conversations, your project preferences, or the debugging journey you went through yesterday.

This means you waste time:

  • Re-explaining your tech stack
  • Re-establishing coding conventions
  • Losing the context of multi-session refactoring work
  • Forgetting what prompts worked well before

Fix 1: CLAUDE.md — Your Project's Memory File

The most straightforward solution. Create a CLAUDE.md file in your project root:

# Project Context
- Stack: Next.js 14, TypeScript, Prisma, PostgreSQL
- Testing: Vitest + React Testing Library
- Style: Tailwind CSS, no CSS modules

# Conventions
- Use server actions for mutations
- API routes only for webhooks
- Components in src/components/{feature}/

# Current Work
- Migrating from pages/ to app/ router
- Focus: /dashboard routes this week
Enter fullscreen mode Exit fullscreen mode

Claude Code reads this automatically at session start. It's simple and effective for static context.

Limitation: You have to manually maintain it. It doesn't capture your actual workflow — what you tried, what failed, what prompts worked.

Fix 2: Session Bookmarking with Git

Before ending a session, commit a "checkpoint":

git stash
git log --oneline -5  # note where you are
Enter fullscreen mode Exit fullscreen mode

Then start your next session with:

Look at the last 3 commits. I was working on [feature]. 
The current state is [description]. Continue from here.
Enter fullscreen mode Exit fullscreen mode

This gives Claude Code some historical context through git history.

Limitation: Git captures code changes, not the conversation. You lose the reasoning, the failed approaches, the specific prompts that led to breakthroughs.

Fix 3: Session Replay Tools

This is where it gets interesting. Tools like Mantra record your entire AI coding session — terminal I/O, code changes, everything — and let you replay it later.

The key insight: your coding session IS the context. Instead of trying to summarize what happened, you can literally replay the session and see:

  • Exactly what prompts you used
  • What the AI suggested (and what you rejected)
  • The sequence of changes that led to the current state

I've been using this approach for about a month, and the biggest win isn't even the replay — it's being able to search through past sessions. "How did I fix that auth bug last week?" becomes a searchable question instead of a memory exercise.

Which Approach to Use?

Approach Best For Effort
CLAUDE.md Static project context Low
Git bookmarks Code-level continuity Medium
Session replay Full workflow context Low (automated)

Realistically, you'll want CLAUDE.md as a baseline + one of the other approaches for workflow continuity.

What's Worked Best for Me

I combine all three:

  1. CLAUDE.md for project basics (updated weekly)
  2. Descriptive commit messages for code context
  3. Session replay for the conversational context that gets lost everywhere else

The memory problem in AI coding tools isn't fully solved yet — but these approaches get you 80% of the way there.


What's your approach for maintaining context across AI coding sessions? I'd love to hear what works for others.

Top comments (0)