# memory-compress

memory-compress shrinks the semantic memory tree by merging near-identical nodes and dropping duplicates, while key checkpoints stay put.

- command · `type=command` · Claude Code, Codex, GitHub Copilot, Gemini CLI · ★ 1357 repo stars
- Author: qdhenry
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/qdhenry/Claude-Command-Suite/tree/HEAD/.claude/commands/memory/memory-compress.md
- Updated: 2026-03-01
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/commands/memory-compress

## What it 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`.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/commands/memory-compress.md` — Call it with /memory-compress. For all projects use ~/.claude/commands/

### Codex

**Manually: put the files in place**
- File: `~/.codex/prompts/memory-compress.md` — Call it with /prompts:memory-compress. Codex marks this format deprecated in favour of skills

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/prompts/memory-compress.prompt.md`

### Gemini CLI

**Manually: put the files in place**
- File: `.gemini/commands/memory-compress.toml` — Gemini stores commands as TOML: the prompt text goes into the prompt field

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/qdhenry/Claude-Command-Suite/tree/HEAD/.claude/commands/memory/memory-compress.md

## When to use it
- 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
- 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_100` to `node_500`: `/memory:compress --from "node_100" --to "node_500"`.

## Similar
- [compact-praetorian](https://affpapa.org/en/nevibecode/commands/compact-praetorian.md) — command · ★ 78 repo stars
- [memory-discipline](https://affpapa.org/en/nevibecode/skills/memory-discipline.md) — skill · 4900 installs
- [OMEGA Memory](https://affpapa.org/en/nevibecode/mcp/omega-memory-omega-memory.md) — MCP server · 2862 installs
- [claude-memory-curator](https://affpapa.org/en/nevibecode/skills/claude-memory-curator.md) — skill · 2700 installs
- [memory-continue](https://affpapa.org/en/nevibecode/skills/memory-continue.md) — skill · 1500 installs
- [ov-experience-memory](https://affpapa.org/en/nevibecode/skills/ov-experience-memory.md) — skill · 865 installs

From the same set: [qdhenry/claude-command-suite](https://affpapa.org/en/nevibecode/by/qdhenry/claude-command-suite.md) — 112 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
