glimfly
guide updated

Why does your AI keep forgetting what you were doing?

The short answer

Your AI is running out of room. Everything it can “see” during a session (your messages, the files it reads, command output, its own earlier replies) shares one fixed budget called the context window. Once that budget fills, something has to give: Claude Code first drops older tool output, then summarizes the conversation if it still needs space, a process called compacting. The summary keeps the gist (what you asked for, the main decisions) but drops exact wording, specific variable names, and the smaller corrections you made along the way. That’s the forgetting. It’s a resource limit doing exactly what it’s designed to do. The model isn’t confused about your project; it just ran out of room.

What’s actually competing for the space

Before you type a single word, a chunk of the window is already spent: the system prompt, your project’s CLAUDE.md, any notes the agent saved itself from earlier sessions, and the names of the tools it has access to. Then every file it opens, every grep result, every test run output adds more. Nothing here is stored “in the AI’s head” between messages. The full window gets reconstructed and sent again on every single turn. That’s why a long session gets harder to steer the fuller it gets: everything already inside it is competing for attention on each pass.

As of mid-2026, Claude Code’s default model, Sonnet 5, runs a full 1 million token window out of the box on Pro, Team, and Enterprise plans. Older or lighter models are smaller: Sonnet 4.5 and the fast Haiku 4.5 still cap out at 200,000 tokens (roughly 150,000 words). Either size sounds huge until you remember what fills it: a sprawling codebase, an hours-long debugging session with a dozen failed attempts, a stack of long test logs. That can chew through even a million-token window, and it will fill a 200,000-token one in a single sitting. And each Claude Code session starts with a completely fresh window. It does not carry yesterday’s conversation forward on its own. Only two things persist deliberately: your CLAUDE.md, and a memory file Claude writes to itself as it works.

The symptoms, so you can name them when they hit

  • It reintroduces a bug you already asked it to fix, because the fix and the reasoning behind it got compacted away.
  • It re-adds an import, a function, or a file it already deleted three prompts ago.
  • It asks a question you already answered earlier in the same session.
  • A rule you stated once (“never touch the payments file,” “always use pnpm”) quietly falls away halfway through a long session.
  • You notice a “Conversation compacted” message, and right after, the agent seems to have lost the thread on something specific, even though it clearly remembers the big picture.

None of these mean the model got worse mid-conversation. They mean the detail that mattered lived only in conversation history, which is exactly what gets thinned first.

What survives compaction, and what doesn’t

Most people assume everything either survives compaction or all of it gets lost. It depends on where the instruction lived.

Where it livedAfter compaction
Project-root CLAUDE.mdReloaded from disk, intact
A note Claude saved to its own memory fileReloaded from disk, intact
Something you only said in chatSummarized, exact wording likely gone
A rule scoped to a subfolder (a nested CLAUDE.md)Gone until Claude reads a file in that folder again
A skill you actually used during the sessionRe-added, but trimmed if it’s long

The pattern: anything written to a file that Claude re-reads from disk survives. Anything that only ever existed as a sentence in the back-and-forth is the first thing to go. That single distinction explains most of the “why did it forget that” moments you’ll run into.

What actually helps

  1. Put durable rules in CLAUDE.md instead of chat. If you’ve corrected the same thing twice, that’s the signal to write it down once instead of repeating it. Keep the file under roughly 200 lines; past that, adherence starts to slip, and Claude follows five sharp rules more reliably than fifty vague ones.
  2. Give each session one goal. A session that starts as “fix this bug” and drifts into three unrelated refactors runs out of room faster and confuses itself sooner. This is the same failure mode behind prompt fatigue: each new patch drifts further from the original problem instead of closer to solving it.
  3. Reset deliberately instead of letting it happen to you. Run /clear between unrelated tasks so old, irrelevant conversation stops crowding out what you need next. For a big task about to start, run /compact focus on <the thing that matters> so you control what gets kept, instead of letting an automatic pass guess.
  4. Offload big research instead of reading it into your own window. A subagent works in a completely separate context; only its short summary comes back to you. If you’re about to have Claude read through a dozen files just to answer one question, hand that job to a subagent instead of burning your main session on it.
  5. Treat repeated forgetting as a signal. If the same rule keeps slipping, that’s a sign it’s living in the wrong place. Move it to a file Claude re-reads from disk, and it stops being a fight you have every session.

This doesn’t eliminate the limit. A context window is finite by design, and no amount of prompting removes that ceiling. What changes is where the things you actually care about live: on disk, where they survive, or in the conversation, which drops them first.

What Glim would tell you

This is exactly the kind of moment Glimfly built Glim for. Glim is a small companion that sits next to your agent and narrates what it’s doing while it’s doing it, including the unglamorous parts: context filling up, a compaction about to happen, a rule in your CLAUDE.md that never loaded. Instead of guessing why the AI suddenly forgot something, you see it happen. If you want the rest of the vocabulary this guide builds on, the dictionary is the place to keep digging.

People also ask

“Why does Claude Code suddenly say 'Conversation compacted' in the middle of my session?”

Your context window filled up. Claude Code clears older tool outputs first (old file reads, command logs), and if that's not enough, it summarizes the rest of the conversation into a shorter version so the session can keep going. You'll see the token count drop. That's what keeps a full context window from ending your session outright.

“Should I start a new session for every bug, or keep going in the same one?”

Keep going as long as you're making real progress on one goal. Once you notice you're re-explaining the same bug, or the agent keeps contradicting a decision from earlier in the thread, that's the signal to run /clear and restate the problem fresh instead of sending another patch into an already-crowded conversation.

“If I write more into CLAUDE.md, does that fix the forgetting?”

Only up to a point. CLAUDE.md is read in full every session and survives compaction, which makes it the right place for rules you'd otherwise repeat. But files over roughly 200 lines start reducing how reliably Claude follows them, and it still won't remember yesterday's conversation, only what you deliberately wrote down.

Words from this guide

Want this explained about your own project?

Glim watches your coding agent work and explains your sessions in plain words, live. Join the waitlist to get it first.