DEV Community

Cover image for Claude Code forgets everything when you close it. Here's how I made it remember (and share it with Claude.ai)
kaushal trivedi
kaushal trivedi

Posted on

Claude Code forgets everything when you close it. Here's how I made it remember (and share it with Claude.ai)

Every morning I opened Claude Code and did the same thing: explained my project again. What we changed yesterday. Why we picked that approach. What was still broken.

Then I'd switch to Claude.ai on my phone, or hand a task to Codex, and do it all over again.

The worst part wasn't repeating myself. It was the AI forgetting why we made a decision, and quietly undoing a fix from two days ago.

So I built a small open-source tool to fix it for myself: CogniCore. This post shows how it works and how to set it up in a couple of minutes.

What actually gets lost between sessions

When a Claude Code session ends, the useful parts are gone:

the goal you were working toward
decisions, and the reason behind each one
open tasks you left for later
exact values: ticket IDs, versions, file paths, ports

A CLAUDE.md file helps, but you have to remember to update it, it keeps growing, and Claude.ai or ChatGPT can't read a file on your laptop.

The idea: a handoff, saved automatically

CogniCore uses Claude Code's hooks. After each turn it saves a short, structured handoff:

text
Goal: Make the deploy pipeline survive restarts
State: PR #193 merged, downtime 27 min -> 6 s
Decisions:

  • Uploads run in a background process (why: a turn never waits on the network) Open tasks:
  • Publish the next release to PyPI Values: fix/deploy-permissions, port 8765

When the next session starts, it injects a short brief (about 450 tokens) instead of the whole history. If the agent needs more, it asks for a specific section.

Two design choices I'm happy with:

Rule-based extraction by default. It only calls an LLM to compress a session when it's over 3,000 tokens, so most saves cost zero model calls and memory is ready in about a second.
Newest revision wins. Uploads run in the background, and an older upload can never overwrite newer work.
Setup (about 2 minutes)
bash
pipx install "cognicore-env[mcp]"
cognicore install # sets up Claude Code and Codex

Restart Claude Code. That's it for local memory. Nothing leaves your machine.

Want the same memory in Claude.ai, ChatGPT or Cursor? Turn on sync:

bash
cognicore login

Then add the CogniCore connector in Claude.ai. Only the short handoff is synced, never your transcripts or file contents.

The test that convinced me

In Claude Code, I asked it to remember a code word: BLUE-HERON-4417.

The next day, in a separate Claude.ai chat, I asked: "What did I just do in Claude Code?"

It told me what I'd worked on, and gave me the code word back.

How it compares

I benchmarked it against claude-mem 15.7.0, the most popular memory plugin, on the same tasks. Both finished every follow-up correctly. CogniCore used 53K-60K new tokens vs 147K-216K, and memory was ready in about 1 second vs 70-130 seconds.

It's my own benchmark, so be skeptical: the script (scripts/bench_realworld.py) is in the repo and I'd genuinely like to hear if you get different numbers.

What's still not great
On Claude.ai, memory only updates when Claude decides to call the tool. There are no hooks on the web.
The saved summaries are sometimes noisy. I'm improving the extraction every week.
Try it

It's free and open source (Apache 2.0): https://github.com/cognicore-dev/cognicore-env

CogniCore — Memory that follows you between AI apps

CogniCore gives Claude, ChatGPT and coding agents like Claude Code and Codex a shared memory, so every new chat picks up where the last one stopped.

favicon cognicoree.tech

Carries your Claude Code work into Codex and back, so a new session resumes the same goal, decisions and open tasks. Hooks save each session from its…

favicon claudepluginhub.com

How do you keep context when you switch between AI tools? A notes file, copy-paste, or just re-explaining? I'd love to hear what works for you.

I built CogniCore largely with Claude Code, and used AI help to draft parts of this post.

Top comments (0)