memory-compress — Claude Code command: compress the memory tree
memory-compress shrinks the semantic memory tree by merging near-identical nodes and dropping duplicates, while key checkpoints stay put.
no license ★ 1,357 updated 2026-03-01
.claude/commands/memory-compress.mdWhat memory-compress does
The command opens the active tree at .wfgy/trees/active_tree.json and measures it first: node count, mean ΔS, how tightly nodes cluster. From those numbers it picks what to squeeze — pairs below ΔS 0.2, repeated insights, dead-end branches.
Four moves do the work. Close nodes merge into one with a combined insight. Intermediate steps drop out of a path so its ends link directly. A cluster folds into a summary node, and duplicates or loops get deleted. Checkpoints, branch points, nodes above ΔS 0.7 and anything marked important are held back.
Rollback runs through /memory:restore and a checkpoint, so /memory:checkpoint comes first — a compression without one leaves nothing to return to. Strength is set with --level (light in the examples), and --dry-run shows the plan without writing. The log lands in .wfgy/logs/compression.log.
What it helps with
- shrink a memory tree before a new session
- merge nodes that say nearly the same thing
- strip duplicate insights and circular links
- cut the tree down to a set node count
- preview the compression before writing anything
Example prompts for the agent
- Compress the memory tree, but just show me the plan first:
/memory:compress --dry-run. - Compress down to 500 nodes with
/memory:compress --target-nodes 500. - Only compress the stretch from
node_100tonode_500:/memory:compress --from "node_100" --to "node_500".
How to install memory-compress
Manually: put the files in place
.claude/commands/memory-compress.mdCall it with /memory-compress. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/memory-compress.mdCall it with /prompts:memory-compress. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/memory-compress.prompt.mdManually: put the files in place
.gemini/commands/memory-compress.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about memory-compress
How do I install memory-compress in Claude Code?
Copy the command file into your project at .claude/commands/memory-compress.md, then call /memory:compress from the session.
What does memory-compress do?
It merges similar nodes in the semantic tree, simplifies redundant paths and removes duplicates, keeping checkpoints and branch points intact.
Can I undo a compression?
Yes, with /memory:restore pointed at a checkpoint taken beforehand. Without a pre-compression checkpoint there is nothing to restore.