DEV Community

Jamie Cole
Jamie Cole

Posted on • Edited on

Never lose Claude Code context again

Never lose Claude Code context again

Yesterday I had a Claude Code session that actually worked. Like, properly clicked. We refactored the auth module, tracked down a nasty JWT refresh edge case, figured out why the middleware was silently eating POST requests. By the end of it, Claude understood the whole system.

Then I closed the terminal.

This morning: fresh session, blank slate. "Hi! How can I help you today?"

I had to re-explain that this is a FastAPI app, PostgreSQL not SQLite, token-based auth, and we just refactored the middleware so please don't suggest the old pattern from the docs. The wrong one. That I already told you about yesterday.

That re-explanation took 8 minutes. On a good day.

I've been using Claude Code daily for a few months. The session amnesia is the thing that grinds me down. Not hallucinations, not wrong suggestions - those are catchable. The tax you pay just to get back to where you were.

What I built

claude-remember. Python CLI, MIT licensed, free. Two commands:

# end of session
claude-remember save

# start of next session
claude-remember load
Enter fullscreen mode Exit fullscreen mode

When you save, it captures your current context - open files, recent git diff, working directories, any notes you want to add - and dumps it to a .claude-context file in your project root.

The output looks roughly like this:

{
  "saved_at": "2025-02-27T09:14:00Z",
  "project": "auth-service",
  "active_files": ["src/auth/middleware.py", "src/auth/tokens.py"],
  "recent_changes": "Refactored JWT middleware, moved refresh logic to tokens.py",
  "git_branch": "feature/auth-refactor",
  "notes": [
    "JWT refresh edge case: check expiry buffer, not just expired bool",
    "Middleware now uses dependency injection - don't revert this"
  ],
  "context_summary": "FastAPI auth service. PostgreSQL. Token-based auth with refresh."
}
Enter fullscreen mode Exit fullscreen mode

When you load it in a fresh session, it formats all of that into a message Claude sees at the start. By message two you're already talking about the actual problem instead of re-litigating your stack choices.

You can add notes before saving, which is the part I use most:

claude-remember save --note "found the auth bug - middleware.py line 47, haven't fixed yet"
Enter fullscreen mode Exit fullscreen mode

Future-you will be grateful for that.

What it doesn't do

This works by injecting context at the start of a session, not by persisting actual Claude memory. So it's not perfect - if your context is massive you'll run into token limits. For 90% of daily use it's fine. The 8-minute re-explanation drops to about 30 seconds.

Also no magic. If you saved context three weeks ago and your codebase has changed a lot since, the loaded context will be stale. Worth re-saving at the end of each working session rather than just once.

The other half: project-level context

Session context (what happened recently) is one problem. Project context (what Claude should always know about your codebase) is another.

That's what CLAUDE.md is for - a file in your project root that Claude reads at the start of every session. Stack, build commands, code style, things to never do. You write it once, it loads automatically. Combined with claude-remember for session notes, you basically eliminate the re-explanation tax.

If you haven't set one up yet, there's a free CLAUDE.md generator that produces a solid starting skeleton based on your stack. Pick your language and framework, copy the output into your project. Takes about 30 seconds.

Why I built this

There's a thread on r/ClaudeAI with 384 upvotes from people complaining about exactly this problem. That's not a small signal. And most of the comments were people saying they'd either hacked something themselves or were just living with the pain.

Seemed worth building properly.

Install

pip install claude-remember
Enter fullscreen mode Exit fullscreen mode

Or from source:

git clone github.com/GenesisClawbot/claude-remember
cd claude-remember
pip install -e .
Enter fullscreen mode Exit fullscreen mode

Then in any project:

claude-remember save    # before closing
claude-remember load    # at the start of next session
Enter fullscreen mode Exit fullscreen mode

Add .claude-context to your .gitignore if you don't want it committed - it may contain file paths and notes with sensitive project info.

GitHub: github.com/GenesisClawbot/claude-remember

If something's broken or you want a feature, open an issue. Planning to add a hosted version for teams at some point, but the free CLI will stay free.


Building autonomous agents? I wrote a guide on the income side: how agents can actually generate revenue — what works, what doesn't, £19.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.