/memory-loop:consolidatefrom memory-loop
Periodically merge the memory index, long-tier memory files, and the habit file — deduplicate, resolve contradictions to the current truth, absolutize dates, bring HABITS.md back under budget — and propose the result for your confirmation before any write. Use when MEMORY.md grows large (~120+ lines), when the habit file is over budget, or when memories accumulate duplicates, contradictions, or stale facts.
Ships in memory-loop. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Capture and expiry keep memory flowing; nothing keeps it coherent. Over many
sessions the index bloats, two files describe the same thing, an old fact
survives next to the newer one that disproved it, and "yesterday" is frozen in a
note whose yesterday is long gone. This skill is the operate-stage cleanup: a
reflective pass that merges long-tier memory into durable, well-organized form —
and, like remember, never writes without your confirmation.
Adapted from xai-org/grok-build's "dream" consolidation pass (Apache-2.0), reframed around memory-loop's save gate and tier model.
It is a manual skill — there is no forced trigger. Run it when:
MEMORY.md has grown large (~120+ lines).signals.jsonl has accumulated correction signals worth reviewing (see
the signals pass below).memory-staleness-check.sh) reported
habits over budget, habits over rule cap, or habits over split threshold — or a write to HABITS.md was denied by
habits-budget-guard.sh.memory-staleness-check.sh) listed
re-verification candidates, index drift, orphans or broken index links — it
is the closest thing this skill has to a trigger, and it only ever reports.Read MEMORY.md, the tier: long memory files beside it, and the habit file
(habitsPath, default ~/.claude/groundwork/HABITS.md). Exclude:
| Excluded | Why |
|---|---|
Files without a tier key | Outside the lifecycle (the compatibility contract) — never touch them |
tier: short memories | The expiry sweep owns these; consolidation leaves them alone |
Identity files (the user/assistant names from setup) | Continuity anchors — changed only through the identity skill, never here |
Anything already under archived/ | Already retired |
Review each memory or group through five lenses (the consolidation prompt):
archived/, not delete — nothing is lost.The index is a separate artifact from the memories it points at, so it drifts on its own. All four checks are mechanical:
MEMORY.md: its one-line summary may describe
a version of the body that no longer exists. Re-read the body and rewrite the
line from it, never from the old summary.memoryIndexMaxLines (default 120) the index is itself the
thing to consolidate.Age is not wrongness. A memory past memoryReviewDays is a candidate for
re-verification, never a candidate for deletion:
reviewed: <today> and change nothing else. That is the
whole repair, and it is what stops the same file being reported forever.modified: <today>, and fix its index line.Two buckets the check reports are out of scope here (see the exclusion
table above) — route both through remember: untiered files, and tier: short
memories whose expiry is conditional or missing, which no sweep will ever
archive and which are retired by their event, not by their age.
HABITS.md is consolidated by the same five verbs, with one extra constraint: it
has a hard budget (habitsBudgetBytes, default 8000; habitsMaxRules, default
24) that a PreToolUse guard enforces at the write. Capture has an automatic
trigger and pruning does not, so without this pass the file only ever grows.
CLAUDE.md or the wiki.HABITS-ARCHIVE.md beside HABITS.md, keeping its [Cnn] pointer so the case
record still resolves. Never touch HABITS-CASES.md itself — the cases outlive
the rules that cited them.🛑 hard lines are consolidated, never dropped for budget: merge overlapping prohibitions and compress their inline background to one sentence, but a prohibition leaves this file only when it is promoted to a hook that enforces it.
~/.claude/groundwork/memory-loop/signals.jsonl accumulates one line per
detected correction (hooks/correction-signal.sh, UserPromptSubmit):
three keys only — ts, session_id, matched (a list of keyword
labels: 아니, 그게아니라, 틀렸, 다시해, dont, wrong) — never the prompt
text itself.
matched
label and by session_id — several corrections in one session on the
same label is the strongest signal of a repeated mistake worth
capturing.memory-loop:habit's three gates, or memory-loop:remember's
save gate) rather than writing anything directly here.signals.jsonl to remove
only the lines just reviewed (keep any appended after this run
started). Never truncate before that confirmation — an unreviewed
signal is not "handled" just because it was read.Read (read-only) MEMORY.md, the in-scope long-tier files,
signals.jsonl when this run includes the signals pass, and — when
this run includes the habit pass — all of HABITS.md.
Apply the five verbs and draft a per-file action table — no writing yet:
| File | Action | Basis (one line) |
|-----------------|---------------------------|----------------------------------------|
| a.md + b.md | merge → topic-x.md | same topic X in both; b is newer |
| c.md | evolve (edit in place) | 3 relative dates → absolute; 1 Resolve |
| d.md | archive | consumed project note; gist now global |
| e.md | keep | still valid, unchanged |
Include the before/after of each MEMORY.md index line that changes.
Refuse the degenerate case. If the table is empty — nothing genuinely merges, contradicts, or staled — report "nothing to consolidate" honestly. Never invent consolidation to look productive.
Confirm before writing. Present the table and ask the user to approve
all / pick items / reject. Flag any uncertain call (especially which side of
a contradiction is current) as a question, not a decision. No Write/Edit
before this confirmation.
Apply only what was approved. For each merge: create the merged file, move
the originals to archived/, update the MEMORY.md index line, and fix any
[[wikilink]] references to renamed files (grep to confirm none dangle).
Preserve every frontmatter key (tier, salience, expires, …) on the
surviving file.
Report what changed: N actions applied, index N → N lines.
Record the run so the upkeep check stops asking:
mkdir -p ~/.claude/groundwork/memory-loop
date +%Y-%m-%d > ~/.claude/groundwork/memory-loop/last-consolidate
Write it after step 5 applied something, or after an honest "nothing to consolidate" in step 3 — never as a way to silence the check without looking.
mv plus a save-gate re-save).tier to untiered files here; that is the remember gate's job.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/habitDistill a lesson — a mistake, a user correction, or a praised behavior — into HABITS.md as a positive practice or a hard line, after it clears the damage/recurrence/generality gate. Use after the user corrects you, after an incident, or when a correction signal fires./identitySet, change, or decline the user/assistant names that memory-loop injects at session start. Use when the user wants to set up names, rename either party, ask the assistant to pick its own name, or stop the name-setup offer from appearing./rememberSave gate for persistent memories — confirm tier (long/short) and expiry with the user before writing, so hallucinated or transient facts never enter long-term memory. Use whenever saving a memory file, and when the expiry sweep reports archived memories.memory-loop@buildwithclaude is listed by davepoon/buildwithclaude — review the source before installing
npx claudepluginhub davepoon/buildwithclaude --plugin memory-loop