DEV Community

Surya S S
Surya S S

Posted on

How do you handle Claude losing the plot during long coding sessions?

I've been running into something with Claude that I can't quite figure out the best workflow for.

I'll start a coding task and the first few hours are honestly impressive. Claude understands the existing code, finds the relevant files, makes the changes, tests them, and generally stays on track.
But once the session gets really long, things sometimes start getting messy.

For example, I'll fix issue A, then move on to issue B. While working on B, Claude changes something related to A. I point it out, it fixes A again, and then something from an earlier part of the conversation gets lost.

The frustrating part is that the individual responses still look reasonable. It's not necessarily an obvious hallucination. It feels more like the overall understanding of the project slowly drifts as the session gets longer.

I've tried compacting and starting a completely new session, but I'm still not sure when I should use each approach.

For people who use Claude seriously on larger codebases:

What's your workflow for this?

  • Do you keep one long session until the feature is finished?
  • Do you start a new session for every major subtask?
  • Do you maintain a CLAUDE.md with important architectural decisions?
  • Do you ask Claude to create a handoff document before starting a new session?
  • Do you explicitly summarize the current state before continuing?
  • Or do you just restart the session once it gets too large?

I'm especially interested in workflows for existing production codebases, rather than greenfield projects.

I'm trying to figure out whether there's a good way to manage the context intentionally, instead of eventually reaching the point where I'm telling Claude:

"Remember, we already decided this 20 messages ago." 😅

What has actually worked for you?

Top comments (0)