[FEATURE] Hierarchical memory to prevent silent loss at 200-line MEMORY.md limit

Resolved 💬 11 comments Opened Mar 29, 2026 by j-p-c Closed May 11, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Claude Code's auto memory stores entries in a flat MEMORY.md index capped
at 200 lines / 25KB. When a power user accumulates enough memories, entries
at the bottom of the index are silently truncated on reload. The topic files
still exist on disk but become orphaned — Claude can't find them because their
pointers are gone.

Auto Dream consolidates entries but maintains the flat structure. It doesn't
create hierarchy or push detail into sub-indices. For users with complex,
long-running projects, the flat model hits its ceiling and memories are
quietly lost.

Proposed Solution

Replace the flat index with a self-balancing tree. When MEMORY.md exceeds
a threshold (e.g. 150 lines), entries are grouped by memory type and pushed
into category index files in an _index/ subdirectory. Each category pointer
in MEMORY.md becomes a single line with a count and summary. If a category
index also overflows, it splits further by topic keyword. The tree grows in
depth, not width — same discipline at every level.

I built this as an external tool that runs via hooks:
https://github.com/j-p-c/alzheimer

It works today with all Claude Code models (Opus, Sonnet, Haiku) and requires
no dependencies beyond Python 3.6+ stdlib. Installation is one sentence to
Claude: "Install the alzheimer memory rebalancer from github.com/j-p-c/alzheimer."

Key design points:

  • Root stays small: MEMORY.md never exceeds 150 lines (headroom below the 200-line cap)
  • Detail pushes down, summaries push up — Claude gets enough context from the

summary line to decide whether to read deeper

  • Self-balancing via PostToolUse, SessionStart, and PreCompact hooks
  • Compatible with Auto Dream (rebuilds if Dream flattens the tree)
  • Configurable limits via .alzheimer.conf for forward-compatibility
  • 50 tests, MIT-0 license

Why This Matters

The 200-line limit means Claude Code's memory system has a hard ceiling on
complexity. Users who rely on memory for project context, preferences, and
workflow instructions hit this wall and lose information without warning.
A hierarchical approach lifts this ceiling without requiring changes to
Claude Code itself.

The tool is MIT-0 (no attribution required) — happy for the ideas or code
to be adopted natively if useful.

View original on GitHub ↗

This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗