Claude Code memory between sessions, checked against your code
Claude Code starts every session from zero. Here is how to give it a memory per repository that recalls only what is relevant, flags notes that went stale, and costs no tokens until it is used.
Updated 2026-12-02
Claude Code forgets everything when a session ends. The fix you found yesterday, the reason the team chose pnpm, the test that is flaky on Mondays: gone. The usual workaround is to keep adding notes to CLAUDE.md. That works for a week. Then the file is loaded, in full, at the start of every session, it costs tokens every time, and half of it describes files that were renamed.
threadctx gives Claude Code a memory per repository that solves both problems: Claude recalls only the notes relevant to the task, and every note is checked against the code before Claude sees it.
Set it up in one command
npx threadctx setupThis installs the threadctx plugin with the claude command you already have. Open a new session in any repository and the first reply starts with a status line:
threadctx · context B (81/100) · 2,140 tokens/session, 600 duplicated → /context-check · 3 memories in useFrom then on you just work. When Claude fixes something non-obvious or you make a decision, it saves a note with memory_write. Next session, before similar work, it calls memory_query and gets the notes that matter.
What makes it different from a longer CLAUDE.md
| Notes in CLAUDE.md | threadctx memory | |
|---|---|---|
| Token cost | Loaded in full at every session start | Nothing until Claude asks; then only the relevant notes |
| Stale notes | Stay until someone notices | Flagged when they name files or scripts that no longer exist, or contradict your instructions or lockfile |
| Unsafe notes | Obeyed like any instruction | Secrets and download-and-run instructions are refused when written and withheld when read |
| Sharing | One file everyone edits | Personal notes on your machine; team notes in .threadctx/memory.json, reviewed in pull requests |
| Expiry | Never | Notes can expire, be superseded, and are flagged for review after 90 days |
Checked, not just stored
A memory is an instruction your agent will follow later, so it deserves the same checks as CLAUDE.md. Each time notes are recalled, threadctx compares them with the repository as it is now:
- A note that mentions src/billing/retry.ts after the file moved is marked may be stale.
- A note that says npm install in a repository whose lockfile is pnpm-lock.yaml is marked as conflicting.
- A note containing an API key or curl … | sh is withheld, and was refused when written.
- Expired and superseded notes are hidden. Old ones are flagged for review.
Checks cover what the repository can prove: files, scripts, commands, package manager, runtime versions and secrets. Claims about outside systems, such as a cloud account or a colleague’s preference, cannot be verified, and the answer says so.
Team memory without a server
Ask Claude to save a note for the team and it goes to .threadctx/memory.json in the repository. It is shared through git and reviewed in pull requests like any other change. In CI, one command fails the build when team memory no longer matches the code:
npx threadctx memory check --teamUseful commands
/memory-review # in Claude Code: review what Claude remembers, fix what went stale
/context-check # grade this repository's CLAUDE.md, AGENTS.md and rules
npx threadctx memory list # every note and its check resultEverything runs on your machine. No account, nothing uploaded, Apache-2.0. Prefer to see the opening line only in the terminal? Add sessionStart: { announce: false } to .threadctx/config.yaml.
Questions
Does Claude Code remember between sessions?
Not by itself. Each session starts with only the instruction files it loads, such as CLAUDE.md. threadctx adds a memory per repository that Claude queries when it needs it, so nothing is lost between sessions.
Why not just put everything in CLAUDE.md?
CLAUDE.md is loaded in full at the start of every session, so each note costs tokens every time, and nothing tells you when a note goes out of date. threadctx memory is recalled only when relevant and checked against the code first.
Does it upload my code or my notes?
No. Personal notes stay in ~/.threadctx/local.json on your machine and team notes in .threadctx/memory.json in your repository. threadctx runs locally and offline.
Does it work with Cursor, Copilot or Gemini CLI?
Yes. The memory tools are a standard MCP server: add npx -y threadctx mcp to any MCP client. The one-command setup and the session-start line are for Claude Code.
What does it cost?
Memory and the repository checks are free. Paid plans add organisation-wide audits and compliance evidence.