DEV Community

Why Your AI Coding Assistant Forgets Everything When the Chat Ends, and How to Stop Re-Explaining Your Project

An AI coding assistant forgets context between sessions because each chat starts with an empty context window, and nothing from the last conversation is loaded back in unless something puts it there. The fix is a memory layer that saves decisions, fixes and preferences and loads them into each new session.

You've probably felt this. On Monday you tell Claude Code you're dropping Redis for SQLite. On Tuesday you open a new chat, or open Cursor, and it suggests a Redis client. You explain it again. This article covers why that happens, what a useful session memory holds, and how to get it back into the next chat without handing your code to someone else's server.

Why an AI coding assistant forgets context between sessions

It isn't forgetfulness. The model doesn't learn from your chat. It reads whatever is in its context window for that conversation and answers from that. When the chat ends, the window goes away. A new chat gets a new window with your system prompt, your open files and your first message in it, and that's all.

A bigger window doesn't fix this. It only changes how much you can fit into one conversation. A larger window still starts empty, and long sessions get slower and noisier as they fill up. What you want is persistent context: a small, curated set of facts that is there at the start every time.

The problem gets worse when you use more than one tool. Claude Code, Cursor and Codex each keep their own history, and none of them can see the others'. What you taught one is invisible to the rest. A second laptop makes it worse again.

What is worth remembering

The obvious idea is to save everything and feed it back. That fails quickly. Transcripts are long, repetitive and full of dead ends. Pasting them into a new chat uses up the window you were trying to protect.

Most of what you'd re-explain falls into three kinds of thing:

  • Decisions. "We use SQLite, not Redis, because this runs on one box." The reason matters as much as the choice.

  • Fixes. "The flaky test was a timezone issue in the fixture, not the parser." Next time you hit the same error, you want that answer in seconds.

  • Preferences. "Always use pnpm. Never npm." Small rules like this are the ones people get tired of repeating.

Each of these is a sentence or two. A few hundred of them still fit in a small briefing, which is the point. At Agentic Brain, we capture these three things from your coding sessions, rank them, and drop the rest.

Tag memories by project

A decision about one repo shouldn't leak into another. Agentic Brain files each memory under the project it came from, found by walking up from your working folder to the nearest .git. When you open a folder, that repo's history comes first. It isn't walled off, though. A recall can search one project or all of them, so a lesson from one codebase can still help in another.

How memory gets back into the next chat

There are two paths, and they work together.

A start-up briefing

When a session starts, a hook runs before you type anything. It picks the most relevant memories for the folder you're in and injects them as a briefing. Ours is capped at 2,000 tokens, and in our own timing it's ready in 84 ms (p50). The cap is deliberate. A briefing that grows without limit just recreates the transcript problem.

The same briefing reaches every supported tool: Claude Code, Cursor, Codex, Antigravity and Kilo Code (beta). So the SQLite decision you made in Claude Code on Monday is already known to Cursor on Tuesday.

Recall on demand over MCP

Two thousand tokens can't hold everything, and it shouldn't try. When the assistant needs something that isn't in the briefing, it asks. Agentic Brain exposes MCP tools for this: brain_recall, brain_remember, brain_context and a load-my-brain command. In our own measurements, recall across 10,000 memories takes 28 ms (p50). Search is hybrid, combining keywords with meaning, so "why did we drop the cache layer" can find a note that says "Redis removed".

Those figures come from our own benchmarks, so treat them as ours and not as an independent test. You can check how well recall works on your own history with brain eval, which scores it against what you've actually done.

Across machines

If you work on a desktop and a laptop, the briefing should match on both. At start-up, Agentic Brain merges in what your other machines have learned. You can read how the whole flow fits together on the Agentic Brain site.

Keeping it yours

Memory about your code is sensitive. It holds your architecture choices, your mistakes and sometimes your internal names. So where it lives matters.

Agentic Brain keeps memories in a local SQLite database on your machine. There's no account and no server of ours. For sync, memory is encrypted with age and stored as a Release asset in your own private GitHub repo. The key stays in your OS Keychain. Only you hold it, which also means nobody can recover your memory if you lose it. A leaked repo or token exposes nothing readable.

You also stay in control of the contents. A local control panel lets you read, edit, pin or delete any memory. If one is wrong, fix it. If you'd rather not start from old sessions, start fresh. It's free and Apache-2.0, built by Rohith, Chandan and Sushmita, so you can read the code too.

If you switch between AI coding tools or machines, try it on one repo for a week and see whether you stop re-explaining. Install Agentic Brain from the site.

Frequently asked questions

Why does Claude Code forget my project between sessions?

Claude Code reads only what's in the current context window, and each new session begins with a fresh one. Nothing you said earlier is carried over unless it's written down somewhere that gets loaded at start-up. A memory layer does that loading for you.

Can an AI coding tool remember decisions without uploading my code to a hosted service?

Yes. Agentic Brain stores memories in a local SQLite database and needs no account. If you sync between machines, the data goes up age-encrypted to your own private GitHub repo, with the key in your OS Keychain.

How many tokens should a session start-up briefing use?

Keep it small enough that it never crowds out your actual work. Agentic Brain caps the briefing at 2,000 tokens and fetches anything else on demand through MCP recall. That's a design choice we made, not a universal standard.

Does a bigger context window fix this?

No. A bigger window holds more within one chat, but the next chat still starts empty. You still need something that carries the important facts across sessions.

Can Claude Code and Cursor share memory?

Not on their own, since each keeps its own history. With a shared layer like Agentic Brain, both read from the same store, so a decision made in one is known to the other.

Top comments (0)