manage-memory
Manage Memory
Maintain Claude Code's persistent memory directory so it stays accurate, concise, and useful across sessions. MEMORY.md is the only file loaded automatically — topic files are read on demand, when something links to them — so the index must stay both small enough to load whole and complete enough that every topic file is reachable from it.
MEMORY.md is truncated on load at 200 lines or 25KB, whichever comes first (per the Claude Code memory documentation). Measure both and act on the larger fraction: usage = max(size / 25000, lines / 200) — warn at 0.80, rewrite target 0.70. Above ~125 units per line the size cap binds first; at the ~150-character entry this skill targets — a derivation of this skill's own, not a documented recommendation — the real budget is ~166 lines, not 200. Never report a line count alone, and always name which cap binds.
What the size cap counts (measured, not documented). The cap is applied to UTF-16 code units — JavaScript String.length — rather than UTF-8 bytes or Unicode code points. For any text inside the Basic Multilingual Plane — ASCII, Latin-1 accents, CJK — the character count is the unit count, so a character count is exact for most real indexes. It diverges in two places: a byte count over-reports on any non-ASCII content (up to 3x on CJK, which is why a wc -c check can demand a prune the loader does not need), and a character count under-reports on astral characters such as emoji, where one character costs two units. Measured on Claude Code v2.1.238 (Windows) and 2.1.237 (Linux) and reported in anthropics/claude-code#82056, August 2026. Treat as version-volatile: the two documented numbers are the contract, this is how the current implementation counts.
size = sum(2 if ord(c) > 0xFFFF else 1 for c in text) # UTF-16 code units