memory-consolidate

memory-consolidate is a command for Claude Code from rand/mnemosyne. It costs 12 tokens per session (1,240 once invoked), scanned A, original, MIT.

A command for finding and combining similar or duplicate memories in a local knowledge base, either after review or automatically.

In plain words
What is it for?
Use `/memory-consolidate` to review candidates, analyse two memory IDs, limit the search to a namespace, or apply all recommendations automatically.
Why use it?
It reduces repeated information and helps keep stored project knowledge organised.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/rand/mnemosyne/memory-consolidate
Clone the repo
git clone --depth 1 https://github.com/rand/mnemosyne

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for memory-consolidate

README.md
[![agentmods](https://agentmods.dev/badge/commands/rand/mnemosyne/memory-consolidate.svg)](https://agentmods.dev/commands/rand/mnemosyne/memory-consolidate)
Your own site
<a href="https://agentmods.dev/commands/rand/mnemosyne/memory-consolidate"><img src="https://agentmods.dev/badge/commands/rand/mnemosyne/memory-consolidate.svg" alt="Measured on agentmods" height="20"></a>
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,240 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00012 $0.01240
Opus 5 $0.00006 $0.00620
Sonnet 5 $0.00002 $0.00248
Haiku 4.5 $0.00001 $0.00124

Measured 4d ago against content hash 42344c8202d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-consolidate scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/memory-consolidate.md · 160 lines

How it starts

The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.

I will help you consolidate similar or duplicate memories to keep your knowledge base clean and organized.

Usage:

  • /memory-consolidate - Find and review consolidation candidates
  • /memory-consolidate --auto - Auto-apply all recommendations
  • /memory-consolidate <id1> <id2> - Analyze specific pair
  • /memory-consolidate --namespace <ns> - Limit to namespace

Instructions for me:

  1. Parse the arguments:

    • Extract --auto flag if present (auto-apply mode)
    • Extract --namespace flag if present (otherwise auto-detect)
    • Extract two memory IDs if provided as positional args
    • If both --auto and IDs provided: error
  2. Auto-detect namespace (if not specified):

    • Use Bash: git rev-parse --show-toplevel 2>/dev/null
    • Read CLAUDE.md for project name
    • Construct namespace as project:<name>
    • If no project: use null (all)
  3. Mode A: Specific pair analysis (if two IDs provided):

    • Call mnemosyne.consolidate with the two IDs:
    {
      "name": "mnemosyne.consolidate",
      "arguments": {
        "memory_ids": ["<id1>", "<id2>"],
        "auto_apply": false
      }
    }
    
    • Display the recommendation:
    Analyzing consolidation of two memories:
    
    Memory A [<importance>/10]: <summary>
    Created: <date>
    <content preview (200 chars)>
    
    Memory B [<importance>/10]: <summary>
    Created: <date>
    <content preview (200 chars)>
    
    ---
    
    LLM Recommendation: <MERGE|SUPERSEDE|KEEP_BOTH>
    
    <if MERGE>:
    Reason: Memories contain very similar information
    Action: Merge into Memory <A|B> (higher importance), archive the other
    New content will combine both perspectives
    
    <if SUPERSEDE>:
    Reason: Memory <A|B> contains updated/more accurate information
    Action: Keep Memory <kept>, mark Memory <superseded> as superseded
    
    <if KEEP_BOTH>:
    Reason: Memories are distinct and should be maintained separately
    Action: No consolidation needed
    
    ---
    
    Apply this recommendation? [y/N]:
    (Or run with /memory-consolidate --auto <id1> <id2> to apply automatically)
    
  4. Mode B: Find candidates (default mode):

    • Call mnemosyne.consolidate without IDs:
    {
      "name": "mnemosyne.consolidate",
      "arguments": {
        "namespace": "<namespace or null>",
        "auto_apply": <--auto flag value>
      }
    }
    
    • If candidates found, display each:
    🔍 Scanning for consolidation candidates in <namespace>...
    
    Found <N> candidate pairs:
    
    <for each pair>:
    
    <number>. <MERGE|SUPERSEDE|KEEP_BOTH> Recommended
       Memory A [<imp>/10]: "<summary>"
       Created: <date>, Tags: <tags>
    
       Memory B [<imp>/10]: "<summary>"
       Created: <date>, Tags: <tags>
    
       Similarity: <high|medium|low>
       Reason: <LLM reasoning>
    
       <if --auto>:
       ✓ Applied: <action taken>
    
       <if not --auto>:
       [View details: /memory-consolidate <idA> <idB>]
    
    ---
    
    • Summary at end:
    Summary:
    - Total pairs analyzed: <N>
    - Merge recommended: <N>
    - Supersede recommended: <N>
    - Keep both: <N>
    
    <if --auto>:
    - Actions applied: <N>
    - Memories archived: <N>
    
    <if not --auto>:
    To apply recommendations:
    - Review each pair: /memory-consolidate <id1> <id2>
    - Auto-apply all: /memory-consolidate --auto
    
  5. Interactive confirmation (if not --auto):

    • After showing recommendation for a specific pair
    • Ask user: "Apply this recommendation? [y/N]: "
    • If 'y': Call consolidate again with auto_apply: true
    • If 'N' or anything else: Do nothing, exit
  6. Format the detailed pair view: When showing specific pair details, include:

    • Full content (not just preview)
    • All tags and keywords
    • Related files and entities
    • Link information
    • Access statistics
  7. Error handling:

    • If MCP server not available: "Error: Mnemosyne MCP server not running"
    • If API key not configured: "Error: Consolidation requires LLM. Configure API key with 'mnemosyne config set-key'"
    • If invalid memory IDs: "Error: Invalid memory ID(s). Use /memory-list to see available memories"
    • If no candidates found: "No consolidation candidates found. Your memory base is well-organized!"
    • If both --auto and IDs provided: "Error: Cannot use --auto with specific memory IDs"

Read the full file on GitHub · 160 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 160 lines · 12 tokens per session scan A 42344c8202d9

Subscribe to this mod's changes

memory-consolidate is a command published in the GitHub repository rand/mnemosyne (84 stars, last pushed 9mo ago), licensed MIT. It adds 12 tokens to every session and 1,240 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.