MemoryRouter
Claude Code memory

Claude Code memory: what it keeps, and what compaction takes

Claude Code reads your instructions at startup, keeps a running summary of the session, and compacts when the context window fills. Everything the session learned that is not in a file dies at one of those boundaries.

Anthropic. Sources checked 2026-09-25.

How Claude Code handles memory today

Two systems, per the official memory docs. CLAUDE.md files are written by you and loaded in full at session start: project instructions, conventions, commands. Auto memory is Claude’s own notes, written to MEMORY.md during sessions, and only the first 200 lines or 25KB of it is loaded at startup.

A session also carries a live conversation, and Claude Code compacts when that fills up. The compaction summary is a lossy rewrite of the session, produced by the model, under budget pressure.

What Claude Code forgets

What survives a session is files. What does not survive is the reasoning behind them.

The fix with MemoryRouter

The published hook package installs at deterministic Claude Code lifecycle points. Recall runs before each prompt, capture runs after each completed turn, and compaction, resume, and fork all re-inject project memory the moment they finish.

  1. 1

    Install the hooks in your project

    Grab a Memory Key from the app, then run the installer in the repo. It wires SessionStart, UserPromptSubmit, Stop, PreCompact, PostCompact, resume, and fork.

    Run inside your project

    npx -y memoryrouter-claude init
  2. 2

    Verify the integration

    Start a new session, then check health. A healthy setup ends with "Automatic memory integration is healthy."

    Health check

    npx -y memoryrouter-claude doctor
  3. 3

    Confirm it survives compaction

    Stash a decision mid-session, force a compaction, then keep going. The recalled context comes back in the next turn instead of a request to restate the plan.

Your Memory Key stays under ~/.memoryrouter/ with owner-only permissions. It is never written into .claude or your repository, so hook settings are safe to commit for a team.

Install for Claude Code

Full install guide, commands, and the MCP option on the Claude Code page. 14-day free trial.

Related

Claude Code memory FAQ

Sources

Sources checked 2026-09-25. Tool behavior changes; check the vendor docs before relying on a detail.

Start free